mirror of
https://github.com/hassio-addons/bashio.git
synced 2025-05-06 12:01:25 +00:00
✨ Adds new CLI features (#24)
This commit is contained in:
parent
b4b61fb4f7
commit
11d683cc87
3 changed files with 205 additions and 55 deletions
55
lib/os.sh
55
lib/os.sh
|
@ -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.
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue