mvebu: add support for WRT32X (venom)
[openwrt/openwrt.git] / target / linux / mvebu / base-files / lib / preinit / 81_linksys_syscfg
1 #
2 # Copyright (C) 2014-2016 OpenWrt.org
3 # Copyright (C) 2016 LEDE-Project.org
4 #
5
6 preinit_mount_syscfg() {
7
8 . /lib/functions.sh
9
10 case $(board_name) in
11 armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-rango|armada-385-linksys-shelby|armada-385-linksys-venom|armada-xp-linksys-mamba)
12 needs_recovery=0
13 syscfg_part=$(grep syscfg /proc/mtd |cut -c4)
14 ubiattach -m $syscfg_part || needs_recovery=1
15 if [ $needs_recovery -eq 1 ]
16 then
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
22 fi
23 mkdir /tmp/syscfg
24 mount -t ubifs ubi1:syscfg /tmp/syscfg
25 [ -f /tmp/syscfg/sysupgrade.tgz ] && {
26 echo "- config restore -"
27 cd /
28 mv /tmp/syscfg/sysupgrade.tgz /tmp
29 tar xzf /tmp/sysupgrade.tgz
30 rm -f /tmp/sysupgrade.tgz
31 sync
32 }
33 ;;
34 esac
35 }
36
37 boot_hook_add preinit_main preinit_mount_syscfg