Skip to content

Commit

Permalink
ffac-ssid-changer: strip trailing whitespaces (#45)
Browse files Browse the repository at this point in the history
Co-authored-by: Grische <10663446-grische@users.noreply.gitlab.com>
  • Loading branch information
grische and grische authored Nov 18, 2023
1 parent 6eeaa2e commit 601cb60
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions ffac-ssid-changer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Adapt and add this block to your `site.conf`:

ssid_changer = {
enabled = true,
switch_timeframe = 30, -- only once every timeframe (in minutes) the SSID will change to the Offline-SSID
switch_timeframe = 30, -- only once every timeframe (in minutes) the SSID will change to the Offline-SSID
-- set to 1440 to change once a day
-- set to 1 minute to change every time the router gets offline
first = 5, -- the first few minutes directly after reboot within which an Offline-SSID may be
Expand Down Expand Up @@ -102,4 +102,4 @@ Some SSID changers are in use in:
- Freifunk Vogtland
- [Freifunk Berlin](https://github.com/freifunk-berlin/falter-packages/tree/master/packages/falter-berlin-ssid-changer)
- [Freifunk Stuttgart](https://gitlab.freifunk-stuttgart.de/firmware/gluon-packages.git)
- [Freifunk Altdorf](https://github.com/tecff/gluon-packages/tree/main/tecff-ssid-changer)
- [Freifunk Altdorf](https://github.com/tecff/gluon-packages/tree/main/tecff-ssid-changer)
14 changes: 7 additions & 7 deletions ffac-ssid-changer/shsrc/ssid-changer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ PREFIX="$(uci -q get ssid-changer.settings.prefix)"
PREFIX_OWE="$(uci -q get ssid-changer.settings.prefix_owe)"
: ${PREFIX_OWE:='FF_Off_OWE'}

if [ "$(uci -q get ssid-changer.settings.enabled)" = '0' ]; then
if [ "$(uci -q get ssid-changer.settings.enabled)" = '0' ]; then
DISABLED='1'
else
DISABLED='0'
Expand Down Expand Up @@ -122,7 +122,7 @@ if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
LOOP=1
# check status for all physical devices
for HOSTAPD in $(ls /var/run/hostapd-phy*); do
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
LOOP=$((LOOP+1))
CURRENT_SSID="$(grep "^ssid=$ONLINE_SSID" $HOSTAPD | cut -d"=" -f2)"
if [ "$CURRENT_SSID" = "$ONLINE_SSID" ]; then
Expand Down Expand Up @@ -156,17 +156,17 @@ elif [ "$CHECK" -eq 0 ]; then
echo "node is considered offline"
if [ $UP -lt $FIRST ] || [ $M -eq 0 ]; then
# set SSID offline, only if uptime is less than FIRST or exactly a multiplicative of switch_timeframe
if [ $UP -lt $FIRST ]; then
if [ $UP -lt $FIRST ]; then
T=$FIRST
else
T=$MINUTES
fi
#echo minute $M, check if $OFF_COUNT is more than half of $T
#echo minute $M, check if $OFF_COUNT is more than half of $T
if [ $OFF_COUNT -ge $(($T / 2)) ]; then
# node was offline more times than half of switch_timeframe (or than $FIRST)
LOOP=1
for HOSTAPD in $(ls /var/run/hostapd-phy*); do
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
ONLINE_SSID="$(echo $ONLINE_SSIDs | awk -F '~' -v l=$((LOOP*2)) '{print $l}')"
LOOP=$((LOOP+1))
CURRENT_SSID="$(grep "^ssid=$OFFLINE_SSID" $HOSTAPD | cut -d"=" -f2)"
if [ "$CURRENT_SSID" = "$OFFLINE_SSID" ]; then
Expand Down Expand Up @@ -203,8 +203,8 @@ fi
if [ $HUP_NEEDED = 1 ]; then
# send HUP to all hostapd to load the new SSID
killall -HUP hostapd
## check for nonmachting hotapd-pidfiles
if [ -f /lib/gluon/eulenfunk-hotfix/check_hostapd.sh ] ; then
## check for nonmachting hotapd-pidfiles
if [ -f /lib/gluon/eulenfunk-hotfix/check_hostapd.sh ] ; then
sleep 2 # settle down
ps|grep hostapd|grep .pid|xargs -n 10 /lib/gluon/eulenfunk-hotfix/check_hostapd.sh
fi
Expand Down

0 comments on commit 601cb60

Please sign in to comment.