base-files: use jshn lib for ubus sysupgrade argument generation

With this change the well known jshn library will be used, to build the
json arguments for the ubus sysupgrade method. This is also used in all
other shell program that uses JSON. This commit unifies that.

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2019-10-07 15:09:48 +02:00 committed by Petr Štetiar
parent 3d62463755
commit 0f33c6b74a

View File

@ -360,18 +360,15 @@ if [ -n "$FAILSAFE" ]; then
printf '%s\x00%s\x00%s' "$RAM_ROOT" "$IMAGE" "$COMMAND" >/tmp/sysupgrade printf '%s\x00%s\x00%s' "$RAM_ROOT" "$IMAGE" "$COMMAND" >/tmp/sysupgrade
lock -u /tmp/.failsafe lock -u /tmp/.failsafe
else else
force_attr="" json_init
[ $FORCE -eq 1 ] && force_attr="\"force\": true," json_add_string prefix "$RAM_ROOT"
backup_attr="" json_add_string path "$IMAGE"
[ $SAVE_CONFIG -eq 1 ] && backup_attr="\"backup\": $(json_string $CONF_TAR)," [ $FORCE -eq 1 ] && json_add_boolean force 1
ubus call system sysupgrade "{ [ $SAVE_CONFIG -eq 1 ] && json_add_string backup "$CONF_TAR"
\"prefix\": $(json_string "$RAM_ROOT"), json_add_string command "$COMMAND"
\"path\": $(json_string "$IMAGE"), json_add_object options
$force_attr json_add_int save_partitions "$SAVE_PARTITIONS"
$backup_attr json_close_object
\"command\": $(json_string "$COMMAND"),
\"options\": { ubus call system sysupgrade "$(json_dump)"
\"save_partitions\": $SAVE_PARTITIONS
}
}"
fi fi