root@OpenWrt:~# cat /etc/init.d/unbrick
#!/bin/sh /etc/rc.common
START=20
bakcat() {
for i in $* ; do
echo "################file seperator for $i##################"
cat $i
echo
done
}
revert() {
echo revert config...
bakcat /etc/config/* >/root/cfgbak.all 2>&1
cp -R /root/cfgbak/* /etc/config/
}
start() {
count=$(cat /root/count_file)
if [ $count -eq 0 ] ; then
revert
fi
count=$((count-1))
echo $count > /root/count_file
}
root@OpenWrt:~# /etc/init.d/unbrick enable
root@OpenWrt:~# echo 3 > /root/count_file
root@OpenWrt:~# mkdir /root/cfgbak |
before modifying files in /etc/config, put an usable copy in /root/cfgbak.
if the script can run perfectly, echo 3 > /root/count_file after every reboot.
disable this script if the config files are valid and need no more change.
if any config file is wrong, reboot 3 times to unblick.