From 1c0bd14e516f65dd2b327380e5f4d3b2c2aae5fb Mon Sep 17 00:00:00 2001 From: MrMM <mm@freifunk-aachen.de> Date: Tue, 6 Oct 2015 10:38:14 +0200 Subject: [PATCH] Only change SSID if the exakt offline or onlie ssid is found --- files/lib/gluon/ssid-changer/ssid-changer.sh | 28 +++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/files/lib/gluon/ssid-changer/ssid-changer.sh b/files/lib/gluon/ssid-changer/ssid-changer.sh index 319c846..8b63fbd 100755 --- a/files/lib/gluon/ssid-changer/ssid-changer.sh +++ b/files/lib/gluon/ssid-changer/ssid-changer.sh @@ -21,31 +21,41 @@ if [ $GATEWAY_TQ -gt 50 ]; then echo "Gateway TQ is $GATEWAY_TQ node is online" for HOSTAPD in $(ls /var/run/hostapd-phy*); do - CURRENT_SSID=`grep '^ssid=' $HOSTAPD | cut -d"=" -f2` + CURRENT_SSID=`grep "^ssid=$ONLINE_SSID" $HOSTAPD | cut -d"=" -f2` if [ $CURRENT_SSID == $ONLINE_SSID ] then echo "SSID $CURRENT_SSID is correct, noting to do" HUP_NEEDED=0 - else + fi + CURRENT_SSID=`grep "^ssid=$OFFLINE_SSID" $HOSTAPD | cut -d"=" -f2` + if [ $CURRENT_SSID == $OFFLINE_SSID ] + then echo "SSID is $CURRENT_SSID, change to $ONLINE_SSID" - sed -i s/^ssid=.*/ssid=$ONLINE_SSID/ $HOSTAPD + sed -i s/^ssid=$CURRENT_SSID/ssid=$ONLINE_SSID/ $HOSTAPD HUP_NEEDED=1 # HUP here would be to early for dualband devices + else + echo "There is something wrong, did not find SSID $ONLINE_SSID or $OFFLINE_SSID" fi done else echo "Gateway TQ is $GATEWAY_TQ node is considered offline" for HOSTAPD in $(ls /var/run/hostapd-phy*); do - CURRENT_SSID=`grep '^ssid=' $HOSTAPD | cut -d"=" -f2` + CURRENT_SSID=`grep "^ssid=$OFFLINE_SSID" $HOSTAPD | cut -d"=" -f2` if [ $CURRENT_SSID == $OFFLINE_SSID ] then echo "SSID $CURRENT_SSID is correct, noting to do" HUP_NEEDED=0 - else - echo "SSID is $CURRENT_SSID, change to $OFFLINE_SSID" - sed -i "s/^ssid=.*/ssid=$OFFLINE_SSID/" $HOSTAPD - HUP_NEEDED=1 # HUP here would be to early for dualband devices - fi + fi + CURRENT_SSID=`grep "^ssid=$ONLINE_SSID" $HOSTAPD | cut -d"=" -f2` + if [ $CURRENT_SSID == $ONLINE_SSID ] + then + echo "SSID is $CURRENT_SSID, change to $OFFLINE_SSID" + sed -i s/^ssid=$ONLINE_SSID/ssid=$OFFLINE_SSID/ $HOSTAPD + HUP_NEEDED=1 # HUP here would be to early for dualband devices + else + echo "There is something wrong, did not find SSID $ONLINE_SSID or $OFFLINE_SSID" + fi done fi -- GitLab