Standalone version

This commit is contained in:
Devmel Apps
2025-10-06 10:49:59 +02:00
parent 827a1fcdb8
commit c5f99dae9b
8 changed files with 117 additions and 40 deletions
+44 -12
View File
@@ -10,18 +10,50 @@ case "$arch" in \
i386) arch='x86' ;; \
esac;
echo "AirSendWebService arch: ${arch}"
hname="$(hostname -i)"
echo "internal_url: http://${hname}:33863/"
if [ -n "${SUPERVISOR_TOKEN:-}" ]
then
echo ${SUPERVISOR_TOKEN} > hass_api.token
echo $(bashio::config 'auto_include') > auto_include.cfg
else
echo "Not running on Home Assistant machine..."
fi
# Start AirSendWebService
ulimit -n 4096
./bin/unix/${arch}/AirSendWebService 99399
php -S 127.0.0.1:80 callback.php
sleep infinity
CALLBACK_PID=
if [ -n "${SUPERVISOR_TOKEN:-}" ]
then
hname="$(hostname -i)"
echo "internal_url: http://${hname}:33863/"
echo $(bashio::config 'auto_include') > auto_include.cfg
# Start hass callback service
php -S 127.0.0.1:80 hass_cb.php & CALLBACK_PID=$!
elif [ -n "${HASS_HOST:-}" ] && [ -n "${HASS_TOKEN:-}" ]
then
echo "internal_url: http://{YOUR_DOCKER_MACHINE_IP}:33863/"
# Start hass callback service
php -S 127.0.0.1:80 hass_cb.php & CALLBACK_PID=$!
else
echo "Running the AirSendWebService only..."
fi
# Give services time to start
sleep 5
# Monitor services
ASW_PID=$(cat AirSendWebService.lock)
while true; do
sleep 30
# Check if AirSendWebService is still running
if ! kill -0 "$ASW_PID" 2>/dev/null; then
echo "ERROR: AirSendWebService (PID: $ASW_PID) died..." >&2
break
fi
# Check if Callback service exists and if is still running
if [[ -n "$CALLBACK_PID" && "$CALLBACK_PID" =~ ^[0-9]+$ ]] && ! kill -0 "$CALLBACK_PID" 2>/dev/null; then
echo "ERROR: Callback Service (PID: $CALLBACK_PID) died..." >&2
break
fi
done
kill $ASW_PID 2>/dev/null || true
kill $CALLBACK_PID 2>/dev/null || true
echo "exiting..."
exit 1