Skip to content

Commit

Permalink
base-files: use jshn lib for ubus sysupgrade argument generation
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
feckert authored and ynezz committed Jan 13, 2020
1 parent 3d62463 commit 0f33c6b
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions package/base-files/files/sbin/sysupgrade
Original file line number Diff line number Diff line change
Expand Up @@ -360,18 +360,15 @@ if [ -n "$FAILSAFE" ]; then
printf '%s\x00%s\x00%s' "$RAM_ROOT" "$IMAGE" "$COMMAND" >/tmp/sysupgrade
lock -u /tmp/.failsafe
else
force_attr=""
[ $FORCE -eq 1 ] && force_attr="\"force\": true,"
backup_attr=""
[ $SAVE_CONFIG -eq 1 ] && backup_attr="\"backup\": $(json_string $CONF_TAR),"
ubus call system sysupgrade "{
\"prefix\": $(json_string "$RAM_ROOT"),
\"path\": $(json_string "$IMAGE"),
$force_attr
$backup_attr
\"command\": $(json_string "$COMMAND"),
\"options\": {
\"save_partitions\": $SAVE_PARTITIONS
}
}"
json_init
json_add_string prefix "$RAM_ROOT"
json_add_string path "$IMAGE"
[ $FORCE -eq 1 ] && json_add_boolean force 1
[ $SAVE_CONFIG -eq 1 ] && json_add_string backup "$CONF_TAR"
json_add_string command "$COMMAND"
json_add_object options
json_add_int save_partitions "$SAVE_PARTITIONS"
json_close_object

ubus call system sysupgrade "$(json_dump)"
fi

0 comments on commit 0f33c6b

Please sign in to comment.