Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Gluon SSID Changer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
firmware
Gluon SSID Changer
Commits
995190da
Commit
995190da
authored
7 years ago
by
rubo77
Browse files
Options
Downloads
Patches
Plain Diff
Read all options from config and add option to use mac as offline suffix instead of nodename
parent
9cd44be8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/lib/gluon/ssid-changer/ssid-changer.sh
+35
-18
35 additions, 18 deletions
files/lib/gluon/ssid-changer/ssid-changer.sh
with
35 additions
and
18 deletions
files/lib/gluon/ssid-changer/ssid-changer.sh
+
35
−
18
View file @
995190da
#!/bin/sh
MINUTES
=
1440
# only once every timeframe the SSID will change to OFFLINE (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 always may be activated
OFFLINE_PREFIX
=
'FF_OFFLINE_'
# use something short to leave space for the nodename (no '~' allowed!)
# only once every timeframe the SSID will change to OFFLINE (set to 1 minute to change every time the router gets offline)
MINUTES
=
"
$(
uci get ssid-changer.settings.switch_timeframe
-q
)
"
# the first few minutes directly after reboot within which an Offline-SSID always may be activated
:
${
MINUTES
:
=1
}
FIRST
=
"
$(
uci get ssid-changer.settings.first
-q
)
"
# use something short to leave space for the nodename (no '~' allowed!)
:
${
FIRST
:
=5
}
PREFIX
=
"
$(
uci get ssid-changer.settings.prefix
-q
)
"
# generate the ssid with either 'nodename', 'mac' or to use only the prefix: 'none'
:
${
PREFIX
:
=
'FF_OFFLINE_'
}
if
[
"
$(
uci get ssid-changer.settings.enabled
-q
)
"
=
'0'
]
;
then
DISABLED
=
'1'
...
...
@@ -10,20 +19,28 @@ else
DISABLED
=
'0'
fi
ONLINE_SSID
=
"
$(
uci get wireless.client_radio0.ssid
-q
)
"
:
${
ONLINE_SSID
:
=
"FREIFUNK"
}
# if for whatever reason ONLINE_SSID is NULL
SETTINGS_SUFFIX
=
"
$(
uci get ssid-changer.settings.suffix
-q
)
"
# generate an Offline SSID with the first and last part of the nodename to allow owner to recognise wich node is down
NODENAME
=
"
$(
uname
-n
)
"
if
[
${#
NODENAME
}
-gt
$((
30
-
${#
OFFLINE_PREFIX
}))
]
;
then
# 32 would be possible as well
HALF
=
$((
(
28
-
${#
OFFLINE_PREFIX
}
)
/
2
))
# calculate the length of the first part of the node identifier in the offline-ssid
SKIP
=
$((
${#
NODENAME
}
-
$HALF
))
# jump to this charakter for the last part of the 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
OFFLINE_SSID
=
"
$OFFLINE_PREFIX$NODENAME
"
# great! we are able to use the full nodename in the offline ssid
if
[
$SETTINGS_SUFFIX
=
'nodename'
]
;
then
SUFFIX
=
"
$(
uname
-n
)
"
if
[
${#
SUFFIX
}
-gt
$((
30
-
${#
PREFIX
}))
]
;
then
# 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
SKIP
=
$((
${#
SUFFIX
}
-
$HALF
))
# jump to this charakter for the last part of the name
SUFFIX
=
${
SUFFIX
:0:
$HALF
}
...
${
SUFFIX
:
$SKIP
:
${#
SUFFIX
}}
# use the first and last part of the nodename for nodes with long name
fi
elif
[
$SETTINGS_SUFFIX
=
'mac'
]
;
then
SUFFIX
=
"
$(
uci get network.bat0.macaddr
-q
)
"
else
# 'none'
SUFFIX
=
''
fi
# maximum simplified, no more ttvn rating
OFFLINE_SSID
=
"
$PREFIX$SUFFIX
"
# TODO: ffac tq limits has to be implemented here if enabled
ONLINE_SSID
=
"
$(
uci get wireless.client_radio0.ssid
-q
)
"
:
${
ONLINE_SSID
:
=
"FREIFUNK"
}
# if for whatever reason ONLINE_SSID is NULL
CHECK
=
"
$(
batctl gwl
-H
|grep
-v
"gateways in range"
|wc
-l
)
"
HUP_NEEDED
=
0
if
[
"
$CHECK
"
-gt
0
]
||
[
"
$DISABLED
"
=
'1'
]
;
then
...
...
@@ -37,11 +54,11 @@ if [ "$CHECK" -gt 0 ] || [ "$DISABLED" = '1' ]; then
fi
CURRENT_SSID
=
"
$(
grep
"^ssid=
$OFFLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
)
"
if
[
"
$CURRENT_SSID
"
=
"
$OFFLINE_SSID
"
]
;
then
logger
-s
-t
"gluon-
offline-ssid
"
-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
HUP_NEEDED
=
1
# HUP here would be to early for dualband devices
else
echo
"There is something wrong, did not
find SSID
$ONLINE_SSID
or
$OFFLINE_SSID
"
logger
-s
-t
"gluon-ssid-changer"
-p
5
"could not set to online state: did neither
find SSID
'
$ONLINE_SSID
' n
or
'
$OFFLINE_SSID
'. Please reboot
"
fi
done
elif
[
"
$CHECK
"
-eq
0
]
;
then
...
...
@@ -56,11 +73,11 @@ elif [ "$CHECK" -eq 0 ]; then
fi
CURRENT_SSID
=
"
$(
grep
"^ssid=
$ONLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
)
"
if
[
"
$CURRENT_SSID
"
=
"
$ONLINE_SSID
"
]
;
then
logger
-s
-t
"gluon-
offline-ssid
"
-p
5
"SSID is
$CURRENT_SSID
, change to
$OFFLINE_SSID
"
logger
-s
-t
"gluon-
ssid-changer
"
-p
5
"SSID is
$CURRENT_SSID
, change to
$OFFLINE_SSID
"
sed
-i
"s~^ssid=
$ONLINE_SSID
~ssid=
$OFFLINE_SSID
~"
$HOSTAPD
HUP_NEEDED
=
1
else
echo
"There is something wrong
: did neither find SSID '
$ONLINE_SSID
' nor '
$OFFLINE_SSID
'"
logger
-s
-t
"gluon-ssid-changer"
-p
5
"could not set to offline state
: did neither find SSID '
$ONLINE_SSID
' nor '
$OFFLINE_SSID
'
. Please reboot
"
fi
done
fi
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment