mirror of
https://github.com/hassio-addons/bashio.git
synced 2025-05-06 20:11:24 +00:00
✨ Add watchdog to add-on (#32)
This commit is contained in:
parent
dc6ba0d6d5
commit
3bf2267431
1 changed files with 25 additions and 0 deletions
|
@ -1009,6 +1009,31 @@ function bashio::addon.ingress_port() {
|
|||
'.ingress_port // empty'
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns or sets whether or not watchdog is enabled for this add-on.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Add-on slug (optional, default: self)
|
||||
# $2 Set current watchdog state (Optional)
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::addon.watchdog() {
|
||||
local slug=${1:-'self'}
|
||||
local watchdog=${2:-}
|
||||
|
||||
bashio::log.trace "${FUNCNAME[0]}" "$@"
|
||||
|
||||
if bashio::var.has_value "${watchdog}"; then
|
||||
watchdog=$(bashio::var.json watchdog "^${watchdog}")
|
||||
bashio::api.supervisor POST "/addons/${slug}/options" "${watchdog}"
|
||||
bashio::cache.flush_all
|
||||
else
|
||||
bashio::addons \
|
||||
"${slug}" \
|
||||
"addons.${slug}.watchdog" \
|
||||
'.watchdog // false'
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# List all available stats about an add-on.
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue