OpenWrt Forum Archive

Topic: NVRAM set

The content of this topic has been archived on 25 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hi people, i have the following  code

#!/bin/sh
# Cisco Button
if [ $BUTTON = "ses" -a $ACTION = "released" ]
then
        echo "f" > /proc/diag/led/ses_white

        if [ "$(nvram get wl0_radio)" = "0" ]
        then
                logger -t wifi "Activating wi-fi"
                nvram set wl0_radio=1
                wifi
        else
                logger -t wifi "Activating wi-fi"
                nvram set wl0_radio=0
                wifi
        fi
        sleep 1
        echo "0" > /proc/diag/led/ses_white
        echo "1" > /proc/diag/led/power

fi

But when I reboot the wl0_radio is always on, any one have a idea what i did wrong?
May exist other script that tuns on wl0_radio,

When you boot, the contents of nvram are copied from flash to ram; all the nvram get/set commands use the copy stored in ram. When you do an "nvram commit" it copies the nvram contents from ram back to flash.

If you don't commit the changes back to flash, the next boot will just load the old settings from flash.

I'd suggest not using nvram commit any more than required since there are limits on how many times you can write to the flash.

Thanks for the info

The discussion might have continued from here.