On 05/22/2014 10:16 PM, André Valentin wrote:
> diff --git a/package/base-files/files/sbin/sysupgrade 
> b/package/base-files/files/sbin/sysupgrade
> index 479cbad..5159367 100755
> --- a/package/base-files/files/sbin/sysupgrade
> +++ b/package/base-files/files/sbin/sysupgrade
> @@ -19,6 +19,8 @@ export NEED_IMAGE=
>  export HELP=0
>  export FORCE=0
>  export TEST=0
> +export RUN_AS_INIT=0
> +export ALL_ARGS="$*"
>  
>  # parse options
>  while [ -n "$1" ]; do
> @@ -33,6 +35,7 @@ while [ -n "$1" ]; do
>               -r|--restore-backup) export CONF_RESTORE="$2" NEED_IMAGE=1; 
> shift;;
>               -l|--list-backup) export CONF_BACKUP_LIST=1; break;;
>               -f) export CONF_IMAGE="$2"; shift;;
> +             -s) export RUN_AS_INIT=1;;
I think it should be the default.

>               -F|--force) export FORCE=1;;
>               -T|--test) export TEST=1;;
>               -h|--help) export HELP=1; break;;
> @@ -62,6 +65,9 @@ upgrade-option:
>       -i           interactive mode
>       -c           attempt to preserve all changed files in /etc/
>       -n           do not save configuration over reflash
> +        -s           run the upgrade process as init (PID 0)
> +                     this allows ubifs upgrades i.e.
> +                     important: use full image path like /tmp/xx.bin
same.

>       -T | --test
>                    Verify image and config .tar.gz but do not actually flash.
>       -F | --force
> @@ -220,6 +226,13 @@ if [ $TEST -eq 1 ]; then
>       exit 0
>  fi
>  
> +# should we inform procd to run this script
> +if [ $RUN_AS_INIT -eq 1 ] && [ $$ -ne 1 ]; then
same.

> +        ubus call system upgrade_as_init \
> +                '{ "command": "/sbin/sysupgrade", "arguments": "'$ARGV'" }'

I reckon the best would be to use the running userspace to acquire the upgrade
image (in case it's not a local file sitting under /tmp, e.g. http urls do work
right now!), and pass the filename as an absolute path in the ubus call.

> +        exit 0
> +fi
> +
>  run_hooks "" $sysupgrade_pre_upgrade
>  
>  ubus call system upgrade
> 
_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to