From c4ae6bf2166533e0929fbe72a5cd19b98e0c10fe Mon Sep 17 00:00:00 2001 From: Adrian Schmutzler Date: Sun, 15 Oct 2017 18:00:33 +0200 Subject: [PATCH] fff-hoods: Fix case of missing keyxchangev2data This fixes a missing /tmp/keyxchangev2data due to gateway misconfiguration. Signed-off-by: Adrian Schmutzler Reviewed-by: Tim Niemeyer - Added double quote around $jsonfile Signed-off-by: Tim Niemeyer --- .../fff-hoods/files/lib/functions/fff/keyxchange | 16 ++++++++++++++-- .../fff/fff-web/files/www/ssl/cgi-bin/home.html | 7 ++++--- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange b/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange index be27e5a..d7c2c13 100644 --- a/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange +++ b/src/packages/fff/fff-hoods/files/lib/functions/fff/keyxchange @@ -4,9 +4,21 @@ . /usr/share/libubox/jshn.sh +getJsonPath() { + jsonfile="" + if [ -s /www/public/keyxchangev2data ] ; then + jsonfile="/www/public/keyxchangev2data" + elif [ -s /tmp/keyxchangev2data ] ; then + jsonfile="/tmp/keyxchangev2data" + fi + echo "$jsonfile" +} + getUpgradePath() { - if [ -s /tmp/keyxchangev2data ]; then - json_load "$(cat /tmp/keyxchangev2data)" + jsonfile="$(getJsonPath)" + + if [ -n "$jsonfile" ] ; then + json_load "$(cat "$jsonfile")" json_select hood json_get_var upath upgrade_path echo "$upath" 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 1569c01..cbce768 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 @@ -48,9 +48,10 @@ else fi # read from keyxchangev2data -. /usr/share/libubox/jshn.sh -if [ -s /tmp/keyxchangev2data ] ; then - json_load "$(cat /tmp/keyxchangev2data)" +. /lib/functions/fff/keyxchange +jsonfile="$(getJsonPath)" +if [ -n "$jsonfile" ] ; then + json_load "$(cat "$jsonfile")" json_select hood json_get_var mesh_type2 mesh_type2 json_get_var mesh_type5 mesh_type5