ydns-simple: use curl if dig is not installed

Closes #6
This commit is contained in:
Aminda Suomalainen 2015-07-19 11:30:54 +03:00
parent 5e0a611c4d
commit b4421b0845
1 changed files with 10 additions and 2 deletions

View File

@ -18,7 +18,11 @@ PASSWORD=""
HOSTNAME=""
# Get IPv4 address
WAN_IP4=$(dig +short myip.opendns.com. A @208.67.220.220)
if hash dig 2>/dev/null; then
WAN_IP4=$(dig +short myip.opendns.com. A @208.67.220.220)
else
WAN_IP4=$(curl -L4 https://icanhazip.com/)
fi
if [ -f $HOME/.wan_ip4-ydns.txt ]; then
OLD_WAN_IP4=$(cat $HOME/.wan_ip4-ydns.txt)
else
@ -27,7 +31,11 @@ else
fi
# Get IPv6 address
WAN_IP6=$(dig +short myip.opendns.com. AAAA @2620:0:ccd::2)
if hash dig 2>/dev/null; then
WAN_IP6=$(dig +short myip.opendns.com. AAAA @2620:0:ccd::2)
else
WAN_IP6=$(curl -L6 https://icanhazip.com/)
fi
if [ -f $HOME/.wan_ip6-ydns.txt ]; then
OLD_WAN_IP6=$(cat $HOME/.wan_ip6-ydns.txt)
else