-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-dns-glue
More file actions
executable file
·52 lines (36 loc) · 874 Bytes
/
generate-dns-glue
File metadata and controls
executable file
·52 lines (36 loc) · 874 Bytes
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
#!/bin/bash
# Copyright 2014-2015 Richard Russon (FlatCap)
# Licensed under the GPLv3
PATH="/var/named/bin:/usr/bin:/usr/sbin"
GLUE_FILE="dns-glue.inc"
source log.sh
export TZ="UTC"
set -o errexit # set -e
set -o nounset # set -u
renice --priority 19 --pid $$ > /dev/null
ionice --class 3 --pid $$ > /dev/null
shopt -s nullglob
function finish()
{
local RETVAL=$?
[ $RETVAL = 0 ] || log_error "${0##*/} failed: $RETVAL"
}
trap finish EXIT
cd /var/named
[ $# = 0 ] || exit 2
log_info "Generate DNS Glue"
if [ -f "$GLUE_FILE" ]; then
log_warning "\talready exists"
exit 0
fi
OUT=()
for i in {1..5}; do
H=$(host "ns$i.linode.com")
OUT+=("$(echo "$H" | sed -e 's/IPv6 /AAA/' -e 's/\.com has//' -e 's/address/A/')")
done
(
echo "; Maintain glue to our external dns"
printf "%s\n" "${OUT[@]}" | column -t
) > "$GLUE_FILE"
echo -e "\t$GLUE_FILE"
exit 0