I know enough about linux to make me dangerous, I can figure out a few things here and there, so I thought I would throw this out and get others perspectives. Background: Router = Asus RT-N66U Firmware = Shibby 94.1 AIO test build External Storage = 2GB MicroSD card in onboard slot. I am using the backup settings script by Austin Saint Aubin The following script was written by frater for DD-WRT. I would like to convert any DD_WRT specific code to Tomato. It will reside in /opt/etc/config (Which opt is mounted already to a dir on the sd card) so as to get run on reboot. Now obviously I am going to have to change the location of the backup files. Note: Even though I have the /opt folder mounted, I do not have opt installed. Working Code Code: #!/bin/sh NAME=factdefault.sh NAME="$0" CUR_DIR="/mnt/MSD2GB/Scripts" restflag="${CUR_DIR}/just_restored" wl0_ssid=`nvram get wl0_ssid` lan_ipaddr=`nvram get lan_ipaddr` if [ ! -f "${restflag}" ] && [ "${lan_ipaddr}" = '192.168.1.1' ] && [ "${wl0_ssid}" = 'Tomato24' ] ; then logger $NAME "Detected a firmware reset" lastbackup="`ls -1t /tmp/mnt/MSD2GB/Tomato/Backups/lastbackup_*.sh | head -n1`" touch "${restflag}" if [ -z "${lastbackup}" ] ; then logger $NAME "Unable to find a backup, will restore some handpicked settings" nvram set "dhcpd_endip=192.168.10.249" nvram commit else logger $NAME "Restore settings using ${lastbackup}" ${lastbackup} fi logger $NAME "Reboot" reboot else rm -f "${restflag}" 2>/dev/null logger "factdefault.sh has nothing to do" fi I also added lines to Austins script to also place a copy of the filtered nvram file in the root of the backup dir. Code: backThisUp "NVRam Full List (Quote Filtered)" nvram quote "/tmp//mnt/MSD2GB/Tomato/Backups" "lastbackup" sh $NumOfBackupsToKeep "NC|clkfreq|ddnsx|dhcpd|dnsmasq_|ftp|http|lan_hostname|lan_ipaddr|lan_netmask|lan_proto|log|ntp|portforward|ppp|qos|rstats|sch|script|sesx|smbd|snmp|sshd|telnetd|tm|usb|vpn_server_|vpn_server1|wan_dns|wan_hostname|wan_proto|web|wl0_|wl1_" "Remove-NOTHING" chmod 755 /tmp//mnt/MSD2GB/Tomato/Backups/*.sh
Haven't tried this, but by inspection:- Tomato versions I know don't have "readlink", but I'm sure you can just manually set NAME and/or CUR_DIR to the fixed location you use (note factconfig is replaced by the command used to run the script) Not sure about wl_ssid, I think the primary ssid is wl0_ssid - is the default "wireless"? Replace "optlog" with "logger"
So, remove the line [ -h "${NAME}" ] && NAME="`readlink "${NAME}"`" and set CUR_DIR="`path of factconfig script"`" ? If i wanted to type "sh factdefault.sh" then "NAME=factdefault,sh"?
Ok this is what I got and it appears to do nothing, I first had CUR_DIR="`/mnt/MSD2GB/Scripts"`" but got line 4 permission denied so I changed it to line 4 below. Nothing in the syslog ether. Code: See first post for current codeset EDIT: ok I added logger "factdefault.sh has nothing to do" after rm -f "${restflag}" 2>/dev/null and it showed Jun 14 22:25:18 RT-N66U user.notice root: factdefault.sh has nothing to do. So thus far seems to be working. Now to tweak a bit further.
I try not to use the back-tick `do it` to execute commands because it is difficult to read/ differentiate from strong quotes 'do it', $(do it) seems easier, but then on BusyBox ash at least you do not need the curly brackets in ${lan_ipaddr}, $lan_ipaddr works just as well (there are some constructs that do need the {}). You are still looking for a default ssid of 'dd-wrt'. For script testing from console I should have advised "logger -s" which outputs messages to the console as well as into the message log.
I have updated the first post to reflect my current code. So should I remove all the back-tick's and curly brackets? I have found that shibby's default for wl0_ssid is Tomato24. I have also added the -s to logger so I don't have to keep opening the syslog.
It works as soon as USB and SD are enabled, I have a request into shibby to enable them by default and I need to tweak the line of Austin's script that filters the settings. Code in fist post is updated, should I change the title of the thread to something more relevant?