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
759aafed
Commit
759aafed
authored
8 years ago
by
rubo77
Browse files
Options
Downloads
Patches
Plain Diff
fix grammar, indentions and code quality
parent
cc0e1f4f
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
files/lib/gluon/ssid-changer/ssid-changer.sh
+24
-24
24 additions, 24 deletions
files/lib/gluon/ssid-changer/ssid-changer.sh
with
24 additions
and
24 deletions
files/lib/gluon/ssid-changer/ssid-changer.sh
+
24
−
24
View file @
759aafed
#!/bin/sh
#
A
t first some Definitions:
#
a
t first some Definitions:
ONLINE_SSID
=
$(
uci get wireless.client_radio0.ssid
-q
)
:
${
ONLINE_SSID
:
=FREIFUNK
}
# if for whatever reason ONLINE_SSID is NULL
OFFLINE_PREFIX
=
'FF_OFFLINE_'
#
U
se something short to leave space for the nodename
OFFLINE_PREFIX
=
'FF_OFFLINE_'
#
u
se something short to leave space for the nodename
(no '~' allowed!)
UPPER_LIMIT
=
'55'
#
A
bove this limit the online SSID will be used
LOWER_LIMIT
=
'45'
#
B
elow this limit the offline SSID will be used
#
I
n-between these two values the SSID will never be changed to preven it from toggeling every Minute.
UPPER_LIMIT
=
'55'
#
a
bove this limit the online SSID will be used
LOWER_LIMIT
=
'45'
#
b
elow this limit the offline SSID will be used
#
i
n-between these two values the SSID will never be changed to preven it from toggeling every Minute.
# Generate an Offline SSID with the first and last
P
art of the nodename to allow owner to recognise wich node is down
# Generate an Offline SSID with the first and last
p
art 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
e
we are able to use the full nodename in the offline ssid
OFFLINE_SSID
=
"
$OFFLINE_PREFIX$NODENAME
"
#
great
!
we are able to use the full nodename in the offline ssid
fi
#
I
s there an active
G
ateway?
GATEWAY_TQ
=
`
batctl gwl |
grep
"^=>"
|
awk
-F
'[()]'
'{print $2}'
|
tr
-d
" "
`
#
G
rep the
C
onnection
Q
uality of the
Gateway which is
currently used
#
i
s there an active
g
ateway?
GATEWAY_TQ
=
$(
batctl gwl |
grep
"^=>"
|
awk
-F
'[()]'
'{print $2}'
|
tr
-d
" "
)
#
g
rep the
c
onnection
q
uality of the currently used
gateway
if
[
!
$GATEWAY_TQ
]
;
#
I
f there is no gateway there will be errors in the following if clauses
if
[
!
$GATEWAY_TQ
]
;
#
i
f there is no gateway there will be errors in the following if clauses
then
GATEWAY_TQ
=
0
#
J
ust an easy way to get a
n
valid value if there is no gatway
GATEWAY_TQ
=
0
#
j
ust an easy way to get a valid value if there is no gat
e
way
fi
if
[
$GATEWAY_TQ
-gt
$UPPER_LIMIT
]
;
then
echo
"Gateway TQ is
$GATEWAY_TQ
node is online"
for
HOSTAPD
in
$(
ls
/var/run/hostapd-phy
*
)
;
do
#
C
heck status for all physical devices
for
HOSTAPD
in
$(
ls
/var/run/hostapd-phy
*
)
;
do
#
c
heck status for all physical devices
CURRENT_SSID
=
`
grep
"^ssid=
$ONLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
`
if
[
$CURRENT_SSID
==
$ONLINE_SSID
]
then
...
...
@@ -42,7 +42,7 @@ then
CURRENT_SSID
=
`
grep
"^ssid=
$OFFLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
`
if
[
$CURRENT_SSID
==
$OFFLINE_SSID
]
then
logger
-s
-t
"gluon-offline-ssid"
-p
5
"TQ is
$GATEWAY_TQ
, SSID is
$CURRENT_SSID
, change to
$ONLINE_SSID
"
#
W
rite
I
nfo to
S
yslog
logger
-s
-t
"gluon-offline-ssid"
-p
5
"TQ is
$GATEWAY_TQ
, SSID is
$CURRENT_SSID
, change to
$ONLINE_SSID
"
#
w
rite
i
nfo to
s
yslog
sed
-i
"s~^ssid=
$CURRENT_SSID
~ssid=
$ONLINE_SSID
~"
$HOSTAPD
HUP_NEEDED
=
1
# HUP here would be to early for dualband devices
else
...
...
@@ -54,34 +54,34 @@ fi
if
[
$GATEWAY_TQ
-lt
$LOWER_LIMIT
]
;
then
echo
"Gateway TQ is
$GATEWAY_TQ
node is considered offline"
for
HOSTAPD
in
$(
ls
/var/run/hostapd-phy
*
)
;
do
#
C
heck status for all physical devices
CURRENT_SSID
=
`
grep
"^ssid=
$OFFLINE_SSID
"
$HOSTAPD
|
cut
-d
"="
-f2
`
for
HOSTAPD
in
$(
ls
/var/run/hostapd-phy
*
)
;
do
#
c
heck status for all physical devices
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"
HUP_NEEDED
=
0
break
fi
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
]
then
logger
-s
-t
"gluon-offline-ssid"
-p
5
"TQ is
$GATEWAY_TQ
, SSID is
$CURRENT_SSID
, change to
$OFFLINE_SSID
"
#Write Info to Syslog
logger
-s
-t
"gluon-offline-ssid"
-p
5
"TQ is
$GATEWAY_TQ
, SSID is
$CURRENT_SSID
, change to
$OFFLINE_SSID
"
sed
-i
"s~^ssid=
$ONLINE_SSID
~ssid=
$OFFLINE_SSID
~"
$HOSTAPD
HUP_NEEDED
=
1
# HUP here would be to early for dualband devices
HUP_NEEDED
=
1
# HUP here would be to
o
early for dualband devices
else
echo
"There is something wrong
,
did n
ot
find SSID
$ONLINE_SSID
or
$OFFLINE_SSID
"
echo
"There is something wrong
:
did n
either
find SSID
'
$ONLINE_SSID
' n
or
'
$OFFLINE_SSID
'
"
fi
done
fi
if
[
$GATEWAY_TQ
-ge
$LOWER_LIMIT
-a
$GATEWAY_TQ
-le
$UPPER_LIMIT
]
;
#
T
his is just get a clean run if we are in-between the grace periode
if
[
$GATEWAY_TQ
-ge
$LOWER_LIMIT
-a
$GATEWAY_TQ
-le
$UPPER_LIMIT
]
;
#
t
his is just get a clean run if we are in-between the grace periode
then
echo
"TQ is
$GATEWAY_TQ
, do nothing"
HUP_NEEDED
=
0
fi
if
[
$HUP_NEEDED
==
1
]
;
then
killall
-HUP
hostapd
#
S
end HUP to all hostapd
um di
e ne
ue
SSID
zu laden
killall
-HUP
hostapd
#
s
end HUP to all hostapd
to load th
e ne
w
SSID
HUP_NEEDED
=
0
echo
"HUP!"
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