-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
executable file
·69 lines (56 loc) · 2.18 KB
/
update.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
#!/bin/sh
if [ -z "$TZ" ] || ! echo "$TZ" | grep -q "^[A-Za-z/]\+$"; then
echo "TZ is unset or invalid."
sleep inf
fi
if ! echo "$UI" | grep -q "^[0-9]\+[smhd]\?$"; then
echo "UI needs to be a number which can be followed by one of the chars s, m, h or d."
sleep inf
fi
if [ -z "$DUK" ] || ! echo "$DUK" | grep -q "^[A-Za-z0-9]\+$"; then
echo "DUK is unset or invalid, it can consist of upper letters A-Z, lower letters a-z and numbers 0-9."
sleep inf
fi
if [ -z "$DUDs" ] || ! echo "$DUDs" | grep -q "\."; then
echo "DUDs is unset or invalid, it needs to contain at least one dot."
sleep inf
fi
if ! echo "$IPv4" | grep -q "^true$\|^false$"; then
echo "IPv4 needs to be true or false."
sleep inf
fi
if ! echo "$IPv6" | grep -q "^true$\|^false$"; then
echo "IPv6 needs to be true or false."
sleep inf
fi
if ! curl -sS4 ipv4.ipv64.net -o /dev/null; then
echo "IPv4 does not work, disabling it."
export IPv4="false"
fi
if ! curl -sS6 ipv6.ipv64.net -o /dev/null; then
echo "IPv6 does not work, disabling it."
export IPv6="false"
fi
if [ "$IPv4" = "false" ] && [ "$IPv6" = "false" ]; then
echo "IPv4 and IPv6 disabled, stopping."
sleep inf
fi
for DUD in $DUDs; do
if [ "$IPv4" = "true" ]; then
curl -sSL4 "https://ipv4.ipv64.net/nic/update?key=$DUK&domain=$DUD" | tee /tmp/IPv4.json
fi
if [ "$IPv6" = "true" ]; then
curl -sSL6 "https://ipv6.ipv64.net/nic/update?key=$DUK&domain=$DUD" | tee /tmp/IPv6.json
fi
done
while true; do
for DUD in $DUDs; do
if [ "$IPv4" = "true" ] && [ "$(curl -sS4 https://ipv4.ipv64.net/ipcheck.php?ipv4)" != "$(dig "$DUD" IN A +short +https +tls-ca=/etc/ssl/certs/ca-certificates.crt @1.1.1.1 | grep '^[0-9.]\+$' | sort | head -n1)" ]; then
curl -sSL4 "https://ipv4.ipv64.net/nic/update?key=$DUK&domain=$DUD" | tee /tmp/IPv4.json
fi
if [ "$IPv6" = "true" ] && [ "$(curl -sS6 https://ipv6.ipv64.net/ipcheck.php?ipv6)" != "$(dig "$DUD" IN AAAA +short +https +tls-ca=/etc/ssl/certs/ca-certificates.crt @1.1.1.1 | grep '^[0-9a-f:]\+$' | sort | head -n1)" ]; then
curl -sSL6 "https://ipv6.ipv64.net/nic/update?key=$DUK&domain=$DUD" | tee /tmp/IPv6.json
fi
done
sleep "$UI"
done