armsr: preserve configuration during sysupgrade

Copy configuration to boot partition (partition 1) instead of root
partition (partition 2) because the root partition is not writable if
it's a suqashfs image.
Move configuration back to root during preinit.

Fixes: https://github.com/openwrt/openwrt/issues/13695
Signed-off-by: Christian Buschau <cbuschau@d00t.de>
(cherry picked from commit 67ce60c5f9)
This commit is contained in:
Christian Buschau 2023-10-17 14:51:53 +02:00
parent 72f7f18d2b
commit c0c4a9bce4
No known key found for this signature in database
GPG Key ID: 74B8EC7053894AC4
2 changed files with 21 additions and 1 deletions

View File

@ -0,0 +1,19 @@
# SPDX-License-Identifier: GPL-2.0-only
move_config() {
local partdev parttype=ext4
. /lib/upgrade/common.sh
if export_bootdevice && export_partdevice partdev 1; then
part_magic_fat "/dev/$partdev" && parttype=vfat
if mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt; then
if [ -f "/mnt/$BACKUP_FILE" ]; then
mv -f "/mnt/$BACKUP_FILE" /
fi
umount /mnt
fi
fi
}
boot_hook_add preinit_mount_root move_config

View File

@ -36,7 +36,8 @@ platform_check_image() {
platform_copy_config() {
local partdev parttype=ext4
if export_partdevice partdev 2; then
if export_partdevice partdev 1; then
part_magic_fat "/dev/$partdev" && parttype=vfat
mount -t $parttype -o rw,noatime "/dev/$partdev" /mnt
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
umount /mnt