From 24b585f012dbd7474f7f42ce5673f27d8292f852 Mon Sep 17 00:00:00 2001 From: hobbyquaker Date: Sun, 7 Mar 2021 00:01:27 +0100 Subject: [PATCH] checkContext (unfinished...) --- addon_files/redmatic/bin/checkContext | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 addon_files/redmatic/bin/checkContext diff --git a/addon_files/redmatic/bin/checkContext b/addon_files/redmatic/bin/checkContext new file mode 100755 index 00000000..d06405c1 --- /dev/null +++ b/addon_files/redmatic/bin/checkContext @@ -0,0 +1,25 @@ +#/bin/sh + +ADDON_DIR=/usr/local/addons/redmatic + +source $ADDON_DIR/home/.profile + +CONTEXT_DIR="`jq -r '.contextStorage.file.config.dir' $ADDON_DIR/etc/settings.json`" + +check() { + FILE=$1 + if [ -f $FILE ]; then + echo "checking $1" # | logger -p daemon.info -t redmatic + TYPE=`jq -r -e type $1 2> /dev/null` + if [ $? != 0 ] || [ -z $TYPE ] || [ $TYPE != "object" ]; then + echo "$1 corrupted." # | logger -p daemon.err -t redmatic + fi + fi + + +} + +if [ -d "$CONTEXT_DIR/context" ]; then + export check + find "$CONTEXT_DIR/context" -name \*.json | while read file; do check "$file"; done +fi