mirror of
https://github.com/hassio-addons/bashio.git
synced 2025-05-07 04:21:29 +00:00
Compare commits
55 commits
Author | SHA1 | Date | |
---|---|---|---|
|
5059ff133e | ||
|
445707a903 | ||
|
d70505aada | ||
|
e297fa5c2c | ||
|
c6de3e5756 | ||
|
b0219ef6f1 | ||
|
2b21846d28 | ||
|
dc3e044064 | ||
|
f3bd57130c | ||
|
324f46b5c4 | ||
|
8b96a704cc | ||
|
68464b7655 | ||
|
2de0c2304a | ||
|
fe0f961efc | ||
|
e98156103b | ||
|
52d3a9b40c | ||
|
93e00b593e | ||
|
2f86c63e60 | ||
|
30897c753a | ||
|
818a04b905 | ||
|
6644179728 | ||
|
2860658149 | ||
|
726d3dc511 | ||
|
8861097209 | ||
|
8114de4bbd | ||
|
239a59a2ca | ||
|
d3e2077093 | ||
|
854f8d646c | ||
|
efe813a251 | ||
|
848e6f88c1 | ||
|
b31320da4f | ||
|
1430aaa8eb | ||
|
dd15a1e41d | ||
|
8c88a67db9 | ||
|
780232345e | ||
|
6548123dad | ||
|
30c4b35fa2 | ||
|
5338104d2a | ||
|
f8fc8555b9 | ||
|
04c052828d | ||
|
b4522f150d | ||
|
5a1278193e | ||
|
167216925b | ||
|
38bed6bc6b | ||
|
60cabe22b7 | ||
|
4e7c05b062 | ||
|
77a233097e | ||
|
9e2fc434ed | ||
|
7ffe92b5af | ||
|
440e332cb1 | ||
|
c07f6d51d1 | ||
|
8b59f043a0 | ||
|
8b304f8d25 | ||
|
4b8587093e | ||
|
69608c0d12 |
39 changed files with 248 additions and 77 deletions
14
.github/workflows/ci.yaml
vendored
14
.github/workflows/ci.yaml
vendored
|
@ -17,16 +17,16 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2.4.0
|
||||
uses: actions/checkout@v4
|
||||
- name: 🚀 Run mdl
|
||||
uses: actionshub/markdownlint@2.0.2
|
||||
uses: actionshub/markdownlint@v3.1.4
|
||||
|
||||
lint-shellcheck:
|
||||
name: Shellcheck
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2.4.0
|
||||
uses: actions/checkout@v4
|
||||
- name: 🚀 Run Shellcheck
|
||||
uses: ludeeus/action-shellcheck@1.1.0
|
||||
env:
|
||||
|
@ -37,18 +37,18 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2.4.0
|
||||
uses: actions/checkout@v4
|
||||
- name: 🚀 Run YAMLLint
|
||||
uses: frenck/action-yamllint@v1.1
|
||||
uses: frenck/action-yamllint@v1.5
|
||||
|
||||
lint-prettier:
|
||||
name: Prettier
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2.4.0
|
||||
uses: actions/checkout@v4
|
||||
- name: 🚀 Run Prettier
|
||||
uses: creyD/prettier_action@v4.0
|
||||
uses: creyD/prettier_action@v4.3
|
||||
with:
|
||||
prettier_options: --write **/*.{json,js,md,yaml}
|
||||
env:
|
||||
|
|
2
.github/workflows/labels.yaml
vendored
2
.github/workflows/labels.yaml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: ⤵️ Check out code from GitHub
|
||||
uses: actions/checkout@v2.4.0
|
||||
uses: actions/checkout@v4
|
||||
- name: 🚀 Run Label Syncer
|
||||
uses: micnncim/action-label-syncer@v1.3.0
|
||||
env:
|
||||
|
|
2
.github/workflows/lock.yaml
vendored
2
.github/workflows/lock.yaml
vendored
|
@ -12,7 +12,7 @@ jobs:
|
|||
name: 🔒 Lock closed issues and PRs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: dessant/lock-threads@v3.0.0
|
||||
- uses: dessant/lock-threads@v5.0.1
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
issue-inactive-days: "30"
|
||||
|
|
2
.github/workflows/release-drafter.yaml
vendored
2
.github/workflows/release-drafter.yaml
vendored
|
@ -13,6 +13,6 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🚀 Run Release Drafter
|
||||
uses: release-drafter/release-drafter@v5.15.0
|
||||
uses: release-drafter/release-drafter@v6.1.0
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
|
2
.github/workflows/stale.yaml
vendored
2
.github/workflows/stale.yaml
vendored
|
@ -13,7 +13,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: 🚀 Run stale
|
||||
uses: actions/stale@v4
|
||||
uses: actions/stale@v9
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
days-before-stale: 30
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# MIT License
|
||||
|
||||
Copyright (c) 2019-2021 Franck Nijhof
|
||||
Copyright (c) 2019-2025 Franck Nijhof
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
|
|
@ -147,7 +147,7 @@ check [the contributor's page][contributors].
|
|||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2021 Franck Nijhof
|
||||
Copyright (c) 2019-2025 Franck Nijhof
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -185,7 +185,7 @@ SOFTWARE.
|
|||
[issue]: https://github.com/hassio-addons/bashio/issues
|
||||
[keepchangelog]: http://keepachangelog.com/en/1.0.0/
|
||||
[license-shield]: https://img.shields.io/github/license/hassio-addons/bashio.svg
|
||||
[maintenance-shield]: https://img.shields.io/maintenance/yes/2021.svg
|
||||
[maintenance-shield]: https://img.shields.io/maintenance/yes/2025.svg
|
||||
[patreon-shield]: https://frenck.dev/wp-content/uploads/2019/12/patreon.png
|
||||
[patreon]: https://www.patreon.com/frenck
|
||||
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -164,6 +164,10 @@ function bashio::addons() {
|
|||
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
|
||||
else
|
||||
|
@ -171,6 +175,10 @@ function bashio::addons() {
|
|||
info=$(bashio::cache.get "addons.${slug}.info")
|
||||
else
|
||||
info=$(bashio::api.supervisor GET "/addons/${slug}/info" false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get addon info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set "addons.${slug}.info" "${info}"
|
||||
fi
|
||||
fi
|
||||
|
@ -311,7 +319,7 @@ function bashio::addon.url() {
|
|||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns the deatched state of an add-on.
|
||||
# Returns the detached state of an add-on.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Add-on slug (optional, default: self)
|
||||
|
@ -562,6 +570,14 @@ function bashio::addon.config() {
|
|||
|
||||
response=$(bashio::api.supervisor GET "/addons/self/options/config" false)
|
||||
|
||||
# If the add-on has no configuration, it returns an empty string.
|
||||
# This is Bashio logic, that is problematic in this case, so make it a
|
||||
# emtpty JSON object instead.
|
||||
if bashio::var.is_empty "${response}";
|
||||
then
|
||||
response="{}"
|
||||
fi
|
||||
|
||||
bashio::cache.set "${cache_key}" "${response}"
|
||||
printf "%s" "${response}"
|
||||
|
||||
|
@ -595,7 +611,7 @@ function bashio::addon.network_description() {
|
|||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns a user configured port number for a original port number.
|
||||
# Returns a user configured port number for an original port number.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Original port number
|
||||
|
@ -775,7 +791,7 @@ function bashio::addon.usb() {
|
|||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns whether or not this add-on has a icon available.
|
||||
# Returns whether or not this add-on has an icon available.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Add-on slug
|
||||
|
@ -1194,6 +1210,10 @@ function bashio::addon.stats() {
|
|||
info=$(bashio::cache.get "addons.${slug}.stats")
|
||||
else
|
||||
info=$(bashio::api.supervisor GET "/addons/${slug}/stats" false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get addon stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set "addons.${slug}.stats" "${info}"
|
||||
fi
|
||||
|
||||
|
|
11
lib/api.sh
11
lib/api.sh
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -64,6 +64,11 @@ function bashio::api.supervisor() {
|
|||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
|
||||
if [[ "${status}" -eq 403 ]]; then
|
||||
bashio::log.error "Unable to access the API, forbidden"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
|
||||
if [[ "${status}" -eq 404 ]]; then
|
||||
bashio::log.error "Requested resource ${resource} was not found"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
|
@ -82,13 +87,13 @@ function bashio::api.supervisor() {
|
|||
fi
|
||||
|
||||
if [[ "${status}" -ne 200 ]]; then
|
||||
bashio::log.error "Unknown HTTP error occured"
|
||||
bashio::log.error "Unknown HTTP error occurred"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
|
||||
if bashio::var.true "${raw}"; then
|
||||
echo "${response}"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
return "${__BASHIO_EXIT_OK}"
|
||||
fi
|
||||
|
||||
result=$(bashio::jq "${response}" 'if .data == {} then empty else .data end')
|
||||
|
|
10
lib/audio.sh
10
lib/audio.sh
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -77,6 +77,10 @@ function bashio::audio() {
|
|||
info=$(bashio::cache.get 'audio.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /audio/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get audio info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'audio.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -147,6 +151,10 @@ function bashio::audio.stats() {
|
|||
info=$(bashio::cache.get 'audio.stats')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /audio/stats false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get audio stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'audio.stats' "${info}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -22,5 +22,7 @@ __BASHIO_LIB_DIR=$(dirname "${__BASHIO_BIN}")
|
|||
source "${__BASHIO_LIB_DIR}/bashio.sh"
|
||||
|
||||
# Execute source
|
||||
BASH_ARGV0=${1:?script to source must be provided}
|
||||
shift
|
||||
# shellcheck source=/dev/null
|
||||
source "$@"
|
||||
source "$0" "$@"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# shellcheck disable=SC2034,SC2155
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
10
lib/cli.sh
10
lib/cli.sh
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -51,6 +51,10 @@ function bashio::cli() {
|
|||
info=$(bashio::cache.get 'cli.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /cli/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get cli info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'cli.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -113,6 +117,10 @@ function bashio::cli.stats() {
|
|||
info=$(bashio::cache.get 'cli.stats')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /cli/stats false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get cli stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'cli.stats' "${info}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -544,13 +544,13 @@ function bashio::config.require.ssl() {
|
|||
if bashio::config.is_empty "${certfile}"; then
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "SSL has been enabled using the '${key}' option,"
|
||||
bashio::log.fatal "this requires a SSL certificate file which is"
|
||||
bashio::log.fatal "this requires an SSL certificate file which is"
|
||||
bashio::log.fatal "configured using the '${certfile}' option in the"
|
||||
bashio::log.fatal "add-on configuration."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Unfortunately, the '${certfile}' option is empty."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Consider configuring or getting a SSL certificate"
|
||||
bashio::log.fatal "Consider configuring or getting an SSL certificate"
|
||||
bashio::log.fatal "or setting the '${key}' option to 'false' in case"
|
||||
bashio::log.fatal "you are not planning on using SSL with this add-on."
|
||||
bashio::log.fatal
|
||||
|
@ -563,13 +563,13 @@ function bashio::config.require.ssl() {
|
|||
if bashio::config.is_empty "${keyfile}"; then
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "SSL has been enabled using the '${key}' option,"
|
||||
bashio::log.fatal "this requires a SSL certificate key file which is"
|
||||
bashio::log.fatal "this requires an SSL certificate key file which is"
|
||||
bashio::log.fatal "configured using the '${keyfile}' option in the"
|
||||
bashio::log.fatal "add-on configuration."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Unfortunately, the '${keyfile}' option is empty."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Consider configuring or getting a SSL certificate"
|
||||
bashio::log.fatal "Consider configuring or getting an SSL certificate"
|
||||
bashio::log.fatal "or setting the '${key}' option to 'false' in case"
|
||||
bashio::log.fatal "you are not planning on using SSL with this add-on."
|
||||
bashio::log.fatal
|
||||
|
@ -582,18 +582,18 @@ function bashio::config.require.ssl() {
|
|||
if ! bashio::fs.file_exists "/ssl/$(bashio::config "${certfile}")"; then
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "SSL has been enabled using the '${key}' option,"
|
||||
bashio::log.fatal "this requires a SSL certificate file which is"
|
||||
bashio::log.fatal "this requires an SSL certificate file which is"
|
||||
bashio::log.fatal "configured using the '${certfile}' option in the"
|
||||
bashio::log.fatal "add-on configuration."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Unfortunately, the file specified in the"
|
||||
bashio::log.fatal "'${certfile}' option does not exists."
|
||||
bashio::log.fatal "'${certfile}' option does not exist."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Please ensure the certificate file exists and"
|
||||
bashio::log.fatal "is placed in the '/ssl/' directory."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "In case you don't have SSL yet, consider getting"
|
||||
bashio::log.fatal "a SSL certificate or setting the '${key}' option"
|
||||
bashio::log.fatal "an SSL certificate or setting the '${key}' option"
|
||||
bashio::log.fatal "to 'false' in case you are not planning on using"
|
||||
bashio::log.fatal "SSL with this add-on."
|
||||
bashio::log.fatal
|
||||
|
@ -606,18 +606,18 @@ function bashio::config.require.ssl() {
|
|||
if ! bashio::fs.file_exists "/ssl/$(bashio::config "${keyfile}")"; then
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "SSL has been enabled using the '${key}' option,"
|
||||
bashio::log.fatal "this requires a SSL certificate key file which is"
|
||||
bashio::log.fatal "this requires an SSL certificate key file which is"
|
||||
bashio::log.fatal "configured using the '${keyfile}' option in the"
|
||||
bashio::log.fatal "add-on configuration."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Unfortunately, the file specified in the"
|
||||
bashio::log.fatal "'${keyfile}' option does not exists."
|
||||
bashio::log.fatal "'${keyfile}' option does not exist."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "Please ensure the certificate key file exists and"
|
||||
bashio::log.fatal "is placed in the '/ssl/' directory."
|
||||
bashio::log.fatal
|
||||
bashio::log.fatal "In case you don't have SSL yet, consider getting"
|
||||
bashio::log.fatal "a SSL certificate or setting the '${key}' option"
|
||||
bashio::log.fatal "an SSL certificate or setting the '${key}' option"
|
||||
bashio::log.fatal "to 'false' in case you are not planning on using"
|
||||
bashio::log.fatal "SSL with this add-on."
|
||||
bashio::log.fatal
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2034
|
||||
# shellcheck disable=SC2004,SC2034
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
10
lib/core.sh
10
lib/core.sh
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -99,6 +99,10 @@ function bashio::core() {
|
|||
info=$(bashio::cache.get 'core.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /core/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get core info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'core.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -249,6 +253,10 @@ function bashio::core.stats() {
|
|||
info=$(bashio::cache.get 'core.stats')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /core/stats false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get core stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'core.stats' "${info}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
10
lib/dns.sh
10
lib/dns.sh
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -77,6 +77,10 @@ function bashio::dns() {
|
|||
info=$(bashio::cache.get 'dns.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /dns/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get dns info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'dns.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -163,6 +167,10 @@ function bashio::dns.stats() {
|
|||
info=$(bashio::cache.get 'dns.stats')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /dns/stats false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get dns stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'dns.stats' "${info}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -31,6 +31,10 @@ function bashio::hardware() {
|
|||
info=$(bashio::cache.get 'hardware.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /hardware/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get hardware info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'hardware.info' "${info}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -63,6 +63,10 @@ function bashio::host() {
|
|||
info=$(bashio::cache.get 'host.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /host/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get host info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'host.info' "${info}"
|
||||
fi
|
||||
|
||||
|
|
14
lib/info.sh
14
lib/info.sh
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -31,6 +31,10 @@ function bashio::info() {
|
|||
info=$(bashio::cache.get 'info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -148,3 +152,11 @@ function bashio::info.operating_system() {
|
|||
bashio::log.trace "${FUNCNAME[0]}"
|
||||
bashio::info 'supervisor.info.operating_system' '.operating_system'
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns the current state of Home Assistant Supervisor
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::info.state() {
|
||||
bashio::log.trace "${FUNCNAME[0]}"
|
||||
bashio::info 'supervisor.info.running' '.state'
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -111,9 +111,9 @@ function bashio::log.log() {
|
|||
timestamp=$(date +"${__BASHIO_LOG_TIMESTAMP}")
|
||||
|
||||
output="${__BASHIO_LOG_FORMAT}"
|
||||
output="${output//\{TIMESTAMP\}/${timestamp}}"
|
||||
output="${output//\{MESSAGE\}/${message}}"
|
||||
output="${output//\{LEVEL\}/${__BASHIO_LOG_LEVELS[$level]}}"
|
||||
output="${output//\{TIMESTAMP\}/"${timestamp}"}"
|
||||
output="${output//\{MESSAGE\}/"${message}"}"
|
||||
output="${output//\{LEVEL\}/"${__BASHIO_LOG_LEVELS[$level]}"}"
|
||||
|
||||
echo -e "${output}" >&2
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -68,6 +68,10 @@ function bashio::multicast() {
|
|||
info=$(bashio::cache.get 'multicast.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /multicast/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get multicast info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'multicast.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -130,6 +134,10 @@ function bashio::multicast.stats() {
|
|||
info=$(bashio::cache.get 'multicast.stats')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /multicast/stats false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get multicast stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'multicast.stats' "${info}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck disable=SC2317
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -40,6 +41,10 @@ function bashio::network() {
|
|||
info=$(bashio::cache.get 'network.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /network/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get network info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'network.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -104,6 +109,10 @@ function bashio::network.interface() {
|
|||
info=$(bashio::cache.get "network.interface.${interface}.info")
|
||||
else
|
||||
info=$(bashio::api.supervisor GET "/network/interface/${interface}/info" false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get network interface info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set "network.interface.${interface}.info" "${info}"
|
||||
fi
|
||||
|
||||
|
@ -163,7 +172,7 @@ function bashio::network.enabled() {
|
|||
# Arguments:
|
||||
# $1 Interface name for this operation (optional)
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::network.enabled() {
|
||||
function bashio::network.connected() {
|
||||
local interface=${1:-'default'}
|
||||
|
||||
bashio::log.trace "${FUNCNAME[0]}"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -51,6 +51,10 @@ function bashio::observer() {
|
|||
info=$(bashio::cache.get 'observer.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /observer/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get observer info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'observer.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -121,6 +125,10 @@ function bashio::observer.stats() {
|
|||
info=$(bashio::cache.get 'observer.stats')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /observer/stats false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get observer stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'observer.stats' "${info}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -59,6 +59,10 @@ function bashio::os() {
|
|||
info=$(bashio::cache.get 'os.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /os/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get os info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'os.info' "${info}"
|
||||
fi
|
||||
|
||||
|
|
10
lib/pwned.sh
10
lib/pwned.sh
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -39,15 +39,15 @@ function bashio::pwned.is_safe_password() {
|
|||
# ------------------------------------------------------------------------------
|
||||
function bashio::pwned.occurances() {
|
||||
local password="${1}"
|
||||
local occurances
|
||||
local occurrences
|
||||
|
||||
bashio::log.trace "${FUNCNAME[0]}" "<REDACTED PASSWORD>"
|
||||
|
||||
if ! occurances=$(bashio::pwned "${password}"); then
|
||||
occurances="0"
|
||||
if ! occurrences=$(bashio::pwned "${password}"); then
|
||||
occurrences="0"
|
||||
fi
|
||||
|
||||
echo -n "${occurances}"
|
||||
echo -n "${occurrences}"
|
||||
return "${__BASHIO_EXIT_OK}"
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -34,6 +34,10 @@ function bashio::repositories() {
|
|||
info=$(bashio::cache.get 'repositories.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 "repositories.list" "${info}"
|
||||
fi
|
||||
else
|
||||
|
@ -42,6 +46,10 @@ function bashio::repositories() {
|
|||
else
|
||||
info=$(bashio::api.supervisor GET "/addons" \
|
||||
false ".repositories[] | select(.slug==\"${slug}\")")
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get repositories info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set "repositories.${slug}.info" "${info}"
|
||||
fi
|
||||
fi
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -28,6 +28,10 @@ function bashio::services() {
|
|||
config=$(bashio::cache.get "${cache_key}")
|
||||
else
|
||||
config=$(bashio::api.supervisor GET "/services/${service}" false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get services from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set "${cache_key}" "${config}"
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
|
@ -76,6 +76,10 @@ function bashio::supervisor() {
|
|||
info=$(bashio::cache.get 'supervisor.info')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /supervisor/info false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get supervisor info from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'supervisor.info' "${info}"
|
||||
fi
|
||||
|
||||
|
@ -178,6 +182,26 @@ function bashio::supervisor.timezone() {
|
|||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns or sets the current country of the system.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 Country to set (optional).
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::supervisor.country() {
|
||||
local country=${1:-}
|
||||
|
||||
bashio::log.trace "${FUNCNAME[0]}:" "$@"
|
||||
|
||||
if bashio::var.has_value "${country}"; then
|
||||
channel=$(bashio::var.json country "${country}")
|
||||
bashio::api.supervisor POST /supervisor/options "${country}"
|
||||
bashio::cache.flush_all
|
||||
else
|
||||
bashio::supervisor 'supervisor.info.country' '.country'
|
||||
fi
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Returns the current logging level of the Supervisor.
|
||||
#
|
||||
|
@ -314,6 +338,10 @@ function bashio::supervisor.stats() {
|
|||
info=$(bashio::cache.get 'supervisor.stats')
|
||||
else
|
||||
info=$(bashio::api.supervisor GET /supervisor/stats false)
|
||||
if [ "$?" -ne "${__BASHIO_EXIT_OK}" ]; then
|
||||
bashio::log.error "Failed to get supervisor stats from Supervisor API"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
fi
|
||||
bashio::cache.set 'supervisor.stats' "${info}"
|
||||
fi
|
||||
|
||||
|
|
37
lib/var.sh
37
lib/var.sh
|
@ -1,14 +1,14 @@
|
|||
#!/usr/bin/env bash
|
||||
# ==============================================================================
|
||||
# Home Assistant Community Add-ons: Bashio
|
||||
# Bashio is an bash function library for use with Home Assistant add-ons.
|
||||
# Bashio is a bash function library for use with Home Assistant add-ons.
|
||||
#
|
||||
# It contains a set of commonly used operations and can be used
|
||||
# to be included in add-on scripts to reduce code duplication across add-ons.
|
||||
# ==============================================================================
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Checks if a give value is true.
|
||||
# Checks if a given value is true.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 value
|
||||
|
@ -26,7 +26,7 @@ function bashio::var.true() {
|
|||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Checks if a give value is false.
|
||||
# Checks if a given value is false.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 value
|
||||
|
@ -139,14 +139,17 @@ function bashio::var.json() {
|
|||
|
||||
counter=0;
|
||||
for i in "${data[@]}"; do
|
||||
item="\"$i\""
|
||||
|
||||
separator=","
|
||||
if [ $((++counter%2)) -eq 0 ]; then
|
||||
separator=":";
|
||||
fi
|
||||
|
||||
item="\"$i\""
|
||||
if [[ "${i:0:1}" == "^" ]]; then
|
||||
item="${i:1}"
|
||||
if [[ "${i:0:1}" == "^" ]]; then
|
||||
item="${i:1}"
|
||||
else
|
||||
item=$(bashio::var.json_string "${i}")
|
||||
fi
|
||||
fi
|
||||
|
||||
json="$json$separator$item";
|
||||
|
@ -156,3 +159,23 @@ function bashio::var.json() {
|
|||
return "${__BASHIO_EXIT_OK}"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Escapes a string for use in a JSON object.
|
||||
#
|
||||
# Arguments:
|
||||
# $1 String to escape
|
||||
# ------------------------------------------------------------------------------
|
||||
function bashio::var.json_string() {
|
||||
local string="${1}"
|
||||
local json_string
|
||||
|
||||
# https://stackoverflow.com/a/50380697/12156188
|
||||
if json_string=$(echo -n "${string}" | jq -Rs .); then
|
||||
echo "${json_string}"
|
||||
return "${__BASHIO_EXIT_OK}"
|
||||
fi
|
||||
|
||||
bashio::log.error "Failed to escape string"
|
||||
return "${__BASHIO_EXIT_NOK}"
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue