Script and button issues - startup and reset button appear to be ignored

I am unable to run some scripts or to use the reset button to turn on and off the wifi, maybe more. I think I may have disabled something, but unclear what.

I have be testing out some different scripts for addressing the issues with an unavailable WWAN hanging up the WLAN.

I loaded this piece of code which deletes the STAtion from the wireless (STAtion reset). OpenWrt Forum Archive It works great. I have tested it as part of rc.local (startup) and as a function tied to the reset button. I preferred it the later way, as if I have a working STAtion I do not need to reconfigure things on every boot. I changed the times so as not to accidentally reset the device to factory.

I then tested this piece of code called autowan.sh. OpenWrt Forum Archive Could not get it to work. It uses a cron job.

Finally, I tested this piece of code, (wifimgr) OpenWrt Forum Archive and it’s where I think my problem began. It uses a list of defined SSIDs and keys to populate the STAtions. Great idea. Unfortunately I think it is missing some logic to actually check that the entry it’s changing is a STAtion. It just changes the first wifi-iface, which after using the first tool is the LAN not the WAN.

OK, so to configure this one places some code in the user/bin, etc/init.d and a new folder etc/wifimgr (list of stations). I set some permissions and start the tool

chmod 777 /usr/bin/wifiMgr.sh
chmod 777 /etc/init.d/wifiMgr
chmod 777 /etc/wifiMgr
chmod 777 /etc/wifiMgr/config
/etc/init.d/wifiMgr enable
/etc/init.d/wifiMgr start

So long story short, I could not stop it with /etc/init.d/wifimgr stop or disable (don’t have the error messages). I ended up having to go in through WinSCP and just renaming the files and reboot to make it quit. I think it mostly works, but not fully works, but that’s another post.

I tried to run the “STAtion reset” from the button yesterday, and it would not work. I have removed all the other code. The router seems to generally work, but I am not able to get either of the first 2 reset actions to work (see reset_modified_wcode). Have not tried the third, as I do not wish to reset the entire device. I tried having this to call a function in user/bin with no luck (also worked in the past). I have also copied the code into the Startup section below the GLI code (see startup). This worked fine before, but is not executed on reboot now. The wireless off/on function on the button does not appear to work either, which is why I am inclined to think it’s something other than these scripts. Not sure how to test or validate the other GLI startup scripts are working. I do not know if anything else is NOT working.

Any help is appreciated. I can run CLI commands, just not a clue as to what???

These scripts relate to these other posts on the forum, but once I get things sorted I will post another thread on what ever above works.
http://www.gl-inet.com/forums/topic/potential-rc-button-script-improvement/

1 Like

Well, the system does not like files with no extension, so I have renames my files with txt extensions, but they were set as linux format (no cr)/.

For the reset button script, you have error in your script. It is marked below. There is extra “fi” that should be removed.

if [ "$mode" = "sta" ]; then
        uci delete wireless.@wifi-iface[1]
        uci commit wireless
        uci commit network
        wifi
fi
elif [ "$SEEN" -gt 30 ]
then                                       
        echo "FACTORY RESET" > /dev/console
        /usr/bin/flashleds &
        jffs2reset -y && reboot &          
fi    

For the startup.txt, I don't know what is it. Is it rc.local?


For /etc/init.d/wifiMgr, I don't have your code. The format of this file should be similar as others ones. Just check the others to find out what is there. It should include one other script and have hooks, e.g. start, stop etc. Otherwise it doesn't work as expected.

Hi

Thanks for the review of the code. I removed the redundant “fi”, but it does not change anything. As written, would the code have just NOT executed the third action (after the end statement)?

Yes, the startup is what I added to the rc.local or Luci Startup and looks like below. I have just ried this with and without the “FI” at the end and neither works. Is there some way I can tell if the rest of the code in startup is working?

#/usr/bin/adblock &
/usr/bin/glautoupdater &

Start Tethering

/usr/sbin/usbmuxd

Wireless Reset

Removes the WWAN Connection on boot

mode=$(uci -q get wireless.@wifi-iface[1].mode)
if [ “$mode” = “sta” ]; then
uci delete wireless.@wifi-iface[1]
uci commit wireless
uci commit network
wifi
fi

exit 0

I don’t see other problems. You can try to debug by adding “echo “some message” > /dev/console” to your codes

One thing you need to make sure /etc/rc.button/reset needs to be execute as well.

chmod +x /etc/rc.button/reset

thanks, reset is 0755, so I think that’s covered.

Should the code “<span style=“color: #000000; font-family: monospace, serif; font-size: 14px; line-height: normal; white-space: pre-wrap; background-color: #f9f9f9;”>echo “some message” > /dev/console”</span> show the message in the System Log?

Can I send it to a file “<span style=“color: #000000; font-family: monospace, serif; font-size: 14px; line-height: normal; white-space: pre-wrap; background-color: #f9f9f9;”>echo “some message” > /tmp/startup.log”</span> Not sure this says write a file?

Yes,

echo “some message” > /tmp/startup.log

is a better way.

thanks, is there an append so I can send multiple events\messages to the same log?

echo “some message” > /tmp/startup.log /append

O. Yes, use >> for append. If not existed, the file will be created automatically.

echo “some message” >>/tmp/startup.log

 

Some note on using the crontab:

OpenWRT does not automatically install the the crontab as a service.
To solve this, execute the following commands:

/etc/init.d/cron start
/etc/init.d/cron enable

 

After that you will be able to let the change you made with “crontab -e” take effect.