-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclean
executable file
·63 lines (45 loc) · 1.13 KB
/
clean
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
#!/bin/sh
# 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
[ $# = 0 ] && exit 2
log_info "Cleanup"
if [ $# = 1 -a "$1" = "all" ]; then
set -- $DNSSEC_DOMAINS
echo -e "\tShared resources"
rm --force dns-glue.inc
rm --force named.ca
rm --force ssh-fingerprint.inc
echo -e "\tShared directories"
rm --force --recursive data
rm --force --recursive dynamic
rm --force --recursive slaves
rm --force --recursive "$DNSSEC_KEY_DIR"
echo -e "\tReset zone files"
rm --force *.db
git checkout -- '*.db'
fi
for ZONE in "$@"; do
echo -e "\tZone: $ZONE"
rm --force ${ZONE}.db.signed
rm --force ${ZONE}.tlsa.inc
rm --force ${ZONE}.dkim.inc
rm --force ${ZONE}.gpg.inc
rm --force "$DNSSEC_KEY_DIR"/K${ZONE}.*
rm --force "$DNSSEC_KEY_DIR"/dsset-${ZONE}.
done
exit 0