[PATCH v3 1/5] hood files: Use more meaningful and concise naming scheme
Robert Langhammer
rlanghammer at web.de
Mo Jul 9 14:17:35 CEST 2018
Hallo Adrian,
auch von mir ein
Reviewed-by: Robert Langhammer <rlanghammer at web.de>
Am 08.07.2018 um 21:22 schrieb Fabian Bläse:
> Passt, also kann mein Review wieder dran.
>
> Reviewed-by: Fabian Bläse <fabian at blaese.de>
>
>> On 8. Jul 2018, at 19:57, Adrian Schmutzler <freifunk at adrianschmutzler.de> wrote:
>>
>> Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
>>
>> ---
>>
>> Changes in v2:
>> none
>>
>> Changes in v3:
>> - Removed sector file references
>> - Removed Review (too much changed)
>> ---
>> .../fff/fff-hoods/files/usr/sbin/configurehood | 29 +++++++++++-----------
>> .../files/lib/functions/fff/keyxchange | 12 ++++-----
>> .../fff/fff-vpn-select/files/usr/sbin/vpn-select | 4 +--
>> .../fff/fff-web/files/www/ssl/cgi-bin/home.html | 2 +-
>> 4 files changed, 24 insertions(+), 23 deletions(-)
>>
>> diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>> index 86d83fc..1a2c12a 100755
>> --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>> +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
>> @@ -7,9 +7,10 @@
>> . /lib/functions/fff/timeserver
>> . /usr/lib/functions/fff/hoodfile
>>
>> -hoodlocal=/etc/hoodfile
>>
>> -rm -f "$hoodfile"
>> +hoodfilelocal=/etc/hoodfile
>> +
>> +rm -f "$hoodfiletmp"
>>
>> # Gatewaycheck function
>> isGatewayAvailable() {
>> @@ -35,7 +36,7 @@ hasInternet() {
>>
>> # Hidden AP check
>>
>> -if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
>> +if [ -s "$hoodfilewww" ] && isGatewayAvailable ; then
>> needwifi="0"
>> for radio in $(uci show wireless | sed -n 's,.*\.\([a-z0-9]*\)=wifi-device,\1,p'); do
>> freq="2"
>> @@ -67,13 +68,13 @@ if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then
>> fi
>> fi
>>
>> -if [ -s "$hoodlocal" ]; then
>> - hoodfile="$hoodlocal"
>> +if [ -s "$hoodfilelocal" ]; then
>> + hoodfiletmp="$hoodfilelocal"
>> echo "Use local hood file"
>> else
>> # if we have Internet, we download the Hoodfile from the keyxchangev2
>> 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
>> else
>> @@ -82,7 +83,7 @@ else
>> if ! isGatewayAvailable ; then
>> #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
>> - 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. at system[0].hood"
>> 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
>>
>> - getEthernetHoodfile "$hoodfile" || getWirelessHoodfile "$hoodfile"
>> + getEthernetHoodfile "$hoodfiletmp" || getWirelessHoodfile "$hoodfiletmp"
>> else
>> echo "We have a Gateway in Range, we load the keyxchangev2data from fe80::1"
>> - getGatewayHoodfile "$hoodfile"
>> + getGatewayHoodfile "$hoodfiletmp"
>> fi
>> fi
>> fi
>>
>> -if [ -s "$hoodfile" ]; then
>> +if [ -s "$hoodfiletmp" ]; then
>>
>> # we get a json file in this format:
>> # https://pw.freifunk-franken.de/patch/205/
>> # but without signature, every hood file we get is valid!
>>
>> - catnew="$(cat "$hoodfile" | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
>> - catold="$(cat "$hoodfilecopy" 2>/dev/null | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')"
>> + catnew="$(cat "$hoodfiletmp" | 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 " ")
>> sumold=$(echo "$catold" | sha256sum | cut -f1 -d " ")
>>
>> - json_load "$(cat "$hoodfile")"
>> + json_load "$(cat "$hoodfiletmp")"
>>
>> if [ "$sumnew" != "$sumold" ] ; then
>> 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 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
>> /etc/init.d/alfred restart
>> diff --git a/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange b/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange
>> index 30963ae..4d624a1 100644
>> --- a/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange
>> +++ b/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange
>> @@ -4,15 +4,15 @@
>>
>> . /usr/share/libubox/jshn.sh
>>
>> -hoodfile="/tmp/keyxchangev2data"
>> -hoodfilecopy="/www/hood/keyxchangev2data"
>> +hoodfiletmp="/tmp/hoodfile"
>> +hoodfilewww="/www/hood/keyxchangev2data"
>>
>> getJsonPath() {
>> jsonfile=""
>> - if [ -s "$hoodfilecopy" ] ; then
>> - jsonfile="$hoodfilecopy"
>> - elif [ -s "$hoodfile" ] ; then
>> - jsonfile="$hoodfile"
>> + if [ -s "$hoodfilewww" ] ; then
>> + jsonfile="$hoodfilewww"
>> + elif [ -s "$hoodfiletmp" ] ; then
>> + jsonfile="$hoodfiletmp"
>> fi
>> echo "$jsonfile"
>> }
>> diff --git a/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select b/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select
>> index 85930a8..135c063 100755
>> --- a/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select
>> +++ b/src/packages/fff/fff-vpn-select/files/usr/sbin/vpn-select
>> @@ -9,7 +9,7 @@ make_config() {
>> rm /tmp/fastd_fff_peers/*
>> count=0
>> Index=1
>> -json_load "$(cat "$hoodfile")"
>> +json_load "$(cat "$hoodfiletmp")"
>> json_select vpn
>> # get fastd peers
>> while json_select "$Index" > /dev/null
>> @@ -54,7 +54,7 @@ json_select ".." # back to root
>> # main
>>
>> # Only do something when file is here and greater 0 byte
>> -if [ -s "$hoodfile" ]; then
>> +if [ -s "$hoodfiletmp" ]; then
>> # set some vars
>> hostname=$(cat /proc/sys/kernel/hostname)
>> mac=$(awk '{ mac=toupper($1); gsub(":", "", mac); print mac }' /sys/class/net/br-mesh/address 2>/dev/null)
>> diff --git a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html
>> index 21bd4e7..ef71eb4 100755
>> --- a/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html
>> +++ b/src/packages/fff/fff-web/files/www/ssl/cgi-bin/home.html
>> @@ -8,7 +8,7 @@
>> if [ "$REQUEST_METHOD" == "POST" ] ; then
>> if [ "$POST_resethood" != "" ] ; then
>> # 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>'
>> fi
>> fi
>> --
>> 2.7.4
>>
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname : signature.asc
Dateityp : application/pgp-signature
Dateigröße : 819 bytes
Beschreibung: OpenPGP digital signature
URL : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20180709/f158d065/attachment.sig>
Mehr Informationen über die Mailingliste franken-dev