I could really use help with my addon/run script. Thanks
I want option 1 to run bluetooth.sh or else option 2 runs Ethernet.sh depending on the corresponding selection.
I either end up with unbound or bad substitution errors if I move the " " ( ) { } around
I have looked at bashio config.sh and bashio jq.sh I can’t say I follow much there.
I have a selector option on my addon user config
- Bluetooth
- Ethernet
That is pushed to options.json as
"Connection_Type": "Bluetooth"
or
"Connection_Type": "Ethernet"
When my run script starts… I would like to do
##CONFIG_PATH=/data/options.json <---- not needed
value=$(bashio::config "${"Connection_Type":=}")
If bashio::config.equals Bluetooth; then
bashio::log.info Generating Bluetooth Config
exec /usr/bin/bluetooth.sh
fi
else
If bashio::config Ethernet; then
bashio::log.info Generating Ethernet Config
exec /usr/bin/ethernet.sh
fi
fi
This is the example I was trying to follow. I am not really sure how to fill it out however. I am also not sure how to pair it up to run the second Ethernet part. Basically I am not sure of the syntax and which keys to manually change vs pull in from options. Do I need to use bashio::jq
function bashio::config.equals() {
local key=${1}
local equals=${2}
local value
bashio::log.trace "${FUNCNAME[0]}:" "$@"
value=$(bashio::config "${key}")
if ! bashio::var.equals "${value}" "${equals}"; then
return "${__BASHIO_EXIT_NOK}"
fi
return "${__BASHIO_EXIT_OK}"
}
************************************************************************************************
Whole block here
#!/usr/bin/with-contenv bashio
# ==============================================================================
# Start the service
# s6-overlay docs: https://github.com/just-containers/s6-overlay
# ==============================================================================
set -x
# --- GENERATE CONFIG --
echo "PWD is current directory $(pwd)"
cd /
echo "PWD is current directory $(pwd)"
function bashio::config.equals() {
local key=${1}
local equals=${2}
local value
bashio::log.trace "${config.equals[0]}:" "$@"
value=$(bashio::config "${Connection_Type:=}")
if ! bashio::var.equals "${value}" "${Bluetooth}"; then
bashio::log.info
bashio::log.info "[Bluetooth being setup]"
bashio::log.info
/usr/bin/my_addon/genBluetoothConfig.sh
return "${__BASHIO_EXIT_NOK}"
fi
# return "${__BASHIO_EXIT_OK}"
value=%(bashio::config "${Connection_Type:=}"); then
if ! bashio::var.equals "${value}" "${Ethernet}"; then
bashio::log.error
bashio::log.error "Ethernet being setup"
bashio::log.error
/usr/bin/my_addon/genEthernetConfig.sh
return "${__BASHIO_EXIT_NOK}"
fi
return "${__BASHIO_EXIT_OK}"
}
# ---- Print Host BT Controller and sys info
bashio::log.info
bashio::log.info echo "$(uname -smrv)"
bashio::log.info
## Get the 'message' key from the user config options.
message=$(echo "[Host Bluetooth MAC Address] $(bluetoothctl list)")
## Print the message the user supplied, defaults to "Hello World..."
bashio::log.info
bashio::log.info "${message:="Hello World..."}"
bashio::log.info
# ---- RUN ----
echo 'Starting daemon'
# cron
bashio::log.info echo '$('Starting cron in foreground')'
exec /usr/sbin/crond -f