Add a functions and main section, add initialCheck ()
This commit is contained in:
parent
32744f853a
commit
931e82f5de
1 changed files with 29 additions and 10 deletions
|
|
@ -3,18 +3,37 @@
|
||||||
# Secure OpenVPN server installer for Debian, Ubuntu, CentOS and Fedora
|
# Secure OpenVPN server installer for Debian, Ubuntu, CentOS and Fedora
|
||||||
# https://github.com/Angristan/OpenVPN-install
|
# https://github.com/Angristan/OpenVPN-install
|
||||||
|
|
||||||
|
# Functions
|
||||||
|
|
||||||
# Verify root
|
function isRoot () {
|
||||||
if [[ "$EUID" -ne 0 ]]; then
|
if [[ "$EUID" -eq 0 ]]; then
|
||||||
echo "Sorry, you need to run this as root"
|
return 0
|
||||||
exit 1
|
else
|
||||||
fi
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Verify tun
|
function tunAvailable () {
|
||||||
if [[ ! -e /dev/net/tun ]]; then
|
if [[ -e /dev/net/tun ]]; 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
|
||||||
|
|
||||||
if [[ -e /etc/debian_version ]]; then
|
if [[ -e /etc/debian_version ]]; then
|
||||||
OS="debian"
|
OS="debian"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue