2 # Copyright (C) 2014-2016 OpenWrt.org
3 # Copyright (C) 2016 LEDE-Project.org
6 preinit_mount_syscfg() {
11 linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
13 syscfg_part=$(grep syscfg /proc/mtd |cut -c4)
14 ubiattach -m $syscfg_part || needs_recovery=1
15 if [ $needs_recovery -eq 1 ]
17 echo "ubifs syscfg partition is damaged, reformatting"
18 ubidetach -m $syscfg_part
19 ubiformat -y -O 2048 -q /dev/mtd$syscfg_part
20 ubiattach -m $syscfg_part
21 ubimkvol /dev/ubi1 -n 0 -N syscfg -t dynamic --maxavsize
24 mount -t ubifs ubi1:syscfg /tmp/syscfg
25 [ -f /tmp/syscfg/sysupgrade.tgz ] && {
26 echo "- config restore -"
28 mv /tmp/syscfg/sysupgrade.tgz /tmp
29 tar xzf /tmp/sysupgrade.tgz
30 rm -f /tmp/sysupgrade.tgz
37 boot_hook_add preinit_main preinit_mount_syscfg