blob: 0476242d6ebb2c2fed00e3046bb7334fc3f7cf5e (
plain)
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
|
#!/bin/bash
# update dns records of
# pool.mirror.archlinux32.org = CNAME pool32.ddns.eckner.net
# either called with 1 argument (the ip to check and add) or without
# arguments (all known mirrors will be checked in parallel)
if [ $# -eq 1 ]; then
if [ "${1%.*}" != "$1" ]; then
ipver='A'
elif [ "${1%:*}" != "$1" ]; then
ipver='AAAA'
else
exit
fi
if [ "$(curl \
-w '%{http_code}' \
-o /dev/null \
--connect-timeout 10 \
--resolve "pool.mirror.archlinux32.org:80:$1" \
-s 'http://pool.mirror.archlinux32.org/i686/')" != '200' ]; then
exit
fi
printf '%s %s\n' "${ipver}" "$1"
exit
fi
{
for type in 'A' 'AAAA'; do
printf '%s\n' \
'zone ddns.eckner.net.' \
'prereq yxrrset pool32.ddns.eckner.net IN '"${type}" \
'update delete pool32.ddns.eckner.net IN '"${type}" \
'send'
done
printf 'zone ddns.eckner.net.\n'
curl -s 'https://packages.archlinux32.org/mirrors/status.php?tsv' | \
{
read -r headers
url_column=$(
printf '%s\n' "${headers}" | \
tr '\t' '\n' | \
grep -nxF 'url' | \
cut -d: -f1
)
recently_active_column=$(
printf '%s\n' "${headers}" | \
tr '\t' '\n' | \
grep -nxF 'recently_active' | \
cut -d: -f1
)
awk '{
print $'"${recently_active_column}"' "\t" $'"${url_column}"'
}'
} | \
sed -n '
s/^1\t//
T
\|//mirror\.archlinux32\.org/|d
s|[^:]\+://||
T
s|/.*$||
p
' | \
sort -u | \
parallel -j0 getent ahosts | \
sed -n '
s/\s\+STREAM\(\s.*\)\?$//
T
p
' | \
sort -u | \
parallel -j0 "$0" | \
sed '
s/^/update add pool32.ddns.eckner.net. 3600 IN /
'
printf '%s\n' \
'send'
} | \
nsupdate -l
exit 0
|