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.
This commit is contained in:
Henry N 2020-03-27 00:42:59 +01:00 committed by GitHub
parent 3d075c8708
commit c2353a6f6c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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