From a11408dd0388d4ba2f0ddb7610f83559b5dee9fc Mon Sep 17 00:00:00 2001 From: Alexandre Date: Sun, 31 Oct 2021 14:46:44 +0100 Subject: [PATCH] Clean error message, create backup for settings --- transmission/rootfs/etc/cont-init.d/19-json_repair.sh | 8 +++++++- 1 file changed, 7 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 d4b77671e..429c51c22 100644 --- a/transmission/rootfs/etc/cont-init.d/19-json_repair.sh +++ b/transmission/rootfs/etc/cont-init.d/19-json_repair.sh @@ -9,7 +9,13 @@ if [ -f ${JSONTOCHECK} ]; then 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} && exit 0) + jq -reM '""' <<<${JSONTOCHECK} 1>/dev/null || ERROR=true + if [ $ERROR = true ]; then + bashio::log.fatal "Settings.json structure is abnormal, restoring options from scratch. Your old file is renamed as settings.json_old" + mv ${JSONSOURCE} ${JSONSOURCE}_old + cp ${JSONSOURCE} ${JSONTOCHECK} + exit 0 + fi # Get the default keys from the original file mapfile -t arr < <(jq -r 'keys[]' ${JSONSOURCE})