mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-05-25 18:21:51 +02:00
allow mqtt autodiscover
This commit is contained in:
25
gazpar2mqtt/rootfs/scripts/91-run_mqtt_autodiscover.sh
Normal file
25
gazpar2mqtt/rootfs/scripts/91-run_mqtt_autodiscover.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/env bashio
|
||||||
|
|
||||||
|
#####################
|
||||||
|
# Autodiscover mqtt #
|
||||||
|
#####################
|
||||||
|
|
||||||
|
if bashio::config.true 'mqtt_autodiscover'; then
|
||||||
|
bashio::log.info "mqtt_autodiscover is defined in options, attemption autodiscovery..."
|
||||||
|
# Check if available
|
||||||
|
[ ! bashio::services.available "mqtt" ] && bashio::exit.nok "No internal MQTT service found. Please install Mosquitto broker"
|
||||||
|
# Get variables
|
||||||
|
bashio::log.info "... MQTT service found, fetching server detail ..."
|
||||||
|
export MQTT_HOST=$(bashio::services mqtt "host")
|
||||||
|
export MQTT_PORT=$(bashio::services mqtt "port")
|
||||||
|
export MQTT_SSL=$(bashio::services mqtt "ssl")
|
||||||
|
export MQTT_USERNAME=$(bashio::services mqtt "username")
|
||||||
|
export MQTT_PASSWORD=$(bashio::services mqtt "password")
|
||||||
|
# Export variables
|
||||||
|
for variables in "MQTT_HOST=$MQTT_HOST" "MQTT_PORT=$MQTT_PORT" "MQTT_SSL=$MQTT_SSL" "MQTT_USERNAME=$MQTT_USERNAME" "MQTT_PASSWORD=$MQTT_PASSWORD"; do
|
||||||
|
sed -i "1a export $variables" /etc/services.d/*/*run*
|
||||||
|
sed -i "1a export $variables" /scripts/*run*
|
||||||
|
done
|
||||||
|
# Log
|
||||||
|
bashio::log.info "Received user: '$MQTT_USERNAME' for MQTT at '$MQTT_HOST:$MQTT_PORT'!"
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user