forked from moderntld/.o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_o.sh
66 lines (56 loc) · 1.52 KB
/
update_o.sh
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
#!/bin/bash
#Update script for ".o" on BIND9/Ubuntu 18.04
#Variables
TLD='o'
NS='ns11.opennic.glue.'
EMAIL='jonah.opennic.org.'
CHECKZONE=/usr/sbin/named-checkzone
TMP_DEST='/tmp/db.o'
WORK_DIR='/opt/tld/o/'
FILE_NAME='db.o'
OUTPUT_DIR='/etc/bind/zone/master/o/'
FILES=${WORK_DIR}zone/*
cd $WORK_DIR
git fetch origin master > /dev/null
git reset --hard origin/master > /dev/null
# ADD NEW SOA!
{ echo "@ IN SOA $NS $EMAIL ("
echo " `date +%s` ; serial"
echo " 300 ; refresh"
echo " 180 ; retry"
echo " 604800 ; expire"
echo " 3600 ; minimum"
echo " )"
} >> $WORK_DIR$FILE_NAME
# ADD NAMESERVERS!
{ echo "; TLD information"
echo " IN NS ns11.opennic.glue."
echo " IN NS ns9.opennic.glue."
echo " IN NS ns2.opennic.glue."
echo " IN NS ns6.opennic.glue."
echo " IN NS ns8.opennic.glue."
echo ";"
echo "; Additional zones"
echo ";"
} >> $WORK_DIR$FILE_NAME
for f in $FILES
do
cp $WORK_DIR$FILE_NAME $TMP_DEST
cat $f >> $TMP_DEST
TEST=$($CHECKZONE $TLD "$TMP_DEST" | tail -n 1)
if [ "$TEST" != "OK" ]; then
echo "Failed to add ${f}.o to the main zone!"
else
echo "Processed ${f}.o Successfully"
echo "; `git log --oneline -- $f | tail -n 1`" >> $FILE_NAME
cat $f >> $FILE_NAME
fi
VERIFY=$($CHECKZONE $TLD "$WORK_DIR$FILE_NAME" | tail -n 1)
if [ "$VERIFY" != "OK" ]; then
echo "Some unknown error occured: $WORK_DIR$FILE_NAME"
exit 1
fi
done
rm ${OUTPUT_DIR}db*
cp $WORK_DIR$FILE_NAME $OUTPUT_DIR
systemctl reload bind9