Rework and cleanup service handling

This commit is contained in:
angristan 2018-09-17 16:19:44 +02:00
parent f75b330561
commit 9e05390c0c

View file

@ -784,35 +784,23 @@ verb 3" >> /etc/openvpn/server.conf
fi fi
fi fi
# And finally, restart OpenVPN # Finally, restart and enable OpenVPN
if [[ "$OS" = 'debian' ]]; then if [[ "$OS" = 'fedora' ]]; then
# Little hack to check for systemd # Workaround to fix OpenVPN service on OpenVZ
if pgrep systemd-journal; then sed -i 's|LimitNPROC|#LimitNPROC|' /usr/lib/systemd/system/openvpn-server@.service
# Another workaround to keep using /etc/openvpn/
sed -i 's|/etc/openvpn/server|/etc/openvpn|' /usr/lib/systemd/system/openvpn-server@.service
systemctl daemon-reload
systemctl restart openvpn-server@server
systemctl enable openvpn-server@server
else
# Workaround to fix OpenVPN service on OpenVZ # Workaround to fix OpenVPN service on OpenVZ
sed -i 's|LimitNPROC|#LimitNPROC|' /lib/systemd/system/openvpn\@.service sed -i 's|LimitNPROC|#LimitNPROC|' /lib/systemd/system/openvpn\@.service
# Another workaround to keep using /etc/openvpn/
sed -i 's|/etc/openvpn/server|/etc/openvpn|' /lib/systemd/system/openvpn\@.service sed -i 's|/etc/openvpn/server|/etc/openvpn|' /lib/systemd/system/openvpn\@.service
systemctl daemon-reload systemctl daemon-reload
systemctl restart openvpn@server systemctl restart openvpn@server
systemctl enable openvpn@server systemctl enable openvpn@server
else
/etc/init.d/openvpn restart
fi
else
if pgrep systemd-journal; then
if [[ "$OS" = 'fedora' ]]; then
# Workaround to avoid rewriting the entire script for Fedora
sed -i 's|/etc/openvpn/server|/etc/openvpn|' /usr/lib/systemd/system/openvpn-server@.service
systemctl daemon-reload
systemctl restart openvpn-server@openvpn
systemctl enable openvpn-server@openvpn
else
systemctl restart openvpn@server
systemctl enable openvpn@server
fi
else
service openvpn restart
chkconfig openvpn on
fi
fi fi
# If the server is behind a NAT, use the correct IP address # If the server is behind a NAT, use the correct IP address