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

Set the online and offline SSID at the top of the script

parent 7878a502
No related branches found
No related tags found
No related merge requests found
#!/bin/sh #!/bin/sh
# At first some Definitions:
ONLINE_SSID='Freifunk'
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 > 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 RADIO in $(iw dev | grep client | cut -d" " -f2); do
CURRENT_SSID=`iw dev $RADIO info | grep ssid | cut -d" " -f2` CURRENT_SSID=`iw dev $RADIO info | grep ssid | cut -d" " -f2` # Is there a better way to fetch the SSID wich is active?
# Use Freifunk for now, get it from /lib/gluon/site.conf in future version if [ $CURRENT_SSID == $ONLINE_SSID ]
if [ $CURRENT_SSID == 'Freifunk' ]
then then
echo "SSID $CURRENT_SSID is correct, noting to do" echo "SSID $CURRENT_SSID is correct, noting to do"
else else
echo "SSID is $CURRENT_SSID, change to $ONLINE_SSID"
NUM=`echo $RADIO | tail -c 2` NUM=`echo $RADIO | tail -c 2`
`uci set wireless.client_radio$NUM.ssid="Freifunk"` `uci set wireless.client_radio$NUM.ssid=$ONLINE_SSID`
wifi wifi
fi fi
done done
...@@ -22,15 +27,20 @@ then ...@@ -22,15 +27,20 @@ then
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`
#There is a limit auf 32 charakters for the ssid + 'FF_OFFLINE_' leves us 21 maximum SSID length if [ ${#NODENAME} > 30-${#OFFLINE_PREFIX} ] ; then #32 would be possible as well
if [ ${#NODENAME} > 20 ] ; then HALF=$(( (28 - ${#OFFLINE_PREFIX} ) / 2 ))
OFFLINE_SSID=`echo "FF_OFFLINE_${STRING:0:9}...${STRING:(-9)}"` # use the first and last part of the nodename for nodes with long prefix 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
else
OFFLINE_SSID=`$OFFLINE_PREFIX$NODENAME`
fi
for RADIO in $(iw dev | grep client | cut -d" " -f2); do for RADIO in $(iw dev | grep client | cut -d" " -f2); do
CURRENT_SSID=`iw dev $RADIO info | grep ssid | cut -d" " -f2` CURRENT_SSID=`iw dev $RADIO info | grep ssid | 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"
else else
echo "SSID is $CURRENT_SSID, change to $OFFLINE_SSID"
NUM=`echo $RADIO | tail -c 2` NUM=`echo $RADIO | tail -c 2`
`uci set wireless.client_radio$NUM.ssid="$OFFLINE_SSID"` `uci set wireless.client_radio$NUM.ssid="$OFFLINE_SSID"`
wifi wifi
...@@ -38,4 +48,3 @@ else ...@@ -38,4 +48,3 @@ else
done done
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment