From c2353a6f6c904e3a4646a40d2ce730b0244e7f74 Mon Sep 17 00:00:00 2001 From: Henry N Date: Fri, 27 Mar 2020 00:42:59 +0100 Subject: [PATCH] Fix Problem running on OpenVZ #129 again On Debian 9 the unit file openvpn-server@.service must use and modyfy for OpenVZ. The file openvpn@.service does not work. --- openvpn-install.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index 078d200..7f8d599 100755 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -894,6 +894,19 @@ verb 3" >> /etc/openvpn/server.conf # This package uses a sysvinit service systemctl enable openvpn systemctl start openvpn + elif [[ -f /lib/systemd/system/openvpn-server@.service ]]; then + # On Debian 9, needs to copy from an other place + # Don't modify package-provided service + cp /lib/systemd/system/openvpn-server@.service /etc/systemd/system/openvpn-server@.service + + # Workaround to fix OpenVPN service on OpenVZ + sed -i 's|LimitNPROC|#LimitNPROC|' /etc/systemd/system/openvpn-server@.service + # Another workaround to keep using /etc/openvpn/ + sed -i 's|/etc/openvpn/server|/etc/openvpn|' /etc/systemd/system/openvpn-server@.service + + systemctl daemon-reload + systemctl restart openvpn-server@server + systemctl enable openvpn-server@server else # Don't modify package-provided service cp /lib/systemd/system/openvpn\@.service /etc/systemd/system/openvpn\@.service @@ -1171,7 +1184,8 @@ function removeOpenVPN () { PORT=$(grep '^port ' /etc/openvpn/server.conf | cut -d " " -f 2) # Stop OpenVPN - if [[ "$OS" =~ (fedora|arch|centos) ]]; then + if [[ -f /etc/systemd/system/openvpn-server@.service ]]; then + # fedora, arch, centos, debian 9 systemctl disable openvpn-server@server systemctl stop openvpn-server@server # Remove customised service