Add checkOS ()

This commit is contained in:
Angristan 2018-08-19 01:01:30 +02:00
parent ff5c7aef41
commit 468a1afa46

View file

@ -23,26 +23,11 @@ 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
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
exit 1
fi
if [[ -e /etc/debian_version ]]; then
@ -59,11 +44,11 @@ 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
@ -80,8 +65,28 @@ elif [[ -e /etc/arch-release ]]; then
SYSCTL='/etc/sysctl.d/openvpn.conf'
else
echo "Looks like you aren't running this installer on a Debian, Ubuntu, CentOS or ArchLinux system"
exit 4
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 ""