Add checkOS ()
This commit is contained in:
parent
ff5c7aef41
commit
468a1afa46
1 changed files with 49 additions and 44 deletions
|
|
@ -23,29 +23,14 @@ function isRoot () {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function initialCheck () {
|
function checkOS () {
|
||||||
if ! isRoot; then
|
# Check if CentOS 5
|
||||||
echo "Sorry, you need to run this as root"
|
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
||||||
exit 1
|
|
||||||
elif ! tunAvailable; then
|
|
||||||
echo "TUN is not available"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
##########################################
|
|
||||||
############### MAIN ###############
|
|
||||||
##########################################
|
|
||||||
|
|
||||||
initialCheck
|
|
||||||
|
|
||||||
# Check if CentOS 5
|
|
||||||
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
|
||||||
echo "CentOS 5 is too old and not supported"
|
echo "CentOS 5 is too old and not supported"
|
||||||
exit 3
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -e /etc/debian_version ]]; then
|
if [[ -e /etc/debian_version ]]; then
|
||||||
OS="debian"
|
OS="debian"
|
||||||
# Getting the version number, to verify that a recent version of OpenVPN is available
|
# Getting the version number, to verify that a recent version of OpenVPN is available
|
||||||
VERSION_ID=$(grep "VERSION_ID" /etc/os-release)
|
VERSION_ID=$(grep "VERSION_ID" /etc/os-release)
|
||||||
|
|
@ -59,29 +44,49 @@ if [[ -e /etc/debian_version ]]; then
|
||||||
echo "then you can continue, a recent version of OpenVPN is available on these."
|
echo "then you can continue, a recent version of OpenVPN is available on these."
|
||||||
echo "Keep in mind they are not supported, though."
|
echo "Keep in mind they are not supported, though."
|
||||||
while [[ $CONTINUE != "y" && $CONTINUE != "n" ]]; do
|
while [[ $CONTINUE != "y" && $CONTINUE != "n" ]]; do
|
||||||
read -rp "Continue ? [y/n]: " -e CONTINUE
|
read -rp "Continue ? [y/n]: " -e local CONTINUE
|
||||||
done
|
done
|
||||||
if [[ "$CONTINUE" = "n" ]]; then
|
if [[ "$CONTINUE" = "n" ]]; then
|
||||||
echo "Ok, bye !"
|
echo "Ok, bye !"
|
||||||
exit 4
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
elif [[ -e /etc/fedora-release ]]; then
|
elif [[ -e /etc/fedora-release ]]; then
|
||||||
OS=fedora
|
OS=fedora
|
||||||
IPTABLES='/etc/iptables/iptables.rules'
|
IPTABLES='/etc/iptables/iptables.rules'
|
||||||
SYSCTL='/etc/sysctl.d/openvpn.conf'
|
SYSCTL='/etc/sysctl.d/openvpn.conf'
|
||||||
elif [[ -e /etc/centos-release || -e /etc/redhat-release || -e /etc/system-release ]]; then
|
elif [[ -e /etc/centos-release || -e /etc/redhat-release || -e /etc/system-release ]]; then
|
||||||
OS=centos
|
OS=centos
|
||||||
IPTABLES='/etc/iptables/iptables.rules'
|
IPTABLES='/etc/iptables/iptables.rules'
|
||||||
SYSCTL='/etc/sysctl.conf'
|
SYSCTL='/etc/sysctl.conf'
|
||||||
elif [[ -e /etc/arch-release ]]; then
|
elif [[ -e /etc/arch-release ]]; then
|
||||||
OS=arch
|
OS=arch
|
||||||
IPTABLES='/etc/iptables/iptables.rules'
|
IPTABLES='/etc/iptables/iptables.rules'
|
||||||
SYSCTL='/etc/sysctl.d/openvpn.conf'
|
SYSCTL='/etc/sysctl.d/openvpn.conf'
|
||||||
else
|
else
|
||||||
echo "Looks like you aren't running this installer on a Debian, Ubuntu, CentOS or ArchLinux system"
|
echo "Looks like you aren't running this installer on a Debian, Ubuntu, CentOS or ArchLinux system"
|
||||||
exit 4
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function initialCheck () {
|
||||||
|
if ! isRoot; then
|
||||||
|
echo "Sorry, you need to run this as root"
|
||||||
|
exit 1
|
||||||
|
elif ! tunAvailable; then
|
||||||
|
echo "TUN is not available"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
checkOS
|
||||||
|
}
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
############### MAIN ###############
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
initialCheck
|
||||||
|
|
||||||
|
|
||||||
function newclient () {
|
function newclient () {
|
||||||
echo ""
|
echo ""
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue