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
|
||||
}
|
||||
|
||||
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 2
|
||||
fi
|
||||
}
|
||||
|
||||
##########################################
|
||||
############### MAIN ###############
|
||||
##########################################
|
||||
|
||||
initialCheck
|
||||
|
||||
# Check if CentOS 5
|
||||
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
||||
function checkOS () {
|
||||
# Check if CentOS 5
|
||||
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
||||
echo "CentOS 5 is too old and not supported"
|
||||
exit 3
|
||||
fi
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ -e /etc/debian_version ]]; then
|
||||
if [[ -e /etc/debian_version ]]; then
|
||||
OS="debian"
|
||||
# Getting the version number, to verify that a recent version of OpenVPN is available
|
||||
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 "Keep in mind they are not supported, though."
|
||||
while [[ $CONTINUE != "y" && $CONTINUE != "n" ]]; do
|
||||
read -rp "Continue ? [y/n]: " -e CONTINUE
|
||||
read -rp "Continue ? [y/n]: " -e local CONTINUE
|
||||
done
|
||||
if [[ "$CONTINUE" = "n" ]]; then
|
||||
echo "Ok, bye !"
|
||||
exit 4
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
elif [[ -e /etc/fedora-release ]]; then
|
||||
elif [[ -e /etc/fedora-release ]]; then
|
||||
OS=fedora
|
||||
IPTABLES='/etc/iptables/iptables.rules'
|
||||
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
|
||||
IPTABLES='/etc/iptables/iptables.rules'
|
||||
SYSCTL='/etc/sysctl.conf'
|
||||
elif [[ -e /etc/arch-release ]]; then
|
||||
elif [[ -e /etc/arch-release ]]; then
|
||||
OS=arch
|
||||
IPTABLES='/etc/iptables/iptables.rules'
|
||||
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"
|
||||
exit 4
|
||||
fi
|
||||
exit 1
|
||||
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 () {
|
||||
echo ""
|
||||
|
|
|
|||
Loading…
Reference in a new issue