From 7878a5026a86ecbe1d3296aeb86ef65ffb7adfb5 Mon Sep 17 00:00:00 2001
From: MrMM <mm@freifunk-aachen.de>
Date: Mon, 5 Oct 2015 16:44:43 +0200
Subject: [PATCH] Use the frist and the last part of the nodename for the
 offline ssid, otherwise a long prefix in the nodename will be a problem

---
 files/lib/gluon/ssid-changer/ssid-changer.sh | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/files/lib/gluon/ssid-changer/ssid-changer.sh b/files/lib/gluon/ssid-changer/ssid-changer.sh
index 2530f0c..19ee9e9 100755
--- a/files/lib/gluon/ssid-changer/ssid-changer.sh
+++ b/files/lib/gluon/ssid-changer/ssid-changer.sh
@@ -1,7 +1,6 @@
 #!/bin/sh
 
 
-
 #Is there an active Gateway
 GATEWAY_TQ=`batctl gwl | grep "^=>" | cut -d" " -f3 | tr -d "()"`
 if [ $GATEWAY_TQ > 50 ];
@@ -9,7 +8,7 @@ then
 	echo "Gateway TQ is $GATEWAY_TQ node is online"
 	for RADIO in $(iw dev | grep client | cut -d" " -f2); do
 		CURRENT_SSID=`iw dev $RADIO info | grep ssid | cut -d" " -f2`
-		# Use Freifunk for now, get it from /lib/gluon/site.conf in futre version
+		# Use Freifunk for now, get it from /lib/gluon/site.conf in future version
 		if [ $CURRENT_SSID == 'Freifunk' ]
 		then
 			echo "SSID $CURRENT_SSID is correct, noting to do"
@@ -23,7 +22,9 @@ then
 else
 	echo "Gateway TQ is $GATEWAY_TQ node is considered offline"
 	NODENAME=`uname -n`
-	OFFLINE_SSID=`echo "Freifunk_OFFLINE_$NODENAME" | cut -b -30`
+	#There is a limit auf 32 charakters for the ssid + 'FF_OFFLINE_' leves us 21 maximum SSID length
+	if [ ${#NODENAME} > 20 ] ; then
+			OFFLINE_SSID=`echo "FF_OFFLINE_${STRING:0:9}...${STRING:(-9)}"` # use the first and last part of the nodename for nodes with long prefix
 	for RADIO in $(iw dev | grep client | cut -d" " -f2); do
 		CURRENT_SSID=`iw dev $RADIO info | grep ssid | cut -d" " -f2`
 		if [ $CURRENT_SSID == $OFFLINE_SSID ]
-- 
GitLab