1
0
mirror of https://github.com/Nyr/openvpn-install.git synced 2024-11-27 15:36:07 +03:00

Variable check added to avoid performing the same request twice

This commit is contained in:
Rubén Díaz 2013-07-31 23:38:32 +02:00
parent 730691c8a1
commit 22b5fdf80b

View File

@ -26,6 +26,7 @@ fi
IP=$(ifconfig | grep 'inet addr:' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | cut -d: -f2 | awk '{ print $1}') IP=$(ifconfig | grep 'inet addr:' | grep -v inet6 | grep -vE '127\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | cut -d: -f2 | awk '{ print $1}')
if [ "$IP" = "" ]; then if [ "$IP" = "" ]; then
IP=$(wget -qO- ipv4.icanhazip.com) IP=$(wget -qO- ipv4.icanhazip.com)
EXTERNALIP=$IP
fi fi
@ -179,7 +180,7 @@ else
mkdir ~/ovpn-$CLIENT mkdir ~/ovpn-$CLIENT
# Try to detect a NATed connection and ask about it to potential LowEndSpirit # Try to detect a NATed connection and ask about it to potential LowEndSpirit
# users # users
EXTERNALIP=$(wget -qO- ipv4.icanhazip.com) if [ -z "$EXTERNALIP" ]; then EXTERNALIP=$(wget -qO- ipv4.icanhazip.com); fi
if [ "$IP" != "$EXTERNALIP" ]; then if [ "$IP" != "$EXTERNALIP" ]; then
echo "" echo ""
echo "Looks like your server is behind a NAT!" echo "Looks like your server is behind a NAT!"
@ -209,4 +210,4 @@ else
echo "" echo ""
echo "Your client config is available at ~/ovpn-$CLIENT.tar.gz" echo "Your client config is available at ~/ovpn-$CLIENT.tar.gz"
echo "If you want to add more clients, you simply need to run this script another time!" echo "If you want to add more clients, you simply need to run this script another time!"
fi fi