-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow-keys
executable file
·50 lines (36 loc) · 1 KB
/
show-keys
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
#!/bin/bash
# Copyright 2014-2015 Richard Russon (FlatCap)
# Licensed under the GPLv3
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
[ ! -d "$DNSSEC_KEY_DIR" ] && exit 0
if [ $# = 0 ]; then
FILES=("$DNSSEC_KEY_DIR"/K*.key)
else
for i in "$@"; do
FILES=("$DNSSEC_KEY_DIR"/K${i}.*.key)
done
fi
[ ${#FILES[@]} = 0 ] && exit 0
for type in "key-signing" "zone-signing"; do
log_info "$type keys"
ls -1 --sort=time --reverse "$DNSSEC_KEY_DIR"/*.key | while read x; do
grep --quiet $type "$x" || continue
echo $x
grep -e "Activate" -e "Inactive" $x | sed -e 's/^; /\t/' -e 's/\([0-9][0-9][0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)\([0-9][0-9]\)/\1-\2-\3 \4:\5:\6/'
done
echo
done