From 75213a93ea742d586bc6d958a13fc02d5ed5f525 Mon Sep 17 00:00:00 2001 From: angristan Date: Mon, 17 Sep 2018 15:02:05 +0200 Subject: [PATCH] Refactor my refactoring :) --- openvpn-install.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/openvpn-install.sh b/openvpn-install.sh index f4e41ae..3f1c41a 100644 --- a/openvpn-install.sh +++ b/openvpn-install.sh @@ -6,17 +6,13 @@ # Functions function isRoot () { - if [[ "$EUID" -eq 0 ]]; then - return 0 - else + if [ "$EUID" -ne 0 ]; then return 1 fi } function tunAvailable () { - if [[ -e /dev/net/tun ]]; then - return 0 - else + if [ ! -e /dev/net/tun ]; then return 1 fi } @@ -78,6 +74,10 @@ function initialCheck () { checkOS } +function getNIC () { + return $(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1) +} + function newclient () { echo "" echo "Do you want to protect the configuration file with a password?" @@ -222,7 +222,7 @@ private-address: ::ffff:0:0/96' > /etc/unbound/openvpn.conf initialCheck # Get Internet network interface with default route -NIC=$(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1) +NIC=$(getNIC) if [[ -e /etc/openvpn/server.conf ]]; then while :