[RFC PATCH] fff-hoods/fff-hoodutils: Use different files for www and checksum

Adrian Schmutzler freifunk at adrianschmutzler.de
So Jun 10 14:39:08 CEST 2018


Since using the same file for detecting changes and for the hidden
AP causes trouble, this introduces two files.

Note that $hoodfilecopy is on /tmp, so reconfiguration will now
always occur on restarts.

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
 src/packages/fff/fff-hoods/files/usr/sbin/configurehood           | 6 ++++--
 src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange | 7 +++++--
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
index 780c2ba..455674d 100755
--- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
+++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood
@@ -38,7 +38,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"
@@ -91,6 +91,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 "$hoodfilewww" # delete this, so interfaces are recreated if reconnect with unchanged hood file takes place
 			rm -f "$hoodfilecopy" # delete this, so interfaces are recreated if reconnect with unchanged hood file takes place
 			rm -f "$sectorcopy" # always delete: no broadcast for isolated device
 			rm -f "$sectortmp"
@@ -215,7 +216,8 @@ 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 "$hoodfile" "$hoodfilecopy" # provide file for checksum verification
+		isGatewayAvailable && [ ! -s "$hoodlocal" ] && cp "$hoodfile" "$hoodfilewww" # provide file for hiddenap (NO file is served if local hood file present)
 		[ -s "$sectortmp" ] && cp "$sectortmp" "$sectorcopy"
 
 		# This is a workaround to enable alfred on devices which do not see a configap during initial setup
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..94b09bf 100644
--- a/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange
+++ b/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange
@@ -5,11 +5,14 @@
 . /usr/share/libubox/jshn.sh
 
 hoodfile="/tmp/keyxchangev2data"
-hoodfilecopy="/www/hood/keyxchangev2data"
+hoodfilewww="/www/hood/keyxchangev2data"
+hoodfilecopy="/tmp/keyxchangev2copy"
 
 getJsonPath() {
 	jsonfile=""
-	if [ -s "$hoodfilecopy" ] ; then
+	if [ -s "$hoodfilewww" ] ; then
+		jsonfile="$hoodfilewww"
+	elif [ -s "$hoodfilecopy" ] ; then
 		jsonfile="$hoodfilecopy"
 	elif [ -s "$hoodfile" ] ; then
 		jsonfile="$hoodfile"
-- 
2.7.4



Mehr Informationen über die Mailingliste franken-dev