base-files: sysupgrade: exit if the firmware download failed
[openwrt/staging/jogo.git] / package / base-files / files / sbin / sysupgrade
index f106c3c981873d1d7628559ee0db173b364e3bc4..6c518b780eddd973966537b50d8f7c82539bb1e1 100755 (executable)
@@ -294,7 +294,7 @@ type platform_check_image >/dev/null 2>/dev/null || {
 case "$IMAGE" in
        http://*|\
        https://*)
-               wget -O/tmp/sysupgrade.img "$IMAGE"
+               wget -O/tmp/sysupgrade.img "$IMAGE" || exit 1
                IMAGE=/tmp/sysupgrade.img
                ;;
 esac
@@ -362,13 +362,15 @@ if [ -n "$FAILSAFE" ]; then
 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_config\": $SAVE_CONFIG,
                        \"save_partitions\": $SAVE_PARTITIONS
                }
        }"