aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/octeon/base-files/lib
diff options
context:
space:
mode:
authorRoman Kuzmitskii <damex.pp@icloud.com>2020-10-22 18:31:07 +0000
committerAdrian Schmutzler <freifunk@adrianschmutzler.de>2020-10-26 21:07:22 +0100
commit733700c652d37ca4c26f623d2a71337147af395d (patch)
tree955af7dcec274f65325496935cad7369aa53f7cb /target/linux/octeon/base-files/lib
parentd7db32440fd5d5eee015896ec19e583513bb9bae (diff)
downloadupstream-733700c652d37ca4c26f623d2a71337147af395d.tar.gz
upstream-733700c652d37ca4c26f623d2a71337147af395d.tar.bz2
upstream-733700c652d37ca4c26f623d2a71337147af395d.zip
octeon: use dedicated function to move config backup
All octeon devices use the same or a very similar way to backup and restore configuration. We expect to have more devices added and in order to stop repeating ourselves move the logic to a separate function. While at it, add a few checks. Signed-off-by: Roman Kuzmitskii <damex.pp@icloud.com> [commit message facelift] Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Diffstat (limited to 'target/linux/octeon/base-files/lib')
-rw-r--r--target/linux/octeon/base-files/lib/preinit/79_move_config22
1 files changed, 14 insertions, 8 deletions
diff --git a/target/linux/octeon/base-files/lib/preinit/79_move_config b/target/linux/octeon/base-files/lib/preinit/79_move_config
index fd780a9461..086f7c62e2 100644
--- a/target/linux/octeon/base-files/lib/preinit/79_move_config
+++ b/target/linux/octeon/base-files/lib/preinit/79_move_config
@@ -1,21 +1,27 @@
# Copyright (C) 2014 OpenWrt.org
move_config() {
- . /lib/functions.sh
. /lib/upgrade/common.sh
+ local device="$1"
+ [ -n "$device" ] && [ -b "$device" ] && {
+ mount -t vfat "$device" /mnt
+ [ -f "/mnt/$BACKUP_FILE" ] && mv -f "/mnt/$BACKUP_FILE" /
+ umount /mnt
+ }
+}
+
+octeon_move_config() {
+ . /lib/functions.sh
+
case "$(board_name)" in
erlite)
- mount -t vfat /dev/sda1 /mnt
- [ -f "/mnt/$BACKUP_FILE" ] && mv -f "/mnt/$BACKUP_FILE" /
- umount /mnt
+ move_config "/dev/sda1"
;;
itus,shield-router)
- mount -t vfat /dev/mmcblk1p1 /mnt
- [ -f "/mnt/$BACKUP_FILE" ] && mv -f "/mnt/$BACKUP_FILE" /
- umount /mnt
+ move_config "/dev/mmcblk1p1"
;;
esac
}
-boot_hook_add preinit_mount_root move_config
+boot_hook_add preinit_mount_root octeon_move_config