81_linksys_syscfg 952 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #
  2. # Copyright (C) 2014-2016 OpenWrt.org
  3. #
  4. preinit_mount_syscfg() {
  5. . /lib/functions.sh
  6. . /lib/mvebu.sh
  7. case $(mvebu_board_name) in
  8. armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-rango|armada-385-linksys-shelby|armada-xp-linksys-mamba)
  9. needs_recovery=0
  10. syscfg_part=$(grep syscfg /proc/mtd |cut -c4)
  11. ubiattach -m $syscfg_part || needs_recovery=1
  12. if [ $needs_recovery -eq 1 ]
  13. then
  14. echo "ubifs syscfg partition is damaged, reformatting"
  15. ubidetach -m $syscfg_part
  16. ubiformat -y -O 2048 -q /dev/mtd$syscfg_part
  17. ubiattach -m $syscfg_part
  18. ubimkvol /dev/ubi1 -n 0 -N syscfg -t dynamic --maxavsize
  19. fi
  20. mkdir /tmp/syscfg
  21. mount -t ubifs ubi1:syscfg /tmp/syscfg
  22. [ -f /tmp/syscfg/sysupgrade.tgz ] && {
  23. echo "- config restore -"
  24. cd /
  25. mv /tmp/syscfg/sysupgrade.tgz /tmp
  26. tar xzf /tmp/sysupgrade.tgz
  27. rm -f /tmp/sysupgrade.tgz
  28. sync
  29. }
  30. ;;
  31. esac
  32. }
  33. boot_hook_add preinit_main preinit_mount_syscfg