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

fixed indentins and all comments in single lines

parent 995190da
No related branches found
No related tags found
No related merge requests found
...@@ -23,14 +23,19 @@ SETTINGS_SUFFIX="$(uci get ssid-changer.settings.suffix -q)" ...@@ -23,14 +23,19 @@ SETTINGS_SUFFIX="$(uci get ssid-changer.settings.suffix -q)"
if [ $SETTINGS_SUFFIX = 'nodename' ]; then if [ $SETTINGS_SUFFIX = 'nodename' ]; then
SUFFIX="$(uname -n)" SUFFIX="$(uname -n)"
if [ ${#SUFFIX} -gt $((30 - ${#PREFIX})) ]; then # 32 would be possible as well # 32 would be possible as well
HALF=$(( (28 - ${#PREFIX} ) / 2 )) # calculate the length of the first part of the node identifier in the offline-ssid if [ ${#SUFFIX} -gt $((30 - ${#PREFIX})) ]; then
SKIP=$(( ${#SUFFIX} - $HALF )) # jump to this charakter for the last part of the name # calculate the length of the first part of the node identifier in the offline-ssid
SUFFIX=${SUFFIX:0:$HALF}...${SUFFIX:$SKIP:${#SUFFIX}} # use the first and last part of the nodename for nodes with long name HALF=$(( (28 - ${#PREFIX} ) / 2 ))
# jump to this charakter for the last part of the name
SKIP=$(( ${#SUFFIX} - $HALF ))
# use the first and last part of the nodename for nodes with long name
SUFFIX=${SUFFIX:0:$HALF}...${SUFFIX:$SKIP:${#SUFFIX}}
fi fi
elif [ $SETTINGS_SUFFIX = 'mac' ]; then elif [ $SETTINGS_SUFFIX = 'mac' ]; then
SUFFIX="$(uci get network.bat0.macaddr -q)" SUFFIX="$(uci get network.bat0.macaddr -q)"
else # 'none' else
# 'none'
SUFFIX='' SUFFIX=''
fi fi
...@@ -39,16 +44,17 @@ OFFLINE_SSID="$PREFIX$SUFFIX" ...@@ -39,16 +44,17 @@ OFFLINE_SSID="$PREFIX$SUFFIX"
# TODO: ffac tq limits has to be implemented here if enabled # TODO: ffac tq limits has to be implemented here if enabled
ONLINE_SSID="$(uci get wireless.client_radio0.ssid -q)" ONLINE_SSID="$(uci get wireless.client_radio0.ssid -q)"
: ${ONLINE_SSID:="FREIFUNK"} # if for whatever reason ONLINE_SSID is NULL # if for whatever reason ONLINE_SSID is NULL
: ${ONLINE_SSID:="FREIFUNK"}
CHECK="$(batctl gwl -H|grep -v "gateways in range"|wc -l)" CHECK="$(batctl gwl -H|grep -v "gateways in range"|wc -l)"
HUP_NEEDED=0 HUP_NEEDED=0
if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
echo "node is online" echo "node is online"
for HOSTAPD in $(ls /var/run/hostapd-phy*); do # check status for all physical devices # check status for all physical devices
for HOSTAPD in $(ls /var/run/hostapd-phy*); do
CURRENT_SSID="$(grep "^ssid=$ONLINE_SSID" $HOSTAPD | cut -d"=" -f2)" CURRENT_SSID="$(grep "^ssid=$ONLINE_SSID" $HOSTAPD | cut -d"=" -f2)"
if [ "$CURRENT_SSID" = "$ONLINE_SSID" ] if [ "$CURRENT_SSID" = "$ONLINE_SSID" ]; then
then
echo "SSID $CURRENT_SSID is correct, nothing to do" echo "SSID $CURRENT_SSID is correct, nothing to do"
break break
fi fi
...@@ -56,7 +62,8 @@ if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then ...@@ -56,7 +62,8 @@ if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
if [ "$CURRENT_SSID" = "$OFFLINE_SSID" ]; then if [ "$CURRENT_SSID" = "$OFFLINE_SSID" ]; then
logger -s -t "gluon-ssid-changer" -p 5 "SSID is $CURRENT_SSID, change to $ONLINE_SSID" logger -s -t "gluon-ssid-changer" -p 5 "SSID is $CURRENT_SSID, change to $ONLINE_SSID"
sed -i "s~^ssid=$CURRENT_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 # HUP here would be to early for dualband devices
HUP_NEEDED=1
else else
logger -s -t "gluon-ssid-changer" -p 5 "could not set to online state: did neither find SSID '$ONLINE_SSID' nor '$OFFLINE_SSID'. Please reboot" logger -s -t "gluon-ssid-changer" -p 5 "could not set to online state: did neither find SSID '$ONLINE_SSID' nor '$OFFLINE_SSID'. Please reboot"
fi fi
...@@ -84,7 +91,8 @@ elif [ "$CHECK" -eq 0 ]; then ...@@ -84,7 +91,8 @@ elif [ "$CHECK" -eq 0 ]; then
fi fi
if [ $HUP_NEEDED = 1 ]; then if [ $HUP_NEEDED = 1 ]; then
killall -HUP hostapd # send HUP to all hostapd to load the new SSID # send HUP to all hostapd to load the new SSID
killall -HUP hostapd
HUP_NEEDED=0 HUP_NEEDED=0
echo "HUP!" echo "HUP!"
fi fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment