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
614d2f5a
Commit
614d2f5a
authored
7 years ago
by
rubo77
Browse files
Options
Downloads
Patches
Plain Diff
the first few minutes directly after reboot an Offline-SSID always may be activated
parent
f0da2afc
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
+11
-13
11 additions, 13 deletions
files/lib/gluon/ssid-changer/ssid-changer.sh
with
11 additions
and
13 deletions
files/lib/gluon/ssid-changer/ssid-changer.sh
+
11
−
13
View file @
614d2f5a
#!/bin/sh
# at first some Definitions:
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!)
# if the router started less than 10 minutes ago, exit
[
$(
cat
/proc/uptime |
sed
's/\..*//g'
)
-gt
600
]
||
exit
ONLINE_SSID
=
"
$(
uci get wireless.client_radio0.ssid
-q
)
"
:
${
ONLINE_SSID
:
=
"FREIFUNK"
}
# if for whatever reason ONLINE_SSID is NULL
#
G
enerate an Offline SSID with the first and last part of the nodename to allow owner to recognise wich node is down
#
g
enerate 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
...
...
@@ -27,13 +24,13 @@ if [ $CHECK -gt 0 ]; then
echo
"node is online"
for
HOSTAPD
in
$(
ls
/var/run/hostapd-phy
*
)
;
do
# check status for all physical devices
CURRENT_SSID
=
"
$(
grep
"^ssid=
$ONLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
)
"
if
[
"
$CURRENT_SSID
"
=
=
"
$ONLINE_SSID
"
]
if
[
"
$CURRENT_SSID
"
=
"
$ONLINE_SSID
"
]
then
echo
"SSID
$CURRENT_SSID
is correct, noting to do"
echo
"SSID
$CURRENT_SSID
is correct, not
h
ing to do"
break
fi
CURRENT_SSID
=
"
$(
grep
"^ssid=
$OFFLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
)
"
if
[
"
$CURRENT_SSID
"
=
=
"
$OFFLINE_SSID
"
]
;
then
if
[
"
$CURRENT_SSID
"
=
"
$OFFLINE_SSID
"
]
;
then
logger
-s
-t
"gluon-offline-ssid"
-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
...
...
@@ -43,15 +40,16 @@ if [ $CHECK -gt 0 ]; then
done
elif
[
$CHECK
-eq
0
]
;
then
echo
"node is considered offline"
if
[
$(
expr
$(
date
"+%s"
)
/ 60 %
$MINUTES
)
-eq
0
]
;
then
UP
=
$(
cat
/proc/uptime |
sed
's/\..*//g'
)
if
[
$((
$UP
/
60
))
-lt
$FIRST
]
||
[
$((
$UP
/
60
%
$MINUTES
))
-eq
0
]
;
then
for
HOSTAPD
in
$(
ls
/var/run/hostapd-phy
*
)
;
do
CURRENT_SSID
=
"
$(
grep
"^ssid=
$OFFLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
)
"
if
[
"
$CURRENT_SSID
"
=
=
"
$OFFLINE_SSID
"
]
;
then
echo
"SSID
$CURRENT_SSID
is correct, noting to do"
if
[
"
$CURRENT_SSID
"
=
"
$OFFLINE_SSID
"
]
;
then
echo
"SSID
$CURRENT_SSID
is correct, not
h
ing to do"
break
fi
CURRENT_SSID
=
"
$(
grep
"^ssid=
$ONLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
)
"
if
[
"
$CURRENT_SSID
"
=
=
"
$ONLINE_SSID
"
]
;
then
if
[
"
$CURRENT_SSID
"
=
"
$ONLINE_SSID
"
]
;
then
logger
-s
-t
"gluon-offline-ssid"
-p
5
"SSID is
$CURRENT_SSID
, change to
$OFFLINE_SSID
"
sed
-i
"s~^ssid=
$ONLINE_SSID
~ssid=
$OFFLINE_SSID
~"
$HOSTAPD
HUP_NEEDED
=
1
...
...
@@ -62,7 +60,7 @@ 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
HUP_NEEDED
=
0
echo
"HUP!"
...
...
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