Permanently store script in /etc/config for WIFI SES/WPS

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Author Message
matth::
DD-WRT Novice


Joined: 13 Sep 2017
Posts: 29

PostPosted: Wed May 16, 2018 17:23    Post subject: Permanently store script in /etc/config for WIFI SES/WPS Reply with quote
Hello folks,

I need your help for my little project.

I wrote a script to turn/toggle on/off wifi on my WRT3200ACM. The script is working until I store it in a folder the system is reading while pressing the SES/AOSS/EZ-SETUP button (the system will look for ".sesbutton" files).

Folders as follows:
/etc/config/
/jffs/etc/config/
/mmc/etc/config/
/tmp/etc/config/

The only folder I can write into/have permissions to write is tmp folder. Since this is a temporary folder the script will be deleted after every reboot.

Did anyone has an idea how to write into the /etc/config or any other of the mentioned folders?

Thank you for your help in advance.

You can take a look at my script on here: https://www.dd-wrt.com/phpBB2/viewtopic.php?p=1128552&highlight=#1128552

Best,
Mike


Sources for my scripts:
https://www.dd-wrt.com/wiki/index.php/Script_Execution

_________________
Router: Linksys WRT3200ACM (DD-WRT enabled)
Sponsor
matth::
DD-WRT Novice


Joined: 13 Sep 2017
Posts: 29

PostPosted: Wed May 16, 2018 21:25    Post subject: Reply with quote
**Edit**

I temporarily discovered a workaround.

Type this in Administration -> Startup

Code:

mkdir /tmp/etc/config
cat <<EOF >/tmp/etc/config/wifi.sesbutton
#!/bin/sh

if [ "`nvram get ath0_net_mode`" = "disabled" ]

   then    stopservice lan

         nvram set ath0_net_mode=acn-mixed

         nvram set ath1_net_mode=ng-only

         startservice lan

      else    stopservice wland

            nvram set ath0_net_mode=disabled

            ifconfig ath0 down

            nvram set ath1_net_mode=disabled

            ifconfig ath1 down

            killall hostapd



fi

EOF

chmod +x /tmp/etc/config/wifi.sesbutton


_________________
Router: Linksys WRT3200ACM (DD-WRT enabled)
d0ug
DD-WRT User


Joined: 31 Jul 2015
Posts: 461

PostPosted: Thu May 17, 2018 0:42    Post subject: Reply with quote
These newer WRT routers have plenty of spare flash to format the /jffs partition. youll probably endup with about 28MB of usable space. That is what I get on my WRT1200AC v2

Once you have /jffs setup you have persistent on router storage that will last between reboots and flashes. Bear in mind this is the non replaceable on board flash. You do not want something running from here that is going to be constantly writing to /jffs else youll wear down the flash memory, but storing scripts or config files here is no problem

You enable /jffs on the administration/management tab




Another bonus if you have a NAS, or windows box that stays up all the time, mount your CIFS storage to an SMB share. This is what I have done in my case. I have nightly cron jobs that run on the router to backup the router NVRAM, Traffic data, and the /jffs storage. Also added a seperate weekly nvram backup, for those times you make a config change and discover days later something isn't right.

Replace <routerusername> <routerpassword> <routerip> with values appropriate to your config.

0 3 * * * root cp -r /jffs /tmp/mnt/smbshare/RouterAP/JFFS2Bkup/
0 3 * * * root wget http://<routerusername>:<routerpassword>@<routerip>/nvrambak.bin -O /tmp/mnt/smbshare/RouterAP/RouterAP-nvrambak.bin
0 3 * * * root wget http://<routerusername>:<routerpassword>@<routerip>/traffdata.bak -O /tmp/mnt/smbshare/RouterAP/RouterAP-traffdata.bak
3 3 * * 1 root cp /tmp/mnt/smbshare/RouterAP/RouterAP-nvrambak.bin /tmp/mnt/smbshare/RouterAP/Weekly-RouterAP-nvrambak.bin
matth::
DD-WRT Novice


Joined: 13 Sep 2017
Posts: 29

PostPosted: Thu May 17, 2018 15:51    Post subject: Reply with quote
Hi d0ug,

Thank you for you very useful hint.

I tried this out and now I have permanent storage to store my WIFI script.

It is working like charm.

69.44 MB of usable permanently storage.

Thumbs up!

Best,
Mike

_________________
Router: Linksys WRT3200ACM (DD-WRT enabled)
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) 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 cannot attach files in this forum
You cannot download files in this forum