forked from freifunk-franken/firmware
hood files: Use more meaningful and concise naming scheme
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Reviewed-by: Fabian Bläse <fabian@blaese.de> Reviewed-by: Robert Langhammer <rlanghammer@web.de> Tested-by: Fabian Bläse <fabian@blaese.de> Reviewed-by: Tim Niemeyer <tim@tn-x.org>
This commit is contained in:
parent
d09df921e0
commit
845886d16a
|
@ -7,9 +7,10 @@
|
||||||
. /lib/functions/fff/timeserver
|
. /lib/functions/fff/timeserver
|
||||||
. /usr/lib/functions/fff/hoodfile
|
. /usr/lib/functions/fff/hoodfile
|
||||||
|
|
||||||
hoodlocal=/etc/hoodfile
|
|
||||||
|
|
||||||
rm -f "$hoodfile"
|
hoodfilelocal=/etc/hoodfile
|
||||||
|
|
||||||
|
rm -f "$hoodfiletmp"
|
||||||
|
|
||||||
# Gatewaycheck function
|
# Gatewaycheck function
|
||||||
isGatewayAvailable() {
|
isGatewayAvailable() {
|
||||||
|
@ -35,7 +36,7 @@ hasInternet() {
|
||||||
|
|
||||||
# Hidden AP check
|
# Hidden AP check
|
||||||
|
|
||||||
if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
|
if [ -s "$hoodfilewww" ] && isGatewayAvailable ; then
|
||||||
needwifi="0"
|
needwifi="0"
|
||||||
for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
|
for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
|
||||||
freq="2"
|
freq="2"
|
||||||
|
@ -67,13 +68,13 @@ if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -s "$hoodlocal" ]; then
|
if [ -s "$hoodfilelocal" ]; then
|
||||||
hoodfile="$hoodlocal"
|
hoodfiletmp="$hoodfilelocal"
|
||||||
echo "Use local hood file"
|
echo "Use local hood file"
|
||||||
else
|
else
|
||||||
# if we have Internet, we download the Hoodfile from the keyxchangev2
|
# if we have Internet, we download the Hoodfile from the keyxchangev2
|
||||||
if hasInternet ; then
|
if hasInternet ; then
|
||||||
getKeyserverHoodfile "$hoodfile"
|
getKeyserverHoodfile "$hoodfiletmp"
|
||||||
|
|
||||||
#if no Internet, we connect to the hidden AP and download the file from another Node in range
|
#if no Internet, we connect to the hidden AP and download the file from another Node in range
|
||||||
else
|
else
|
||||||
|
@ -82,7 +83,7 @@ else
|
||||||
if ! isGatewayAvailable ; then
|
if ! isGatewayAvailable ; then
|
||||||
#now we haven't a gateway in Range, we search for a hidden AP to get a keyxchangev2data file!
|
#now we haven't a gateway in Range, we search for a hidden AP to get a keyxchangev2data file!
|
||||||
#first we delete all wifi settings
|
#first we delete all wifi settings
|
||||||
rm -f "$hoodfilecopy" # delete this, so interfaces are recreated if reconnect with unchanged hood file takes place
|
rm -f "$hoodfilewww" # delete this, so interfaces are recreated if reconnect with unchanged hood file takes place
|
||||||
|
|
||||||
uci -q del "system.@system[0].hood"
|
uci -q del "system.@system[0].hood"
|
||||||
uci -q commit system
|
uci -q commit system
|
||||||
|
@ -90,26 +91,26 @@ else
|
||||||
|
|
||||||
sleep 30 # Wait for the config AP, which may be created at the same time as this script has started
|
sleep 30 # Wait for the config AP, which may be created at the same time as this script has started
|
||||||
|
|
||||||
getEthernetHoodfile "$hoodfile" || getWirelessHoodfile "$hoodfile"
|
getEthernetHoodfile "$hoodfiletmp" || getWirelessHoodfile "$hoodfiletmp"
|
||||||
else
|
else
|
||||||
echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
|
echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
|
||||||
getGatewayHoodfile "$hoodfile"
|
getGatewayHoodfile "$hoodfiletmp"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -s "$hoodfile" ]; then
|
if [ -s "$hoodfiletmp" ]; then
|
||||||
|
|
||||||
# we get a json file in this format:
|
# we get a json file in this format:
|
||||||
# https://pw.freifunk-franken.de/patch/205/
|
# https://pw.freifunk-franken.de/patch/205/
|
||||||
# but without signature, every hood file we get is valid!
|
# but without signature, every hood file we get is valid!
|
||||||
|
|
||||||
catnew="$(cat "$hoodfile" | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
|
catnew="$(cat "$hoodfiletmp" | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
|
||||||
catold="$(cat "$hoodfilecopy" 2>/dev/null | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
|
catold="$(cat "$hoodfilewww" 2>/dev/null | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
|
||||||
sumnew=$(echo "$catnew" | sha256sum | cut -f1 -d " ")
|
sumnew=$(echo "$catnew" | sha256sum | cut -f1 -d " ")
|
||||||
sumold=$(echo "$catold" | sha256sum | cut -f1 -d " ")
|
sumold=$(echo "$catold" | sha256sum | cut -f1 -d " ")
|
||||||
|
|
||||||
json_load "$(cat "$hoodfile")"
|
json_load "$(cat "$hoodfiletmp")"
|
||||||
|
|
||||||
if [ "$sumnew" != "$sumold" ] ; then
|
if [ "$sumnew" != "$sumold" ] ; then
|
||||||
echo "New file detected, we reconfigure the Node";
|
echo "New file detected, we reconfigure the Node";
|
||||||
|
@ -184,7 +185,7 @@ if [ -s "$hoodfile" ]; then
|
||||||
|
|
||||||
# copy the file to webroot so that other mesh routers can download it;
|
# copy the file to webroot so that other mesh routers can download it;
|
||||||
# copy only after all other steps so IF can be reentered if something goes wrong
|
# copy only after all other steps so IF can be reentered if something goes wrong
|
||||||
cp "$hoodfile" "$hoodfilecopy"
|
cp "$hoodfiletmp" "$hoodfilewww"
|
||||||
|
|
||||||
# This is a workaround to enable alfred on devices which do not see a configap during initial setup
|
# This is a workaround to enable alfred on devices which do not see a configap during initial setup
|
||||||
/etc/init.d/alfred restart
|
/etc/init.d/alfred restart
|
||||||
|
|
|
@ -4,15 +4,15 @@
|
||||||
|
|
||||||
. /usr/share/libubox/jshn.sh
|
. /usr/share/libubox/jshn.sh
|
||||||
|
|
||||||
hoodfile="/tmp/keyxchangev2data"
|
hoodfiletmp="/tmp/hoodfile"
|
||||||
hoodfilecopy="/www/hood/keyxchangev2data"
|
hoodfilewww="/www/hood/keyxchangev2data"
|
||||||
|
|
||||||
getJsonPath() {
|
getJsonPath() {
|
||||||
jsonfile=""
|
jsonfile=""
|
||||||
if [ -s "$hoodfilecopy" ] ; then
|
if [ -s "$hoodfilewww" ] ; then
|
||||||
jsonfile="$hoodfilecopy"
|
jsonfile="$hoodfilewww"
|
||||||
elif [ -s "$hoodfile" ] ; then
|
elif [ -s "$hoodfiletmp" ] ; then
|
||||||
jsonfile="$hoodfile"
|
jsonfile="$hoodfiletmp"
|
||||||
fi
|
fi
|
||||||
echo "$jsonfile"
|
echo "$jsonfile"
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ make_config() {
|
||||||
rm /tmp/fastd_fff_peers/*
|
rm /tmp/fastd_fff_peers/*
|
||||||
count=0
|
count=0
|
||||||
Index=1
|
Index=1
|
||||||
json_load "$(cat "$hoodfile")"
|
json_load "$(cat "$hoodfiletmp")"
|
||||||
json_select vpn
|
json_select vpn
|
||||||
# get fastd peers
|
# get fastd peers
|
||||||
while json_select "$Index" > /dev/null
|
while json_select "$Index" > /dev/null
|
||||||
|
@ -54,7 +54,7 @@ json_select ".." # back to root
|
||||||
# main
|
# main
|
||||||
|
|
||||||
# Only do something when file is here and greater 0 byte
|
# Only do something when file is here and greater 0 byte
|
||||||
if [ -s "$hoodfile" ]; then
|
if [ -s "$hoodfiletmp" ]; then
|
||||||
# set some vars
|
# set some vars
|
||||||
hostname=$(cat /proc/sys/kernel/hostname)
|
hostname=$(cat /proc/sys/kernel/hostname)
|
||||||
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
|
mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
if [ "$REQUEST_METHOD" == "POST" ] ; then
|
if [ "$REQUEST_METHOD" == "POST" ] ; then
|
||||||
if [ "$POST_resethood" != "" ] ; then
|
if [ "$POST_resethood" != "" ] ; then
|
||||||
# reset hood
|
# reset hood
|
||||||
rm "$hoodfilecopy" 2> /dev/null
|
rm "$hoodfilewww" 2> /dev/null
|
||||||
MSG='<span class="green">Hood-Daten werden innerhalb von 5 Minuten neu prozessiert.</span>'
|
MSG='<span class="green">Hood-Daten werden innerhalb von 5 Minuten neu prozessiert.</span>'
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue