lamelogin DD-WRT Novice
Joined: 18 Sep 2010 Posts: 25
|
Posted: Fri May 24, 2019 21:33 Post subject: set nvram settings after reset |
|
I've been on a mission to try and move as much of the configuration away from point and click webUI, here is my attempt to query/set nvram settings and share with everyone. I wish there was a way to do this w/o having to use a thick bash binary.
Note: should be used sparingly as I bet most of these have unmapped dependencies.
Code: |
root@localhost:/opt/etc/init.d# cat S02nvram
#!/opt/bin/bash
# set -x
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
start() {
COMMIT=0
declare -A setnvram=(
[no_crossdetect]="1"
[time_zone]="US/Central"
)
for item in "${!setnvram[@]}"; do
temp=` nvram get ${item} `
if [ ${#temp} -eq 0 ]; then
nvram set ${item}="${setnvram[${item}]}"
COMMIT=1
else
if [ ${temp} != ${setnvram[${item}]} ]; then
nvram set ${item}="${setnvram[${item}]}"
COMMIT=1
fi
fi
# echo "${item} is ${setnvram[${item}]}"
done
if [ "${COMMIT}x" == "1x" ]; then
nvram commit
fi
return 0
}
stop() {
return 0
}
##########################start here##########################
case "$1" in
stop)
stop
;;
restart|start)
stop
sleep 2
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit
|
|
|