diff --git a/sysmngr/Makefile b/sysmngr/Makefile index 72ce7a758..54f512f3f 100644 --- a/sysmngr/Makefile +++ b/sysmngr/Makefile @@ -5,13 +5,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=sysmngr -PKG_VERSION:=1.0.31 +PKG_VERSION:=1.1.0 LOCAL_DEV:=0 ifneq ($(LOCAL_DEV),1) PKG_SOURCE_PROTO:=git PKG_SOURCE_URL:=https://dev.iopsys.eu/system/sysmngr.git -PKG_SOURCE_VERSION:=d84dd91e19ec8e2a6baf3efa9ff319bf9d6f746a +PKG_SOURCE_VERSION:=0d0cef8a18ed6683568ddbf8b2263691a6e9927e PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz PKG_MIRROR_HASH:=skip endif diff --git a/sysmngr/files/etc/sysmngr/fwbank b/sysmngr/files/etc/sysmngr/fwbank index e45b2783c..81602d149 100755 --- a/sysmngr/files/etc/sysmngr/fwbank +++ b/sysmngr/files/etc/sysmngr/fwbank @@ -22,7 +22,7 @@ fwbank_get_bootbank() { case "$1" in list) - echo '{ "dump" : {}, "set_bootbank" : {"bank":32}, "copy_config" : {}, "upgrade": {"path":"String","auto_activate":true,"bank":32,"keep_settings":true}}' + echo '{ "dump" : {}, "set_bootbank" : {"bank":32}, "copy_config": {"keep_settings":true, "keep_opconf":true, "config_scope":"String"}, "upgrade": {"path":"String","auto_activate":true,"bank":32,"keep_settings":true,"keep_opconf":true,"config_scope":"String"}}' ;; call) case "$2" in @@ -125,19 +125,32 @@ case "$1" in fi ;; copy_config) - if [ -z "$UPGRADE_BACKUP" ]; then - UPGRADE_BACKUP=/tmp/sysupgrade.tgz + read -r input + json_load "${input}" + json_get_var keep_settings keep_settings + json_get_var keep_opconf keep_opconf + json_get_var config_scope config_scope + + # Set the default value for keep_settings + keep_settings=${keep_settings:-1} + + if command -v "opconf_conf_handler" >/dev/null 2>&1; then + opconf_conf_handler "${keep_settings:+-k} ${keep_settings}" "${keep_opconf:+-o} ${keep_opconf}" "${config_scope:+-s} ${config_scope}" fi ret=0 + if [ "${keep_settings}" -eq "1" ] && [ "${config_scope}" = "All" ]; then + if [ -z "$UPGRADE_BACKUP" ]; then + UPGRADE_BACKUP=/tmp/sysupgrade.tgz + fi - sysupgrade -b "$UPGRADE_BACKUP" || ret=1 - - if [ "$ret" -eq 0 ]; then - if command -v platform_copy_config >/dev/null 2>&1; then - platform_copy_config 1>&2 || ret=1 - else - ret=1 + sysupgrade -b "$UPGRADE_BACKUP" || ret=1 + if [ "$ret" -eq 0 ]; then + if command -v platform_copy_config >/dev/null 2>&1; then + platform_copy_config 1>&2 || ret=1 + else + ret=1 + fi fi fi @@ -157,6 +170,8 @@ case "$1" in json_get_var auto_activate auto_activate json_get_var bank bank json_get_var keep_settings keep_settings + json_get_var keep_opconf keep_opconf + json_get_var config_scope config_scope ret=0 @@ -195,8 +210,20 @@ case "$1" in # Set the flag to do not save configuration over reflash if [ "${keep_settings}" -eq 0 ]; then sysupgrade_flag="${sysupgrade_flag} -n" + elif [ "${keep_settings}" -eq 1 ]; then + if [ "${config_scope}" != "All" ]; then + sysupgrade_flag="${sysupgrade_flag} -n" + fi fi + if command -v "opconf_conf_handler" >/dev/null 2>&1; then + arg="" + [ -n "${keep_settings}" ] && arg="-k ${keep_settings}" + [ -n "${keep_opconf}" ] && arg="${arg} -o ${keep_opconf}" + [ -n "${config_scope}" ] && arg="${arg} -s ${config_scope}" + + opconf_conf_handler "${arg}" + fi # Call sysupgrade synchonously. It should not time out the ubus call, # as it will just verify the image and do an ubus call, leading to # do_stage2 doing the actual upgrade.