forked from theonemule/docker-dynamic-dns
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno-ip.sh
executable file
·127 lines (90 loc) · 1.93 KB
/
no-ip.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#!/bin/bash
while :
do
if [ -z "$USER" ]
then
echo "No user was set. Use -u=username"
exit 10
fi
if [ -z "$PASSWORD" ]
then
echo "No password was set. Use -p=password"
exit 20
fi
if [ -z "$HOSTNAME" ]
then
echo "No host name. Use -h=host.example.com"
exit 30
fi
if [ -n "$DETECTIP" ]
then
IP=$(wget -qO- "http://myexternalip.com/raw")
if [ -n "$UPDATEIPV6" ]
then
IPV6=$(wget -q --output-document - http://checkipv6.dyndns.com/ | grep -o "[0-9a-f\:]\{8,\}")
fi
fi
if [ -n "$DETECTIP" ] && [ -z $IP ]
then
RESULT="Could not detect external IP."
fi
if [[ $INTERVAL != [0-9]* ]]
then
echo "Interval is not an integer."
exit 35
fi
SERVICEURL="dynupdate.no-ip.com/nic/update"
case "$SERVICE" in
noip)
SERVICEURL="dynupdate.no-ip.com/nic/update"
;;
dyndns)
SERVICEURL="members.dyndns.org/v3/update"
;;
duckdns)
SERVICEURL="www.duckdns.org/v3/update"
;;
google)
SERVICEURL="domains.google.com/nic/update"
;;
freedns)
SERVICEURL="freedns.afraid.org/nic/update"
;;
*)
SERVICEURL="dynupdate.no-ip.com/nic/update"
esac
USERAGENT="--user-agent=\"no-ip shell script/1.0 [email protected]\""
BASE64AUTH=$(echo '"$USER:$PASSWORD"' | base64)
AUTHHEADER="--header=\"Authorization: $BASE64AUTH\""
NOIPURL="https://$USER:$PASSWORD@$SERVICEURL"
if [ -n "$IP" ] || [ -n "$HOSTNAME" ]
then
NOIPURL="$NOIPURL?"
fi
if [ -n "$HOSTNAME" ]
then
NOIPURL="${NOIPURL}hostname=${HOSTNAME}"
fi
if [ -n "$IP" ]
then
if [ -n "$HOSTNAME" ]
then
NOIPURL="$NOIPURL&"
fi
NOIPURL="${NOIPURL}myip=$IP"
if [ -n "$UPDATEIPV6" ]
then
NOIPURL="${NOIPURL},$IPV6&myipv6=$IPV6"
fi
fi
echo "$AUTHHEADER $USERAGENT $NOIPURL"
RESULT=$(wget --no-check-certificate -qO- $AUTHHEADER $USERAGENT $NOIPURL)
echo $RESULT
if [ $INTERVAL -eq 0 ]
then
break
else
sleep "${INTERVAL}m"
fi
done
exit 0