Posted: Sun Jan 16, 2011 10:11 Post subject: Asus RT-N16 - lost all settings!
My router suddenly and inexplicably lost all it's settings. When looking in the GUI all setting was as factory default. Fortunately I have the backup/restore scripts so easy to get all settings back. But this has never happened before.
Has anyone else had this problem?
Posted: Sun Jan 16, 2011 15:27 Post subject: Re: Asus RT-N16 - lost all settings!
wabe wrote:
My router suddenly and inexplicably lost all it's settings. When looking in the GUI all setting was as factory default. Fortunately I have the backup/restore scripts so easy to get all settings back. But this has never happened before.
Has anyone else had this problem?
It's even quite likely to happen if you flash your rom without doing a factory reset.
I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.
wl_ssid=`nvram get wl_ssid`
lan_ipaddr=`nvram get lan_ipaddr`
if [ ! -f "${restflag}" ] && [ "${lan_ipaddr}" = '192.168.1.1' ] && [ "${wl_ssid}" = 'dd-wrt' ] ; then
optlog $NAME "Detected a firmware reset"
lastbackup="`ls -1t /opt/var/backups/*.minimal.sh | head -n1`"
touch "${restflag}"
if [ -z "${lastbackup}" ] ; then
optlog $NAME "Unable to find a backup, will restore some handpicked settings"
nvram set wl_ssid="JP-spot"
nvram set wl0_ssid="JP-spot"
nvram set wl_channel="10"
nvram set wl0_channel="10"
nvram set wl0_wds1_if="wds0.1"
nvram set wl0_wds1_hwaddr="00:26:18:A1:3C:98"
nvram set wl0_wds1_enable="3"
nvram set wl0_wds1_desc="00:26:18:A1:3C:98"
nvram set wan_hostname="WAN"
nvram set wan_domain="mirmana.com"
nvram set usb_storage="1"
nvram set usb_usb2="1"
nvram set usb_mntpoint="opt"
nvram set usb_automnt="1"
nvram set sshd_wanport="53022"
nvram set sshd_enable="1"
nvram set remote_mgt_ssh="1"
nvram set remote_management="1"
nvram set http_wanport="53080"
nvram set http_passwd="\$1\$yctsdBGX\$va20aPWWw.SBqYeSrbEfk20"
nvram set lan_ipaddr="192.168.10.1"
nvram set lan_domain="mirmana.com"
nvram commit
else
optlog $NAME "Restore settings using ${lastbackup}"
${lastbackup}
fi
optlog $NAME "Reboot"
reboot
else
rm -f "${restflag}" 2>/dev/null
fi
_________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
Joined: 18 Oct 2007 Posts: 385 Location: Grecia, Costa Rica
Posted: Sun Jan 16, 2011 16:05 Post subject: Re: Asus RT-N16 - lost all settings!
frater wrote:
I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.
I have a question. I know the script is tailored for your setup and needs to be personally configured for others, but what creates the lastbackup? I have none in /opt/var/backups.
edit: I just did a bit of poking around and found /opt/usr/sbin/backupessential. I suppose you run this via a cron job correct?
Posted: Sun Jan 16, 2011 16:48 Post subject: Re: Asus RT-N16 - lost all settings!
frater wrote:
I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.
That's a great solution! I don't know all that much about scripting but I assume the code you publish is supposed to go into the file "S00factdefault".
A couple of questions:
- Why do you use the "minimal" version of the the backup and not "essential"? - haven't studied the difference between these two files but always use the essential one when upgrading the ROM
- Do you run this script as a cron job?
- How do you enable usb if the router is in the "factory reset" state - usb is then disabled
Posted: Sun Jan 16, 2011 16:58 Post subject: Re: Asus RT-N16 - lost all settings!
Dark_Shadow wrote:
frater wrote:
I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.
Is this part of OTRW? If so I will update.
Just do this...
Code:
wget -O /opt/etc/init.d/S00factdefault http://wd.mirmana.com/S00factdefault
vi /opt/etc/init.d/S00factdefault
chmod +x /opt/etc/init.d/S00factdefault
It isn't fully automatic, unless you have a firmware which has USB enabled by default and automount to /opt.
I asked Kong to publish such a firmware and this is what I have running on my WAN-router.
I wanted to wait until this feature became part of the original DD-WRT (the automount USB), but it seems the devs explicitly don't want that.
The service will be non-executable by default, of course. You also need to put in your own password. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
Posted: Sun Jan 16, 2011 17:06 Post subject: Re: Asus RT-N16 - lost all settings!
wabe wrote:
frater wrote:
I even wrote a script, so it will automagically restore its settings. It does need to have USB enabled for it to run.
That's a great solution! I don't know all that much about scripting but I assume the code you publish is supposed to go into the file "S00factdefault".
A couple of questions:
- Why do you use the "minimal" version of the the backup and not "essential"? - haven't studied the difference between these two files but always use the essential one when upgrading the ROM
As a safeguard, really.
2 months ago there was a version that would choke on the essential. It may have been that version of the flash. You can run essential afterwards. At least you will have access to your router again.
wabe wrote:
- Do you run this script as a cron job?
Yes, each night at 4. If the backup is the same as the last one, the oldest will get deleted.
Code:
# ls -altr /opt/var/backups/ | tail -n16
drwxr-xr-x 12 root root 4096 Jan 12 00:07 ..
-rwxr-xr-x 1 root root 31697 Jan 13 04:09 90E6BA2EE9F3.01132011.preferred.sh
-rwxr-xr-x 1 root root 9735 Jan 13 04:09 90E6BA2EE9F3.01132011.minimal.sh
-rwxr-xr-x 1 root root 40055 Jan 13 04:09 90E6BA2EE9F3.01132011.essential.sh
-rwxr-xr-x 1 root root 3783 Jan 13 04:09 90E6BA2EE9F3.01132011.dangerous.sh
-rwxr-xr-x 1 root root 43738 Jan 13 04:09 90E6BA2EE9F3.01132011.all.sh
-rwxr-xr-x 1 root root 28393 Jan 14 04:09 90E6BA2EE9F3.01142011.preferred.sh
-rwxr-xr-x 1 root root 36751 Jan 14 04:09 90E6BA2EE9F3.01142011.essential.sh
-rwxr-xr-x 1 root root 3817 Jan 14 04:09 90E6BA2EE9F3.01142011.dangerous.sh
-rwxr-xr-x 1 root root 40468 Jan 14 04:09 90E6BA2EE9F3.01142011.all.sh
-rwxr-xr-x 1 root root 28691 Jan 16 04:09 90E6BA2EE9F3.01162011.preferred.sh
-rwxr-xr-x 1 root root 9628 Jan 16 04:09 90E6BA2EE9F3.01162011.minimal.sh
-rwxr-xr-x 1 root root 37049 Jan 16 04:09 90E6BA2EE9F3.01162011.essential.sh
-rwxr-xr-x 1 root root 3783 Jan 16 04:09 90E6BA2EE9F3.01162011.dangerous.sh
-rwxr-xr-x 1 root root 40732 Jan 16 04:09 90E6BA2EE9F3.01162011.all.sh
drwxr-xr-x 2 root root 32768 Jan 16 04:09 .
wabe wrote:
- How do you enable usb if the router is in the "factory reset" state - usb is then disabled
On normal DD-WRT I would need to enable it with my Android phone.
Here I dared to test it (I'm quite #$% if I don't have access to the WAN-router). I just did a factory reset with the webif:
Code:
# grep -B3 -A2 factdefault /opt/var/log/messages
Jan 13 22:11:00 WAN optware.info K90swap: Managing swap partitions
Jan 13 22:11:00 WAN optware.info K90swap: Unmounted swap partition /dev/sda1
Jan 13 22:11:00 WAN optware.info K99optware: Optware shutdown finished
Jan 13 22:12:04 DD-WRT optware.info /opt/etc/init.d/S00factdefault: Detected a firmware reset
Jan 13 22:12:04 DD-WRT optware.info /opt/etc/init.d/S00factdefault: Restore settings using /opt/var/backups/90E6BA2EE9F3.01132011.minimal.sh
Jan 13 22:12:07 DD-WRT optware.info /opt/etc/init.d/S00factdefault: Reboot
Jan 13 22:12:40 WAN optware.info S00optware: Optware startup
Jan 13 22:12:40 WAN optware.info S01addusers: Adding users to /etc/passwd
It had a factory reset at 22:11 and the router was up and running at 22:13. How's that for automagic?
You may have noticed a file that it creates. It will prevent the router to cycle reboots. If that file is there, it will not restore the ROM another time. _________________ Asus RT16N + OTRW
Kingston 4GB USB-disk 128 MB swap + 1.4GB ext3 on /opt + 2 GB ext3 on /mnt
Copperjet 1616 modem in ZipB-config
Asterisk, pixelserv & Pound running on router
Another Asus RT16N as WDS-bridge
Posted: Mon Jan 17, 2011 9:39 Post subject: Re: Asus RT-N16 - lost all settings!
frater wrote:
It had a factory reset at 22:11 and the router was up and running at 22:13. How's that for automagic?
I'll try this one out tonight, should be easy to modify the script to suite my environment using the information in the "minimal" restore script. Thanks for the information!
Too bad that at least the standard Big/Mega version of DD-WRT cannot be delivered with USB-support and drive mounting enabled as default.
I'll test the "frater"-version of Kongs Mod which I assume you use.