81_linksys_syscfg 952 B

12345678910111213141516171819202122232425262728293031323334353637
  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/upgrade/common.sh
  8. case $(board_name) in
  9. linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
  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/$BACKUP_FILE" ] && {
  24. echo "- config restore -"
  25. cd /
  26. mv "/tmp/syscfg/$BACKUP_FILE" /tmp
  27. tar xzf "/tmp/$BACKUP_FILE"
  28. rm -f "/tmp/$BACKUP_FILE"
  29. sync
  30. }
  31. ;;
  32. esac
  33. }
  34. boot_hook_add preinit_main preinit_mount_syscfg