sysmngr: align with opconf

This commit is contained in:
Vivek Kumar Dutta 2025-10-30 16:18:32 +05:30
parent 31cd59b33c
commit c153911acf
No known key found for this signature in database
GPG key ID: 4E09F5AD8265FD4C
2 changed files with 39 additions and 12 deletions

View file

@ -5,13 +5,13 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=sysmngr PKG_NAME:=sysmngr
PKG_VERSION:=1.0.31 PKG_VERSION:=1.1.0
LOCAL_DEV:=0 LOCAL_DEV:=0
ifneq ($(LOCAL_DEV),1) ifneq ($(LOCAL_DEV),1)
PKG_SOURCE_PROTO:=git PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://dev.iopsys.eu/system/sysmngr.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_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
PKG_MIRROR_HASH:=skip PKG_MIRROR_HASH:=skip
endif endif

View file

@ -22,7 +22,7 @@ fwbank_get_bootbank() {
case "$1" in case "$1" in
list) 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) call)
case "$2" in case "$2" in
@ -125,14 +125,26 @@ case "$1" in
fi fi
;; ;;
copy_config) copy_config)
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 if [ -z "$UPGRADE_BACKUP" ]; then
UPGRADE_BACKUP=/tmp/sysupgrade.tgz UPGRADE_BACKUP=/tmp/sysupgrade.tgz
fi fi
ret=0
sysupgrade -b "$UPGRADE_BACKUP" || ret=1 sysupgrade -b "$UPGRADE_BACKUP" || ret=1
if [ "$ret" -eq 0 ]; then if [ "$ret" -eq 0 ]; then
if command -v platform_copy_config >/dev/null 2>&1; then if command -v platform_copy_config >/dev/null 2>&1; then
platform_copy_config 1>&2 || ret=1 platform_copy_config 1>&2 || ret=1
@ -140,6 +152,7 @@ case "$1" in
ret=1 ret=1
fi fi
fi fi
fi
if [ "$ret" -eq 0 ]; then if [ "$ret" -eq 0 ]; then
echo '{"success": true}' echo '{"success": true}'
@ -157,6 +170,8 @@ case "$1" in
json_get_var auto_activate auto_activate json_get_var auto_activate auto_activate
json_get_var bank bank json_get_var bank bank
json_get_var keep_settings keep_settings json_get_var keep_settings keep_settings
json_get_var keep_opconf keep_opconf
json_get_var config_scope config_scope
ret=0 ret=0
@ -195,8 +210,20 @@ case "$1" in
# Set the flag to do not save configuration over reflash # Set the flag to do not save configuration over reflash
if [ "${keep_settings}" -eq 0 ]; then if [ "${keep_settings}" -eq 0 ]; then
sysupgrade_flag="${sysupgrade_flag} -n" sysupgrade_flag="${sysupgrade_flag} -n"
elif [ "${keep_settings}" -eq 1 ]; then
if [ "${config_scope}" != "All" ]; then
sysupgrade_flag="${sysupgrade_flag} -n"
fi
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, # 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 # as it will just verify the image and do an ubus call, leading to
# do_stage2 doing the actual upgrade. # do_stage2 doing the actual upgrade.