-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-tlsa
executable file
·54 lines (38 loc) · 946 Bytes
/
generate-tlsa
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
#!/bin/bash
# Copyright 2014-2015 Richard Russon (FlatCap)
# Licensed under the GPLv3
SUFFIX="tlsa.inc"
PATH="/var/named/bin:/usr/bin:/usr/sbin"
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 TLSA Records for Services"
for ZONE in $@; do
FILE="$ZONE.$SUFFIX"
if [ -f "$FILE" ]; then
log_warning "\t$ZONE already exists"
continue
fi
OUT=()
for PORT in $DNSSEC_PORTS; do
OUT+=("$(danetool --load-certificate /etc/pki/tls/certs/$ZONE.crt --proto tcp --port $PORT --host $ZONE --tlsa-rr)")
done
(
echo '; TLSA records for services'
printf "%s\n" "${OUT[@]}"
) > "$FILE"
echo -e "\t$ZONE: $DNSSEC_PORTS"
done
exit 0