Skip to content
Snippets Groups Projects
Commit 1d6e1ef5 authored by MrMM's avatar MrMM
Browse files

using 'wifi' to commit the ssid does cut the mesh connection, do it via kill -HUP

parent bfdbe820
Branches
Tags
No related merge requests found
#!/bin/sh #!/bin/sh
# At first some Definitions: # At first some Definitions:
...@@ -6,24 +5,24 @@ ...@@ -6,24 +5,24 @@
ONLINE_SSID='Freifunk' ONLINE_SSID='Freifunk'
OFFLINE_PREFIX='FF_OFFLINE_' # Use something short to leave space for the nodename OFFLINE_PREFIX='FF_OFFLINE_' # Use something short to leave space for the nodename
#Is there an active Gateway #Is there an active Gateway?
GATEWAY_TQ=`batctl gwl | grep "^=>" | cut -d" " -f3 | tr -d "()"` GATEWAY_TQ=`batctl gwl | grep "^=>" | cut -d" " -f3 | tr -d "()"`
if [ $GATEWAY_TQ -gt 50 ]; if [ $GATEWAY_TQ -gt 50 ];
then then
echo "Gateway TQ is $GATEWAY_TQ node is online" echo "Gateway TQ is $GATEWAY_TQ node is online"
for RADIO in $(iw dev | grep client | cut -d" " -f2); do for HOSTAPD in $(ls /var/run/hostapd-phy*); do
CURRENT_SSID=`iw dev $RADIO info | grep ssid | cut -d" " -f2` # Is there a better way to fetch the SSID wich is active? CURRENT_SSID=`grep '^ssid=' $HOSTAPD | cut -d"=" -f2`
if [ $CURRENT_SSID == $ONLINE_SSID ] if [ $CURRENT_SSID == $ONLINE_SSID ]
then then
echo "SSID $CURRENT_SSID is correct, noting to do" echo "SSID $CURRENT_SSID is correct, noting to do"
HUP_NEEDED=0
else else
echo "SSID is $CURRENT_SSID, change to $ONLINE_SSID" echo "SSID is $CURRENT_SSID, change to $ONLINE_SSID"
NUM=`echo $RADIO | tail -c 2` sed -i s/^ssid=.*/ssid=$ONLINE_SSID/ $HOSTAPD
`uci set wireless.client_radio$NUM.ssid=$ONLINE_SSID` HUP_NEEDED=1 # HUP here would be to early for dualband devices
wifi
fi fi
done done
else else
echo "Gateway TQ is $GATEWAY_TQ node is considered offline" echo "Gateway TQ is $GATEWAY_TQ node is considered offline"
NODENAME=`uname -n` NODENAME=`uname -n`
...@@ -31,20 +30,25 @@ else ...@@ -31,20 +30,25 @@ else
HALF=$(( (28 - ${#OFFLINE_PREFIX} ) / 2 )) HALF=$(( (28 - ${#OFFLINE_PREFIX} ) / 2 ))
SKIP=$(( ${#NODENAME} - $HALF )) SKIP=$(( ${#NODENAME} - $HALF ))
OFFLINE_SSID=$OFFLINE_PREFIX${NODENAME:0:$HALF}...${NODENAME:$SKIP:${#NODENAME}} # use the first and last part of the nodename for nodes with long name OFFLINE_SSID=$OFFLINE_PREFIX${NODENAME:0:$HALF}...${NODENAME:$SKIP:${#NODENAME}} # use the first and last part of the nodename for nodes with long name
else else
OFFLINE_SSID=`$OFFLINE_PREFIX$NODENAME` OFFLINE_SSID=`$OFFLINE_PREFIX$NODENAME`
fi fi
for RADIO in $(iw dev | grep client | cut -d" " -f2); do for HOSTAPD in $(ls /var/run/hostapd-phy*); do
CURRENT_SSID=`iw dev $RADIO info | grep ssid | cut -d" " -f2` CURRENT_SSID=`grep '^ssid=' $HOSTAPD | cut -d"=" -f2`
if [ $CURRENT_SSID == $OFFLINE_SSID ] if [ $CURRENT_SSID == $OFFLINE_SSID ]
then then
echo "SSID $CURRENT_SSID is correct, noting to do" echo "SSID $CURRENT_SSID is correct, noting to do"
HUP_NEEDED=0
else else
echo "SSID is $CURRENT_SSID, change to $OFFLINE_SSID" echo "SSID is $CURRENT_SSID, change to $OFFLINE_SSID"
NUM=`echo $RADIO | tail -c 2` sed -i "s/^ssid=.*/ssid=$OFFLINE_SSID/" $HOSTAPD
`uci set wireless.client_radio$NUM.ssid="$OFFLINE_SSID"` HUP_NEEDED=1 # HUP here would be to early for dualband devices
wifi
fi fi
done done
fi fi
if [ $HUP_NEEDED == 1 ]; then
killall -HUP hostapd # Send HUP to all hostapd um die neue SSID zu laden
HUP_NEEDED=0
echo "HUP!"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment