From 429a1b0e7b36a4db774cda45491267e4f682d4ea Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 31 Oct 2021 14:39:32 +0100 Subject: [PATCH] change json validation --- transmission/rootfs/etc/cont-init.d/19-json_repair.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transmission/rootfs/etc/cont-init.d/19-json_repair.sh b/transmission/rootfs/etc/cont-init.d/19-json_repair.sh index 589d7d4ee..8275cea2a 100644 --- a/transmission/rootfs/etc/cont-init.d/19-json_repair.sh +++ b/transmission/rootfs/etc/cont-init.d/19-json_repair.sh @@ -8,8 +8,11 @@ if [ -f ${JSONTOCHECK} ]; then # Variables echo "Checking settings.json format" + # Check if json file valid or not + jq -reM '""' <<<${JSONTOCHECK} 1>/dev/null || (bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch" && cp ${JSONSOURCE} ${JSONTOCHECK}) + # Get the default keys from the original file - mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) || (bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch" && cp ${JSONSOURCE} ${JSONTOCHECK}) + mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE}) # Check if all keys are still there, or add them for KEYS in ${arr[@]}; do