ntfy_scripts/openwrt_wifi_up.sh

30 lines
858 B
Bash
Executable File

#!/bin/bash
## dependencies: curl
### This script checks if the 2 wifi interfaces are UP and ENABLED
HOST="$(cat /etc/config/system | grep "hostname" | awk '{print $3}')"
topicurl=https://NTFY_SERVER_IP/hangar_servers
RADIO_STATUS=$(wifi status | grep -c "\"up\": true")
DEVICE_STATUS=$(wifi status | grep -c "\"disabled\": false")
if [ ${RADIO_STATUS} != 2 ] || [ ${DEVICE_STATUS} != 2 ] ; then
curl -k --retry 3 \
-d "wifi down in $HOST" \
-H "Title: Wifi down in $HOST" \
-H "Priority: high" \
-H "Tags: warning,boar" \
$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
fi