mirror of
https://github.com/Nyr/openvpn-install.git
synced 2025-02-17 14:03:13 +03:00
Init system detection
This commit is contained in:
parent
b943ff314d
commit
2cd35e883e
@ -1,11 +1,13 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# OpenVPN road warrior installer for Debian, Ubuntu and CentOS
|
# OpenVPN road warrior installer for Debian, Ubuntu and CentOS
|
||||||
|
|
||||||
# This script will work on Debian, Ubuntu, CentOS and probably other distros
|
# This script is implemented as POSIX-compliant.
|
||||||
# of the same families, although no support is offered for them. It isn't
|
# It should work on sh, dash, bash, ksh, zsh on Debian, Ubuntu, CentOS
|
||||||
# bulletproof but it will probably work if you simply want to setup a VPN on
|
# and probably other distros of the same families,
|
||||||
# your Debian/Ubuntu/CentOS box. It has been designed to be as unobtrusive and
|
# although no support is offered for them. It isn't bulletproof but
|
||||||
# universal as possible.
|
# it will probably work if you simply want to setup a VPN on
|
||||||
|
# your Debian/Ubuntu/CentOS box. It has been designed to be
|
||||||
|
# as unobtrusive and universal as possible.
|
||||||
|
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]
|
if [ "$(id -u)" != "0" ]
|
||||||
@ -41,6 +43,16 @@ else
|
|||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Detect the init system
|
||||||
|
# Return the PID of systemd if running
|
||||||
|
pidof /sbin/init && INITSYS=sysvinit
|
||||||
|
# Return the PID of systemd if running
|
||||||
|
pidof systemd && INITSYS=systemd
|
||||||
|
if [ "$INITSYS" = "" ]
|
||||||
|
then echo "Your init system isn't supported"
|
||||||
|
exit 5
|
||||||
|
fi
|
||||||
|
|
||||||
newclient() {
|
newclient() {
|
||||||
# Generates the custom client.ovpn
|
# Generates the custom client.ovpn
|
||||||
cp /etc/openvpn/client-common.txt ~/$1.ovpn
|
cp /etc/openvpn/client-common.txt ~/$1.ovpn
|
||||||
@ -113,11 +125,9 @@ then
|
|||||||
./easyrsa --batch revoke $CLIENT
|
./easyrsa --batch revoke $CLIENT
|
||||||
./easyrsa gen-crl
|
./easyrsa gen-crl
|
||||||
# And restart
|
# And restart
|
||||||
if pgrep systemd-journal
|
if [ $INITSYS = systemd ]
|
||||||
then systemctl restart openvpn@server.service
|
then systemctl restart openvpn@server.service
|
||||||
elif [ $OS = debian ]
|
else
|
||||||
then /etc/init.d/openvpn restart
|
|
||||||
else
|
|
||||||
service openvpn restart
|
service openvpn restart
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
@ -307,12 +317,10 @@ crl-verify /etc/openvpn/easy-rsa/pki/crl.pem" >> /etc/openvpn/server.conf
|
|||||||
sed -i "1 a\iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT" $RCLOCAL
|
sed -i "1 a\iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT" $RCLOCAL
|
||||||
fi
|
fi
|
||||||
# And finally, restart OpenVPN
|
# And finally, restart OpenVPN
|
||||||
if pgrep systemd-journal
|
if [ $INITSYS = systemd ]
|
||||||
then # Little hack to check for systemd
|
then # Little hack to check for systemd
|
||||||
systemctl restart openvpn@server.service
|
systemctl restart openvpn@server.service
|
||||||
systemctl enable openvpn@server.service
|
systemctl enable openvpn@server.service
|
||||||
elif [ $OS = debian ]
|
|
||||||
then /etc/init.d/openvpn restart
|
|
||||||
else
|
else
|
||||||
service openvpn restart
|
service openvpn restart
|
||||||
chkconfig openvpn on
|
chkconfig openvpn on
|
||||||
|
Loading…
x
Reference in New Issue
Block a user