Skip to content
Snippets Groups Projects
Commit a13166de authored by rubo77's avatar rubo77
Browse files

Add a timeframe under that that the SSID will not change

This adds a configuration MINUTES, so it cannot happen more often than those minutes that the SSID is changed to offline
parent 6a6d4059
No related branches found
No related tags found
No related merge requests found
#!/bin/sh
# at first some Definitions:
MINUTES=1440 # only once every this timeframe the SSID will change to OFFLINE
OFFLINE_PREFIX='FF_OFFLINE_' # use something short to leave space for the nodename (no '~' allowed!)
ONLINE_SSID=$(uci get wireless.client_radio0.ssid -q)
: ${ONLINE_SSID:="FREIFUNK"} # if for whatever reason ONLINE_SSID is NULL
OFFLINE_PREFIX='FF_OFFLINE_' # use something short to leave space for the nodename (no '~' allowed!)
# Generate an Offline SSID with the first and last part of the nodename to allow owner to recognise wich node is down
NODENAME=`uname -n`
......@@ -18,14 +20,22 @@ fi
CHECK=$(batctl gwl -H|grep -v "gateways in range"|wc -l)
if [ $CHECK -eq 0 ] ; then
if [ "$(uci get wireless.client_radio0.ssid)" == "$OFFLINE_SSID" ] ; then echo "$0 - still on $OFFLINE_SSID" ; exit 0 ; fi
echo "$0 change ssid to $OFFLINE_SSID" | logger
uci set wireless.client_radio0.ssid="$OFFLINE_SSID"
sed -i s~^ssid=$ONLINE_SSID~ssid=$OFFLINE_SSID~ /var/run/hostapd-phy0.conf
killall -HUP hostapd
if [ $(expr $(date "+%s") / 60 % $MINUTES) -eq 0 ]; then
if [ "$(uci get wireless.client_radio0.ssid)" == "$OFFLINE_SSID" ]; then
echo "$0 - still on $OFFLINE_SSID"
exit 0
fi
echo "$0 change ssid to $OFFLINE_SSID" | logger
uci set wireless.client_radio0.ssid="$OFFLINE_SSID"
sed -i s~^ssid=$ONLINE_SSID~ssid=$OFFLINE_SSID~ /var/run/hostapd-phy0.conf
killall -HUP hostapd
fi
fi
if [ $CHECK -gt 0 ] ; then
if [ "$(uci get wireless.client_radio0.ssid)" == "$ONLINE_SSID" ] ; then echo "$0 - still on $ONLINE_SSID" ; exit 0 ; fi
if [ "$(uci get wireless.client_radio0.ssid)" == "$ONLINE_SSID" ]; then
echo "$0 - still on $ONLINE_SSID"
exit 0
fi
echo "$0 change ssid to $ONLINE_SSID"| logger
uci set wireless.client_radio0.ssid="$ONLINE_SSID"
sed -i s~^ssid=$OFFLINE_SSID~ssid=$ONLINE_SSID~ /var/run/hostapd-phy0.conf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment