2014-07-13 22:12:56 +00:00
|
|
|
#
|
2016-10-13 10:52:20 +00:00
|
|
|
# Copyright (C) 2014-2016 OpenWrt.org
|
|
|
|
# Copyright (C) 2016 LEDE-Project.org
|
2014-07-13 22:12:56 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
preinit_mount_syscfg() {
|
|
|
|
|
|
|
|
. /lib/functions.sh
|
|
|
|
|
2017-05-12 20:36:07 +00:00
|
|
|
case $(board_name) in
|
2016-10-13 10:52:20 +00:00
|
|
|
armada-385-linksys-caiman|armada-385-linksys-cobra|armada-385-linksys-rango|armada-385-linksys-shelby|armada-xp-linksys-mamba)
|
2015-04-12 08:35:33 +00:00
|
|
|
needs_recovery=0
|
2016-10-13 10:52:20 +00:00
|
|
|
syscfg_part=$(grep syscfg /proc/mtd |cut -c4)
|
|
|
|
ubiattach -m $syscfg_part || needs_recovery=1
|
2015-04-12 08:35:33 +00:00
|
|
|
if [ $needs_recovery -eq 1 ]
|
|
|
|
then
|
|
|
|
echo "ubifs syscfg partition is damaged, reformatting"
|
2016-10-13 10:52:20 +00:00
|
|
|
ubidetach -m $syscfg_part
|
|
|
|
ubiformat -y -O 2048 -q /dev/mtd$syscfg_part
|
|
|
|
ubiattach -m $syscfg_part
|
2015-04-12 08:35:33 +00:00
|
|
|
ubimkvol /dev/ubi1 -n 0 -N syscfg -t dynamic --maxavsize
|
|
|
|
fi
|
2014-07-13 22:12:56 +00:00
|
|
|
mkdir /tmp/syscfg
|
|
|
|
mount -t ubifs ubi1:syscfg /tmp/syscfg
|
|
|
|
[ -f /tmp/syscfg/sysupgrade.tgz ] && {
|
|
|
|
echo "- config restore -"
|
|
|
|
cd /
|
|
|
|
mv /tmp/syscfg/sysupgrade.tgz /tmp
|
|
|
|
tar xzf /tmp/sysupgrade.tgz
|
|
|
|
rm -f /tmp/sysupgrade.tgz
|
|
|
|
sync
|
|
|
|
}
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_hook_add preinit_main preinit_mount_syscfg
|