Initswitch causing problems or

First off I’ve got to say the ar750 is a phenomenal product with a wonderful community and awesome support. But… @alzhao or any other gli support:

I’ve been playing around with this and loving it, but i noticed a problem with the initswitch script. If i have it set to vpn it causes the vpn to start with two separate pids. So i looked into the file and i noticed it has built in logic, it just needs to be applied in another place as well. How could i modify the initswitch script to check the $LOCK file before starting the vpn, and skipping starting it if it’s the first run?. I know how to do it in theory, but in practice I’m a little rusty on the command line… Thanks

Edit:
Would a simple ifdown vpn command added into the startvpn script fix my issue? Or would killall vpn command added work better instead? Or would we need to do kill -9 $(cat /var/run/ovpn_client.pid) >/dev/null 2>&1. Or just startvpn stop at the beginning of the startvpn script? Or am i just trying to over simplify things?

I guess i settled on a solution to try. Going to change these lines in initswitch file:

And I’ll let everyone know how things work out in a bit.

Last edit:
@alzhao

So changing this portion of the initswitch script does fix the problem of the vpn starting under two different instances and everything now works properly, includung the up/downdns scripts. Please look into adding this into the next update. Even tho other people may not realize they’re being affected this could fix some issues for other people as well.

Thanks to everyone who has contributed to this forum, I’ve learned a lot.

thanks very much for your script. We will have a check and fix the firmware.

@Exile1975 could you wrap that code in a code block so that the forum doesn’t eat parts of your code?
In the editor its called “Preformatted text”, 6th icon.

Turns out I was a little early saying all was fixed. What i did also caused the switch to NOT turn the vpn back on if you turned it off and on without a reboot. I’m uploading a zip with my new fix. Tested for a few days and now the switch turns off and on, and doesn’t start the vpn twice. @Johnexinitswitch-test.zip (741 Bytes)

Came across this myself the other day. The issue is that on boot both /etc/init.d/startvpn and /etc/init.d/initswitch are enabled and run at boot time.

I wanted the to use the switch to control vpn so I just disabled the startvpn script:
/etc/init.d/startvpn disable

Hint: you can tell what is enabled by looking at contents of /etc/rc.d