[PATCH v2] configurehood: Move timestamp extraction into function
Adrian Schmutzler
freifunk at adrianschmutzler.de
Do Mär 8 21:51:15 CET 2018
This also removes a strange quote character used in the regex.
Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
Changes in v2:
- Removed "function"
- Removed useless echo
- Named the function sanely
---
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..fd4126e 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
}
+removeTimestamp() {
+ # Remove timestamp from file (by setting it to zero)
+ # Usage: removeTimestamp <filename>
+
+ local file=$1
+
+ 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="$(removeTimestamp "$hoodfile" | sha256sum | cut -f1 -d " ")"
+ sumold="$(removeTimestamp "$hoodfilecopy" | sha256sum | cut -f1 -d " ")"
json_load "$(cat "$hoodfile")"
--
2.7.4
Mehr Informationen über die Mailingliste franken-dev