[3/3] ovpnmain.cgi: Fixes bug13832 - restart collectd initscript on openvpn server status change

Message ID 20250317195123.2092-3-adolf.belka@ipfire.org
State New
Headers
Series [1/3] collectd: Fixes bug13832 - uncomments include openvpn plugin only if openvpn is running |

Commit Message

Adolf Belka March 17, 2025, 7:51 p.m. UTC
  - When the openvpn server status is changed from RUNNING to STOPPED or vice versa then
   the collectd initscript is restarted to ensure that the include openvpn plugin line
   in the collectd.conf file is correctly uncommented or not.

Fixes: bug13832
Tested-by: Adolf Belka <adolf.belka@ipfire.org>
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
 html/cgi-bin/ovpnmain.cgi | 4 ++++
 1 file changed, 4 insertions(+)
  

Patch

diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi
index 20f256f4b..f16ba0591 100644
--- a/html/cgi-bin/ovpnmain.cgi
+++ b/html/cgi-bin/ovpnmain.cgi
@@ -782,6 +782,10 @@  if ($cgiparams{'ACTION'} eq $Lang::tr{'start ovpn server'} ||
 	&General::system("/usr/local/bin/openvpnctrl", "-k");
 	&emptyserverlog();
     }
+
+    # restart collectd to uncomment include openvpn plugin command if openvpn pid exists
+    &General::system("/usr/local/bin/collectdctrl", "restart");
+
 #    #restart openvpn server
 #    if ($cgiparams{'ACTION'} eq $Lang::tr{'restart ovpn server'}){
 #workarund, till SIGHUP also works when running as nobody