[SOLVED] How to restart OpenVPN in a script?
-
@salvadordalisdad said in [SOLVED] How to restart OpenVPN in a script?:
@guardian
Hi Guardian,Thanks very much for the nudge, very much appreciated.
I will certainly give it a try.
I see that at the heart of your script is the "PHP playback service..." mechanism, which simply doesn't work on my instance.I'm using 2.5.2 (there have been no updates since), and when I run it (either from cron or SSH/CLI or console) it says "yup done that" but it simply hasn't - weird.
I am pretty sure it used to work on some 2.4.x version I ran a while ago, but I'm getting forgetful so maybe I imagined it ;-)
It's a fresh install of 2.5.2 on a vmware esxi 6.7 platform, and everything else works, so I'm pretty stumped to be quite honest.
Are you using 2.5.2 or the earlier stable 2.4.x release?
ThanksI'm running 2.5.2, and the script is working perfectly. My ISP was having some "issues" for about a week in December and this script did it's job very well... when the ISP connectivity issue killed the VPN connection, the script restarted everything and got it running again.
I see that at the heart of your script is the "PHP playback service..." mechanism, which simply doesn't work on my instance.
Do you know why it isn't working? I suspect that would lead you to the real trouble source. -
Thanks that's incredibly helpful.
So I added a simple cron job for today which just ran the "playback" bit regardless of whether it needed to or no. Didn't happen. VPNs start time was last week sometime.
I think it just confirms I need a fresh install again.
I will update once I've done so, ;-)
-
@salvadordalisdad said in [SOLVED] How to restart OpenVPN in a script?:
Thanks that's incredibly helpful.
So I added a simple cron job for today which just ran the "playback" bit regardless of whether it needed to or no. Didn't happen. VPNs start time was last week sometime.
I think it just confirms I need a fresh install again.
I will update once I've done so, ;-)
Might I suggest logging into the shell and running the commands manually. Create the restart statement, run it and make sure it's working. Then test your script manually to make sure that it is working. It took me several tries to get the syntax of the php statement correct, and debug the shell script. Nothing wrong with a fresh install, but you may not need it.
-
@guardian
I run the following in cron nightly. mainly so the exit node is a different city every day (LOL)./usr/local/sbin/pfSsh.php playback svc restart openvpn client 1
I have 9 entries defined within the openvpn client with a random selection to the dns entry. The 1 after client equals the ovpnc<x>
I'm about to create a 2nd openvpn client with locations outside my country so the cron job for this client will be
/usr/local/sbin/pfSsh.php playback svc restart openvpn client 2
-
Oh good grief!
Thank you very much for the extra nudge which got me across the line...
You are right - I don't need to re-install, it works fine "when you get the syntax right".
In this case the "syntax" was collected from a post above in this thread, which appears to do the wrong thing.
This works:
/usr/local/sbin/pfSsh.php playback svc restart openvpn client 1The syntax in the post above uses the keyword SERVER which may restart the server, but doesn't restart the client!
So I was also right when I remembered that it used to work previously - because I had the syntax right then, but I copied the wrong advice....what a muppet!
So now we have a mechanism to restart the OVPN client on demand, and the cron jobs in place to check & restart as required.
I do like your technique of changing locations daily - very sneaky 10/10.
I consider this issue closed, don't expect to add any updates as it will almost certainly be fine now.
Thanks.
"Permission to engage smug mode sir?" (Kryton) -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-