OPNsense Forum

Archive => 22.7 Legacy Series => Topic started by: Pfirepfox on November 16, 2022, 11:18:56 am

Title: Cron for OpenVPN
Post by: Pfirepfox on November 16, 2022, 11:18:56 am
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: [Select]
[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

When I manually run
Code: [Select]
/usr/local/sbin/pluginctl -s openvpn restart the expected behavior of restarting the openvpn service occurs. however when I use
Code: [Select]
configctl openvpn restart 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?
Title: Re: Cron for OpenVPN
Post by: crissi on December 03, 2022, 01:44:56 pm
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: [Select]
type:script

to

Code: [Select]
type:script_output

Code: [Select]
configctl custom restart
Service `openvpn' has been restarted.


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
Title: Re: Cron for OpenVPN
Post by: crissi on December 28, 2022, 01:07:01 pm
Still have frequent OpenVpn Client disconnects and the connection is not automatically restarted...

Manually diaqble and enable the connection works fine...