set nvram settings after reset

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware
Author Message
lamelogin
DD-WRT Novice


Joined: 18 Sep 2010
Posts: 25

PostPosted: Fri May 24, 2019 21:33    Post subject: set nvram settings after reset Reply with quote
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
Sponsor
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Broadcom SoC based Hardware All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum