ntfy_scripts/openwrt_wifi_up.sh

30 lines
860 B
Bash
Raw Permalink Normal View History

2024-03-19 21:35:17 +01:00
#!/bin/bash
## dependencies: curl
### This script checks if the 2 wifi interfaces are UP and ENABLED
2024-04-16 12:37:56 +02:00
HOST="$(cat /etc/config/system | grep "hostname" | awk '{print $3}')"
2024-04-16 14:42:39 +02:00
topicurl=https://NTFY_SERVER_IP/hangar_servers
2024-03-19 21:35:17 +01:00
RADIO_STATUS=$(wifi status | grep -c "\"up\": true")
DEVICE_STATUS=$(wifi status | grep -c "\"disabled\": false")
2024-04-29 15:47:42 +02:00
if [ ${RADIO_STATUS} -lt 2 ] || [ ${DEVICE_STATUS} -lt 2 ] ; then
2024-03-19 21:35:17 +01:00
curl -k --retry 3 \
-d "wifi down in $HOST" \
-H "Title: Wifi down in $HOST" \
-H "Priority: high" \
-H "Tags: warning,boar" \
2024-04-16 13:03:00 +02:00
$topicurl ;
# automatically enable wifi on both devices, store and restart wifi devices
uci set wireless.radio0.disabled='0' ;
uci set wireless.radio1.disabled='0' ;
uci commit wireless ;
wifi reload
2024-03-19 21:35:17 +01:00
fi