| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- # Copyright (C) 2014 OpenWrt.org
- move_config() {
- . /lib/upgrade/common.sh
- local device="$1"
- local fstype="$2"
- [ -n "$device" ] && [ -b "$device" ] && {
- mount -t "${fstype}" "$device" /mnt
- [ -f "/mnt/$BACKUP_FILE" ] && mv -f "/mnt/$BACKUP_FILE" /
- umount /mnt
- }
- }
- octeon_get_n821_disk() {
- local partnum=$1
- local MAJOR MINOR DEVNAME DEVTYPE
- while read line; do
- export -n "${line}"
- done < $(find /sys/bus/platform/devices/16f0000000000.ehci/ -path \*block/sd[a-z]/uevent)
- echo "/dev/${DEVNAME}${partnum}"
- }
- octeon_move_config() {
- . /lib/functions.sh
- case "$(board_name)" in
- ubnt,erlite|\
- ubnt,usg)
- move_config "/dev/sda1" "vfat"
- ;;
- itus,shield-router)
- move_config "/dev/mmcblk1p1" "vfat"
- ;;
- er|\
- ubnt,edgerouter-4|\
- ubnt,edgerouter-6p)
- move_config "/dev/mmcblk0p1" "vfat"
- ;;
- cisco,vedge1000)
- # Copy from the internal USB disk's first partition.
- # It is resolved from the device path to not be dependent on which
- # /dev/sd? path it is at, nor which UUID it happens to have.
- move_config "$(octeon_get_n821_disk 1)" "ext2"
- ;;
- esac
- }
- boot_hook_add preinit_mount_root octeon_move_config
|