2021-02-10 01:53:21 +01:00
|
|
|
# SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#
|
2017-10-05 15:37:46 +02:00
|
|
|
# Copyright 2017 Adrian Schmutzler
|
|
|
|
|
|
|
|
. /usr/share/libubox/jshn.sh
|
2019-11-20 22:27:44 +01:00
|
|
|
. /etc/firmware_release
|
2017-10-05 15:37:46 +02:00
|
|
|
|
2018-07-08 19:57:35 +02:00
|
|
|
hoodfiletmp="/tmp/hoodfile"
|
2018-07-25 15:58:15 +02:00
|
|
|
hoodfileref="/tmp/hoodfileref"
|
2018-07-08 19:57:38 +02:00
|
|
|
hoodfilewww="/tmp/hoodfilewww"
|
2017-10-30 20:08:27 +01:00
|
|
|
|
2017-10-15 18:00:33 +02:00
|
|
|
getJsonPath() {
|
|
|
|
jsonfile=""
|
2018-07-08 19:57:35 +02:00
|
|
|
if [ -s "$hoodfilewww" ] ; then
|
|
|
|
jsonfile="$hoodfilewww"
|
2018-07-25 15:58:15 +02:00
|
|
|
elif [ -s "$hoodfileref" ] ; then
|
|
|
|
jsonfile="$hoodfileref"
|
2018-07-08 19:57:35 +02:00
|
|
|
elif [ -s "$hoodfiletmp" ] ; then
|
|
|
|
jsonfile="$hoodfiletmp"
|
2017-10-15 18:00:33 +02:00
|
|
|
fi
|
|
|
|
echo "$jsonfile"
|
|
|
|
}
|
|
|
|
|
2017-10-05 15:37:46 +02:00
|
|
|
getUpgradePath() {
|
2017-10-15 18:00:33 +02:00
|
|
|
jsonfile="$(getJsonPath)"
|
2019-11-20 22:27:44 +01:00
|
|
|
local upgrade_path
|
2017-10-15 18:00:33 +02:00
|
|
|
|
|
|
|
if [ -n "$jsonfile" ] ; then
|
|
|
|
json_load "$(cat "$jsonfile")"
|
2017-10-05 15:37:46 +02:00
|
|
|
json_select hood
|
|
|
|
json_get_var upath upgrade_path
|
2019-11-20 22:27:44 +01:00
|
|
|
upgrade_path="$upath"
|
2017-10-05 15:37:46 +02:00
|
|
|
else
|
2019-11-20 22:27:45 +01:00
|
|
|
upgrade_path="http://dev.freifunk-franken.de"
|
|
|
|
>&2 echo "Upgrade path not set! Falling back to $upgrade_path"
|
2017-10-05 15:37:46 +02:00
|
|
|
fi
|
2019-11-20 22:27:44 +01:00
|
|
|
|
|
|
|
# add full firmware path for current firmwares variant
|
|
|
|
echo "${upgrade_path}/${VARIANT}/current"
|
|
|
|
|
2017-10-05 15:37:46 +02:00
|
|
|
return 0
|
|
|
|
}
|