From patchwork Thu Mar 8 20:24:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: configurehood: Move timestamp extraction into function From: Adrian Schmutzler X-Patchwork-Id: 815 Message-Id: <1520540662-4233-1-git-send-email-freifunk@adrianschmutzler.de> To: franken-dev@freifunk.net Date: Thu, 8 Mar 2018 21:24:22 +0100 This also removes a strange quote character used in catold=... Signed-off-by: Adrian Schmutzler --- src/packages/fff/fff-hoods/files/usr/sbin/configurehood | 15 +++++++++++---- 1 file changed, 11 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 3a6fb9b..76fdfd8 100755 --- a/src/packages/fff/fff-hoods/files/usr/sbin/configurehood +++ b/src/packages/fff/fff-hoods/files/usr/sbin/configurehood @@ -36,6 +36,15 @@ hasInternet() { return 1 } +function getTimestamp() { + # Get timestamp from file + # Usage: getTimestamp + + local file=$1 + + echo "$(cat "$file" 2>/dev/null | sed 's/"timestamp": *"[0-9]*"/"timestamp":0/')" +} + # Hidden AP check if [ -s "$hoodfilecopy" ] && isGatewayAvailable ; then @@ -209,10 +218,8 @@ if [ -s "$hoodfile" ]; then json_get_var mesh_type5 mesh_type5 fi - catnew="$(cat "$hoodfile" | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')" - catold="$(cat "$hoodfilecopy" 2>/dev/null | sed 's/"timestamp”: *"[0-9]*"/"timestamp":0/')" - sumnew=$(echo "$catnew" | sha256sum | cut -f1 -d " ") - sumold=$(echo "$catold" | sha256sum | cut -f1 -d " ") + sumnew="$(getTimestamp "$hoodfile" | sha256sum | cut -f1 -d " ")" + sumold="$(getTimestamp "$hoodfilecopy" | sha256sum | cut -f1 -d " ")" json_load "$(cat "$hoodfile")"