mirror of
https://github.com/Nyr/openvpn-install.git
synced 2024-11-23 21:46:08 +03:00
Detect users running with "sh" instead of bash
And changed error codes. Sorry, not sorry.
This commit is contained in:
parent
2bcb4681a1
commit
52f419e0d5
@ -8,23 +8,26 @@
|
|||||||
# universal as possible.
|
# universal as possible.
|
||||||
|
|
||||||
|
|
||||||
if [[ "$EUID" -ne 0 ]]; then
|
# Detect Debian users running the script with "sh" instead of bash
|
||||||
echo "Sorry, you need to run this as root"
|
if readlink /proc/$$/exe | grep -qs "dash"; then
|
||||||
|
echo "This script needs to be run with bash, not sh"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "$EUID" -ne 0 ]]; then
|
||||||
if [[ ! -e /dev/net/tun ]]; then
|
echo "Sorry, you need to run this as root"
|
||||||
echo "TUN is not available"
|
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -e /dev/net/tun ]]; then
|
||||||
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
echo "TUN is not available"
|
||||||
echo "CentOS 5 is too old and not supported"
|
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
||||||
|
echo "CentOS 5 is too old and not supported"
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
if [[ -e /etc/debian_version ]]; then
|
if [[ -e /etc/debian_version ]]; then
|
||||||
OS=debian
|
OS=debian
|
||||||
RCLOCAL='/etc/rc.local'
|
RCLOCAL='/etc/rc.local'
|
||||||
@ -35,7 +38,7 @@ elif [[ -e /etc/centos-release || -e /etc/redhat-release ]]; then
|
|||||||
chmod +x /etc/rc.d/rc.local
|
chmod +x /etc/rc.d/rc.local
|
||||||
else
|
else
|
||||||
echo "Looks like you aren't running this installer on a Debian, Ubuntu or CentOS system"
|
echo "Looks like you aren't running this installer on a Debian, Ubuntu or CentOS system"
|
||||||
exit 4
|
exit 5
|
||||||
fi
|
fi
|
||||||
|
|
||||||
newclient () {
|
newclient () {
|
||||||
@ -52,7 +55,6 @@ newclient () {
|
|||||||
echo "</key>" >> ~/$1.ovpn
|
echo "</key>" >> ~/$1.ovpn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Try to get our IP from the system and fallback to the Internet.
|
# Try to get our IP from the system and fallback to the Internet.
|
||||||
# I do this to make the script compatible with NATed servers (lowendspirit.com)
|
# I do this to make the script compatible with NATed servers (lowendspirit.com)
|
||||||
# and to avoid getting an IPv6.
|
# and to avoid getting an IPv6.
|
||||||
@ -61,7 +63,6 @@ if [[ "$IP" = "" ]]; then
|
|||||||
IP=$(wget -qO- ipv4.icanhazip.com)
|
IP=$(wget -qO- ipv4.icanhazip.com)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ -e /etc/openvpn/server.conf ]]; then
|
if [[ -e /etc/openvpn/server.conf ]]; then
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
@ -95,7 +96,7 @@ if [[ -e /etc/openvpn/server.conf ]]; then
|
|||||||
if [[ "$NUMBEROFCLIENTS" = '0' ]]; then
|
if [[ "$NUMBEROFCLIENTS" = '0' ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "You have no existing clients!"
|
echo "You have no existing clients!"
|
||||||
exit 5
|
exit 6
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo "Select the existing client certificate you want to revoke"
|
echo "Select the existing client certificate you want to revoke"
|
||||||
|
Loading…
Reference in New Issue
Block a user