mirror of
https://github.com/aljazceru/addons.git
synced 2026-01-11 09:14:21 +01:00
* Migrate deconz to ingress/discovery * update chmod * Add discovery * Fix lint * Fix typo * Bump versio 0.91.2 * Fix discovery * Cleanup config * Fix discovery * Fix url * Fix port * Fix script * Support new host config * Use new network feature * add notes * Fix shell * simplify v1 * Cleanup * Fix api port access * Remove waiting * Use more modern version * Fix lint * Add a note to ingress phoscon app * fix format * Fix ingress * Fix ingress * Fix output * Change flow * Fix wait port * Fix config * Add tiemout * Cleanup
72 lines
1.7 KiB
Bash
Executable File
72 lines
1.7 KiB
Bash
Executable File
#!/usr/bin/env bashio
|
|
set -e
|
|
|
|
. /discovery.sh
|
|
|
|
WAIT_PIDS=()
|
|
|
|
# Load config
|
|
DECONZ_DEVICE=$(bashio::config 'device')
|
|
API_PORT=$(bashio::addon.port 80)
|
|
WEBSOCKET_PORT=$(bashio::addon.port 8080)
|
|
INGRESS_PORT=$(bashio::addon.ingress_port)
|
|
INGRESS_INTERFACE=$(bashio::addon.ip_address)
|
|
|
|
# Check if port is available
|
|
if [ -z "${API_PORT}" ] || [ -z "${WEBSOCKET_PORT}" ]; then
|
|
bashio::exit.nok "You need set API/Websocket port!"
|
|
fi
|
|
|
|
# Start Gateway
|
|
bashio::log.info "Start deCONZ gateway"
|
|
deCONZ \
|
|
-platform minimal \
|
|
--auto-connect=1 \
|
|
--dbg-info=1 \
|
|
--dbg-aps=0 \
|
|
--dbg-zcl=0 \
|
|
--dbg-zdp=0 \
|
|
--dbg-otau=0 \
|
|
--http-port=${API_PORT} \
|
|
--ws-port=${WEBSOCKET_PORT} \
|
|
--upnp=0 \
|
|
--dev="${DECONZ_DEVICE}" &
|
|
WAIT_PIDS+=($!)
|
|
|
|
# Start OTA updates for deCONZ
|
|
bashio::log.info "Run deCONZ OTA updater"
|
|
deCONZ-otau-dl.sh &> /dev/null &
|
|
WAIT_PIDS+=($!)
|
|
|
|
# Start OTA updates for IKEA
|
|
bashio::log.info "Run IKEA OTA updater"
|
|
ika-otau-dl.sh &> /dev/null &
|
|
WAIT_PIDS+=($!)
|
|
|
|
# Start Ingress handler
|
|
bashio::log.info "Start Ingress handler"
|
|
|
|
sed -i "s/%%PORT%%/${API_PORT}/g" /etc/nginx/ingress.conf
|
|
sed -i "s/%%INGRESS_PORT%%/${INGRESS_PORT}/g" /etc/nginx/ingress.conf
|
|
sed -i "s/%%INGRESS_INTERFACE%%/${INGRESS_INTERFACE}/g" /etc/nginx/ingress.conf
|
|
nginx -c /etc/nginx/ingress.conf &
|
|
WAIT_PIDS+=($!)
|
|
|
|
# Register stop
|
|
function stop_addon() {
|
|
bashio::log.debug "Kill Processes..."
|
|
kill -15 "${WAIT_PIDS[@]}"
|
|
|
|
wait "${WAIT_PIDS[@]}"
|
|
bashio::log.debug "Done."
|
|
}
|
|
trap "stop_addon" SIGTERM SIGHUP
|
|
|
|
# Start Hass.io discovery
|
|
bashio::log.info "Run Hass.io discovery task"
|
|
hassio_discovery
|
|
|
|
# Wait until all is done
|
|
bashio::log.info "deCONZ is setup and running"
|
|
wait "${WAIT_PIDS[@]}"
|