test
This commit is contained in:
47
sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-mqtt/run
Normal file
47
sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-mqtt/run
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/command/with-contenv bashio
|
||||
# shellcheck shell=bash
|
||||
# ==============================================================================
|
||||
# Prepare the MQTT config for running
|
||||
# ==============================================================================
|
||||
readonly CONF="/root/.config/mosquitto_pub"
|
||||
readonly CONF_SUB="/root/.config/mosquitto_sub"
|
||||
declare host
|
||||
declare username
|
||||
declare password
|
||||
declare port
|
||||
declare topic
|
||||
|
||||
if bashio::config.true "mqtt_enable"; then
|
||||
|
||||
|
||||
topic=$(bashio::config 'mqtt_topic' "sambanas")
|
||||
host=$(bashio::config 'mqtt_host' "$(bashio::services 'mqtt' 'host')")
|
||||
username=$(bashio::config 'mqtt_username' "$(bashio::services 'mqtt' 'username')")
|
||||
password=$(bashio::config 'mqtt_password' "$(bashio::services 'mqtt' 'password')")
|
||||
port=$(bashio::config 'mqtt_port' "$(bashio::services 'mqtt' 'port')")
|
||||
|
||||
topic=$(bashio::config 'mqtt_topic')
|
||||
|
||||
#bashio::log.info "Init MQTT config ${host}:${port} ${username}:${password}"
|
||||
|
||||
[ -z "$host" ] && bashio::log.warning "No MQTT Server found. Homeassistant integration can't work!"
|
||||
|
||||
if bashio::var.has_value "host" && ! bashio::config.false "mqtt_enable" && [ -n "$host" ]; then
|
||||
{
|
||||
echo "-h ${host}"
|
||||
echo "--username ${username}"
|
||||
echo "--pw ${password}"
|
||||
echo "--port ${port}"
|
||||
} >"${CONF}"
|
||||
{
|
||||
echo "-h ${host}"
|
||||
echo "--username ${username}"
|
||||
echo "--pw ${password}"
|
||||
echo "--port ${port}"
|
||||
} >"${CONF_SUB}"
|
||||
fi
|
||||
else
|
||||
|
||||
bashio::log.info "MQTT support not enabled in config"
|
||||
|
||||
fi
|
1
sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-mqtt/type
Normal file
1
sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-mqtt/type
Normal file
@@ -0,0 +1 @@
|
||||
oneshot
|
1
sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-mqtt/up
Normal file
1
sambanas/rootfs/etc/s6-overlay/s6-rc.d/init-mqtt/up
Normal file
@@ -0,0 +1 @@
|
||||
/etc/s6-overlay/s6-rc.d/init-mqtt/run
|
Reference in New Issue
Block a user