Add a functions and main section, add initialCheck ()
This commit is contained in:
parent
602c169bd8
commit
ff5c7aef41
1 changed files with 33 additions and 10 deletions
|
|
@ -3,18 +3,41 @@
|
||||||
# Secure OpenVPN server installer for Debian, Ubuntu, CentOS and Arch Linux
|
# Secure OpenVPN server installer for Debian, Ubuntu, CentOS and Arch Linux
|
||||||
# https://github.com/Angristan/OpenVPN-install
|
# https://github.com/Angristan/OpenVPN-install
|
||||||
|
|
||||||
|
#########################################
|
||||||
|
############ FUNCTIONS ############
|
||||||
|
#########################################
|
||||||
|
|
||||||
# Verify root
|
function tunAvailable () {
|
||||||
if [[ "$EUID" -ne 0 ]]; then
|
if [[ -e /dev/net/tun ]]; then
|
||||||
echo "Sorry, you need to run this as root"
|
return 0
|
||||||
exit 1
|
else
|
||||||
fi
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Verify tun
|
function isRoot () {
|
||||||
if [[ ! -e /dev/net/tun ]]; then
|
if [[ "$EUID" -eq 0 ]]; then
|
||||||
echo "TUN is not available"
|
return 0
|
||||||
exit 2
|
else
|
||||||
fi
|
return 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 2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##########################################
|
||||||
|
############### MAIN ###############
|
||||||
|
##########################################
|
||||||
|
|
||||||
|
initialCheck
|
||||||
|
|
||||||
# Check if CentOS 5
|
# Check if CentOS 5
|
||||||
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
if grep -qs "CentOS release 5" "/etc/redhat-release"; then
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue