Refactor my refactoring :)

This commit is contained in:
angristan 2018-09-17 15:02:05 +02:00
parent 3284a5f2f5
commit 75213a93ea

View file

@ -6,17 +6,13 @@
# Functions # Functions
function isRoot () { function isRoot () {
if [[ "$EUID" -eq 0 ]]; then if [ "$EUID" -ne 0 ]; then
return 0
else
return 1 return 1
fi fi
} }
function tunAvailable () { function tunAvailable () {
if [[ -e /dev/net/tun ]]; then if [ ! -e /dev/net/tun ]; then
return 0
else
return 1 return 1
fi fi
} }
@ -78,6 +74,10 @@ function initialCheck () {
checkOS checkOS
} }
function getNIC () {
return $(ip -4 route ls | grep default | grep -Po '(?<=dev )(\S+)' | head -1)
}
function newclient () { function newclient () {
echo "" echo ""
echo "Do you want to protect the configuration file with a password?" 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 initialCheck
# Get Internet network interface with default route # 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 if [[ -e /etc/openvpn/server.conf ]]; then
while : while :