2
0

79_move_config 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # Copyright (C) 2014 OpenWrt.org
  2. move_config() {
  3. . /lib/upgrade/common.sh
  4. local device="$1"
  5. local fstype="$2"
  6. [ -n "$device" ] && [ -b "$device" ] && {
  7. mount -t "${fstype}" "$device" /mnt
  8. [ -f "/mnt/$BACKUP_FILE" ] && mv -f "/mnt/$BACKUP_FILE" /
  9. umount /mnt
  10. }
  11. }
  12. octeon_get_n821_disk() {
  13. local partnum=$1
  14. local MAJOR MINOR DEVNAME DEVTYPE
  15. while read line; do
  16. export -n "${line}"
  17. done < $(find /sys/bus/platform/devices/16f0000000000.ehci/ -path \*block/sd[a-z]/uevent)
  18. echo "/dev/${DEVNAME}${partnum}"
  19. }
  20. octeon_move_config() {
  21. . /lib/functions.sh
  22. case "$(board_name)" in
  23. ubnt,erlite|\
  24. ubnt,usg)
  25. move_config "/dev/sda1" "vfat"
  26. ;;
  27. itus,shield-router)
  28. move_config "/dev/mmcblk1p1" "vfat"
  29. ;;
  30. er|\
  31. ubnt,edgerouter-4|\
  32. ubnt,edgerouter-6p)
  33. move_config "/dev/mmcblk0p1" "vfat"
  34. ;;
  35. cisco,vedge1000)
  36. # Copy from the internal USB disk's first partition.
  37. # It is resolved from the device path to not be dependent on which
  38. # /dev/sd? path it is at, nor which UUID it happens to have.
  39. move_config "$(octeon_get_n821_disk 1)" "ext2"
  40. ;;
  41. esac
  42. }
  43. boot_hook_add preinit_mount_root octeon_move_config