firmware/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange
Adrian Schmutzler d0ef635bd4 hood file: Use different files for www and for checksum comparison
At the moment, we use the same file for detecting changes in a
new hood file and for broadcasting the hood information to be used
by mesh routers.

However, there may be situations where we don't want to broadcast
an existing hoodfile. We, on the other hand, cannot delete it
then, as we need the file for checking changes in the temporary
hoodfile.
We also cannot just switch the wXconfig state to achieve this
goal, as we need a trigger to do that (which is the same file we
are discussing about).

So, in this patch, we introduce two files, one for the checksum
comparison and one for the hood info broadcast. Those can now be
set and deleted (in a later patch) as it is required by their
respective tasks. This should also improve code clarity to the
reader ...

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>
2018-07-25 22:59:57 +02:00

36 lines
640 B
Bash

#!/bin/sh
# Copyright 2017 Adrian Schmutzler
# License GPLv3
. /usr/share/libubox/jshn.sh
hoodfiletmp="/tmp/hoodfile"
hoodfileref="/tmp/hoodfileref"
hoodfilewww="/www/hood/keyxchangev2data"
getJsonPath() {
jsonfile=""
if [ -s "$hoodfilewww" ] ; then
jsonfile="$hoodfilewww"
elif [ -s "$hoodfileref" ] ; then
jsonfile="$hoodfileref"
elif [ -s "$hoodfiletmp" ] ; then
jsonfile="$hoodfiletmp"
fi
echo "$jsonfile"
}
getUpgradePath() {
jsonfile="$(getJsonPath)"
if [ -n "$jsonfile" ] ; then
json_load "$(cat "$jsonfile")"
json_select hood
json_get_var upath upgrade_path
echo "$upath"
else
return 1
fi
return 0
}