81_linksys_syscfg 990 B

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