English Forums > 22.7 Legacy Series

Cron for OpenVPN

(1/1)

Pfirepfox:
Hi All,

Just having a few issues creating a custom cron to restart the openvpn service on a defined schedule. Hopefully this will resolve an issue i am having with it consistently dropping and failing to reconnect ever 2-3 days. I have followed this topic https://forum.opnsense.org/index.php?topic=2263.0 to generate the below.


--- Code: ---[stop]
command:/usr/local/sbin/pluginctl -s openvpn stop
parameters:
type:script
message:stop openvpn service
description:Stop openvpn

[start]
command:/usr/local/sbin/pluginctl -s openvpn start
parameters:
type:script
message:start openvpn service
description:Start openvpn

[restart]
command:/usr/local/sbin/pluginctl -s openvpn restart
parameters:
type:script
message:restart openvpn service
description:Restart openvpn

--- End code ---

When I manually run
--- Code: ---/usr/local/sbin/pluginctl -s openvpn restart
--- End code ---
the expected behavior of restarting the openvpn service occurs. however when I use
--- Code: ---configctl openvpn restart
--- End code ---
to call the corresponding function in my conf file it returns "OK" but fails to restart the service.

Does anyone have any ideas on why this is occurring?

crissi:
Hello,
Thanks for the code. I’m having exactly the same issue, and try to restart the openvpn service via custom cron job.

What I did till now is:

Created File actions_custom.conf under Path /usr/local/opnsense/service/conf/actions.d/

Pasted your Code but changed


--- Code: ---type:script

--- End code ---

to


--- Code: ---type:script_output

--- End code ---


--- Code: ---configctl custom restart
Service `openvpn' has been restarted.

--- End code ---


Via Command Line its working openvpn service can be stopped / started / restarted

But the Issues for me are still:
1 . When configctl custom restart via command line is executed, just the first openvpn client connection is restarted. But I have 2. connections. How to adapt the script to restart all openvpn Client connections?


2. Tried yet several times with Firewall Reboots, configd reload etc. to get the Custom Cron-Job working, but no success unfortunately... And i dont want to edit corntab File directly, as with the next System Update the modifications are gone...

Can anyone give me a hint here?

BR
Crissi

crissi:
Still have frequent OpenVpn Client disconnects and the connection is not automatically restarted...

Manually diaqble and enable the connection works fine...

Navigation

[0] Message Index

Go to full version