Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions lib/addons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ function bashio::addons() {
fi
local info
local response
local installed
local info_source

bashio::log.trace "${FUNCNAME[0]}" "$@"

Expand All @@ -171,22 +173,29 @@ function bashio::addons() {
return "${__BASHIO_EXIT_OK}"
fi

if bashio::var.false "${slug}"; then
if bashio::cache.exists "addons.list"; then
info=$(bashio::cache.get 'addons.list')
else
info=$(bashio::api.supervisor GET "/addons" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get addons from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "addons.list" "${info}"
fi
if bashio::cache.exists "store.info"; then
info=$(bashio::cache.get 'store.info')
else
info=$(bashio::api.supervisor GET "/store/info" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get store info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
fi
bashio::cache.set "store.info" "${info}"
fi

if ! bashio::var.false "${slug}"; then
if bashio::cache.exists "addons.${slug}.info"; then
info=$(bashio::cache.get "addons.${slug}.info")
else
info=$(bashio::api.supervisor GET "/addons/${slug}/info" false)
installed=$(bashio::jq "${info}" '.addons[] | select(.slug == "'"${slug}"'") | .installed')
if bashio::var.false "${installed}"; then
info_source="store"
else
info_source="addons"
fi

info=$(bashio::api.supervisor GET "/${info_source}/${slug}/info" false)
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
bashio::log.error "Failed to get addon info from Supervisor API"
return "${__BASHIO_EXIT_NOK}"
Expand Down Expand Up @@ -232,6 +241,14 @@ function bashio::addons.installed() {
fi
}

# ------------------------------------------------------------------------------
# Returns a list of add-on repositories installed.
# ------------------------------------------------------------------------------
function bashio::addons.repositories() {
bashio::log.trace "${FUNCNAME[0]}"
bashio::addons 'addons.info.repositories' '.repositories[]'
}

# ------------------------------------------------------------------------------
# Returns the name of an add-on.
#
Expand Down
24 changes: 2 additions & 22 deletions lib/supervisor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -230,26 +230,6 @@ function bashio::supervisor.ip_address() {
bashio::supervisor 'supervisor.info.ip_address' '.ip_address'
}

# ------------------------------------------------------------------------------
# Returns the time to wait after boot in seconds.
#
# Arguments:
# $1 Timezone to set (optional).
# ------------------------------------------------------------------------------
function bashio::supervisor.wait_boot() {
local wait=${1:-}

bashio::log.trace "${FUNCNAME[0]}:" "$@"

if bashio::var.has_value "${wait}"; then
wait=$(bashio::var.json wait_boot "${wait}")
bashio::api.supervisor POST /supervisor/options "${wait}"
bashio::cache.flush_all
else
bashio::supervisor 'supervisor.info.wait_boot' '.wait_boot'
fi
}

# ------------------------------------------------------------------------------
# Returns if debug is enabled on the supervisor
#
Expand Down Expand Up @@ -303,15 +283,15 @@ function bashio::supervisor.debug_block() {
# ------------------------------------------------------------------------------
function bashio::supervisor.addons() {
bashio::log.trace "${FUNCNAME[0]}"
bashio::supervisor 'supervisor.info.addons' '.addons[].slug'
bashio::addons.installed
}

# ------------------------------------------------------------------------------
# Returns a list of add-on repositories installed.
# ------------------------------------------------------------------------------
function bashio::supervisor.addons_repositories() {
bashio::log.trace "${FUNCNAME[0]}"
bashio::supervisor 'supervisor.info.addons_repositories' '.addons_repositories[]'
bashio::addons.repositories
}

# ------------------------------------------------------------------------------
Expand Down