mirror of
https://github.com/aaronriedel/hetzner-ddns.git
synced 2024-11-18 00:56:41 +01:00
add validity check for ipv4 addresses
This commit is contained in:
parent
43d20a1108
commit
98080c7d07
1 changed files with 3 additions and 3 deletions
6
ddns4.sh
6
ddns4.sh
|
@ -44,10 +44,10 @@ echo -e "${INFO} started $(date)"
|
||||||
echo -e "${INFO} DNS Record will be $SUBDOMAIN_IPV4.$DNSZONE_IPV4"
|
echo -e "${INFO} DNS Record will be $SUBDOMAIN_IPV4.$DNSZONE_IPV4"
|
||||||
echo -e "${PENDING} get IP address"
|
echo -e "${PENDING} get IP address"
|
||||||
IPv4="$(curl -s4 https://ip.hetzner.com)"
|
IPv4="$(curl -s4 https://ip.hetzner.com)"
|
||||||
if [[ -z $IPv4 ]]; then
|
if [[ -z $IPv4 || ! $IPv4 =~ ^[0-9]{1,3}("."[0-9]{1,3}){3}$ ]]; then
|
||||||
IPv4="$(curl -s4 https://icanhazip.com)"
|
IPv4="$(curl -s4 https://icanhazip.com)"
|
||||||
fi
|
fi
|
||||||
if [[ -z $IPv4 ]]; then
|
if [[ -z $IPv4 || ! $IPv4 =~ ^[0-9]{1,3}("."[0-9]{1,3}){3}$ ]]; then
|
||||||
echo -e "${REPLACE}${FAIL} IPv4 not found"
|
echo -e "${REPLACE}${FAIL} IPv4 not found"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue