Adds new CLI features (#24)

This commit is contained in:
Franck Nijhof 2020-04-02 02:12:23 +02:00 committed by GitHub
parent b4b61fb4f7
commit 11d683cc87
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 205 additions and 55 deletions

View file

@ -27,26 +27,6 @@ function bashio::os.update() {
bashio::cache.flush_all
}
# ------------------------------------------------------------------------------
# Updates HassOS CLI to the latest version.
#
# Arguments:
# $1 Version to update to (optional)
# ------------------------------------------------------------------------------
function bashio::os.update_cli() {
local version=${1:-}
bashio::log.trace "${FUNCNAME[0]}:" "$@"
if bashio::var.has_value "${version}"; then
version=$(bashio::var.json version "${version}")
bashio::api.supervisor POST /os/update/cli "${version}"
else
bashio::api.supervisor POST /os/update/cli
fi
bashio::cache.flush_all
}
# ------------------------------------------------------------------------------
# Load HassOS host configuration from USB stick.
# ------------------------------------------------------------------------------
@ -128,41 +108,6 @@ function bashio::os.update_available() {
return "${__BASHIO_EXIT_OK}"
}
# ------------------------------------------------------------------------------
# Returns the CLI version of HassOS.
# ------------------------------------------------------------------------------
function bashio::os.version_cli() {
bashio::log.trace "${FUNCNAME[0]}"
bashio::os 'os.info.version_cli' '.version_cli'
}
# ------------------------------------------------------------------------------
# Returns the latest CLI version of HassOS.
# ------------------------------------------------------------------------------
function bashio::os.version_cli_latest() {
bashio::log.trace "${FUNCNAME[0]}"
bashio::os 'os.info.version_cli_latest' '.version_cli_latest'
}
# ------------------------------------------------------------------------------
# Checks if there is an update available for the Supervisor.
# ------------------------------------------------------------------------------
function bashio::os.update_available_cli() {
local version
local last_version
bashio::log.trace "${FUNCNAME[0]}"
version=$(bashio::os.version_cli)
last_version=$(bashio::os.version_cli_latest)
if [[ "${version}" = "${last_version}" ]]; then
return "${__BASHIO_EXIT_NOK}"
fi
return "${__BASHIO_EXIT_OK}"
}
# ------------------------------------------------------------------------------
# Returns the board running HassOS.
# ------------------------------------------------------------------------------