firmware/src/packages/fff/fff-hoodutils/files/lib/functions/fff/keyxchange
Fabian Bläse d968665704 fff-hoodutils: Add fallback for upgrade path
If no hoodfile is present or hoodfile support is not compiled
into the firmware, no upgrade path is available. This currently
is the case for layer3 variant.

A fallback to our default firmware host is added. At the moment
both variants don't have a trust anchor for TLS and the wget, that
is currently used, doesn't support TLS. Therefore it is currently
necessary to use a unencrypted http URL.

Signed-off-by: Fabian Bläse <fabian@blaese.de>
Reviewed-by: Christian Dresel <fff@chrisi01.de>
2019-11-23 14:29:15 +01:00

42 lines
875 B
Plaintext

# Copyright 2017 Adrian Schmutzler
# License GPLv3
. /usr/share/libubox/jshn.sh
. /etc/firmware_release
hoodfiletmp="/tmp/hoodfile"
hoodfileref="/tmp/hoodfileref"
hoodfilewww="/tmp/hoodfilewww"
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)"
local upgrade_path
if [ -n "$jsonfile" ] ; then
json_load "$(cat "$jsonfile")"
json_select hood
json_get_var upath upgrade_path
upgrade_path="$upath"
else
upgrade_path="http://dev.freifunk-franken.de"
>&2 echo "Upgrade path not set! Falling back to $upgrade_path"
fi
# add full firmware path for current firmwares variant
echo "${upgrade_path}/${VARIANT}/current"
return 0
}