fwbank: add copy_config method to fwbank API

Implemented copy_config handler to create and copy a system upgrade backup
This commit is contained in:
Dariusz Iwanoczko 2025-02-24 15:04:39 +01:00
parent 2a1323bfd0
commit b6e5749b7f

View file

@ -22,7 +22,7 @@ fwbank_get_bootbank() {
case "$1" in case "$1" in
list) list)
echo '{ "dump" : {}, "set_bootbank" : {"bank":32} , "upgrade": {"path":"String","auto_activate":true,"bank":32,"keep_settings":true}}' echo '{ "dump" : {}, "set_bootbank" : {"bank":32}, "copy_config" : {}, "upgrade": {"path":"String","auto_activate":true,"bank":32,"keep_settings":true}}'
;; ;;
call) call)
case "$2" in case "$2" in
@ -124,6 +124,29 @@ case "$1" in
echo '{"success": false}' echo '{"success": false}'
fi fi
;; ;;
copy_config)
if [ -z "$UPGRADE_BACKUP" ]; then
UPGRADE_BACKUP=/tmp/sysupgrade.tgz
fi
ret=0
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
if [ "$ret" -eq 0 ]; then
echo '{"success": true}'
else
echo '{"success": false}'
fi
;;
upgrade) upgrade)
# Read the JSON object provided for the arguments # Read the JSON object provided for the arguments
read -r input read -r input