aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg')
-rw-r--r--target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg37
1 files changed, 37 insertions, 0 deletions
diff --git a/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg b/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg
new file mode 100644
index 0000000000..83448e5ace
--- /dev/null
+++ b/target/linux/mvebu/cortexa9/base-files/lib/preinit/81_linksys_syscfg
@@ -0,0 +1,37 @@
+#
+# Copyright (C) 2014-2016 OpenWrt.org
+# Copyright (C) 2016 LEDE-Project.org
+#
+
+preinit_mount_syscfg() {
+ . /lib/functions.sh
+ . /lib/upgrade/common.sh
+
+ case $(board_name) in
+ linksys,caiman|linksys,cobra|linksys,mamba|linksys,rango|linksys,shelby|linksys,venom)
+ needs_recovery=0
+ syscfg_part=$(grep syscfg /proc/mtd |cut -c4)
+ ubiattach -m $syscfg_part || needs_recovery=1
+ if [ $needs_recovery -eq 1 ]
+ then
+ echo "ubifs syscfg partition is damaged, reformatting"
+ ubidetach -m $syscfg_part
+ ubiformat -y -O 2048 -q /dev/mtd$syscfg_part
+ ubiattach -m $syscfg_part
+ ubimkvol /dev/ubi1 -n 0 -N syscfg -t dynamic --maxavsize
+ fi
+ mkdir /tmp/syscfg
+ mount -t ubifs ubi1:syscfg /tmp/syscfg
+ [ -f "/tmp/syscfg/$BACKUP_FILE" ] && {
+ echo "- config restore -"
+ cd /
+ mv "/tmp/syscfg/$BACKUP_FILE" /tmp
+ tar xzf "/tmp/$BACKUP_FILE"
+ rm -f "/tmp/$BACKUP_FILE"
+ sync
+ }
+ ;;
+ esac
+}
+
+boot_hook_add preinit_main preinit_mount_syscfg