aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Eckert <fe@dev.tdt.de>2019-10-07 15:09:48 +0200
committerPetr Štetiar <ynezz@true.cz>2020-01-14 00:06:03 +0100
commit0f33c6b74a621f2b8bb5793c5e0d3121a1da09b2 (patch)
tree02f2992c77fc76f8fed72ad255c75ff041236596
parent3d62463755067656caaa404a0fa133b2e56179f7 (diff)
downloadupstream-0f33c6b74a621f2b8bb5793c5e0d3121a1da09b2.tar.gz
upstream-0f33c6b74a621f2b8bb5793c5e0d3121a1da09b2.tar.bz2
upstream-0f33c6b74a621f2b8bb5793c5e0d3121a1da09b2.zip
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>
-rwxr-xr-xpackage/base-files/files/sbin/sysupgrade25
1 files changed, 11 insertions, 14 deletions
diff --git a/package/base-files/files/sbin/sysupgrade b/package/base-files/files/sbin/sysupgrade
index 6c518b780e..abd34bdcfb 100755
--- a/package/base-files/files/sbin/sysupgrade
+++ b/package/base-files/files/sbin/sysupgrade
@@ -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