2019-03-23 20:01:47 -05:00
|
|
|
#!/bin/bash
|
|
|
|
#Update script for ".o" on BIND9/Ubuntu 18.04
|
|
|
|
|
|
|
|
#Variables
|
2019-03-23 20:11:16 -05:00
|
|
|
TLD='o'
|
2019-03-23 20:26:43 -05:00
|
|
|
NS='ns11.opennic.glue.'
|
|
|
|
EMAIL='jonah.opennic.org.'
|
2019-03-23 20:11:16 -05:00
|
|
|
CHECKZONE=/usr/sbin/named-checkzone
|
2019-03-23 20:01:47 -05:00
|
|
|
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
|
|
|
|
|
2019-03-23 20:26:43 -05:00
|
|
|
# ADD NEW SOA!
|
|
|
|
{ echo "@ IN SOA $NS $EMAIL ("
|
|
|
|
echo " `date +%s` ; serial"
|
2019-03-25 10:59:07 -05:00
|
|
|
echo " 300 ; refresh"
|
|
|
|
echo " 180 ; retry"
|
|
|
|
echo " 604800 ; expire"
|
2019-03-25 11:00:50 -05:00
|
|
|
echo " 3600 ; minimum"
|
2019-03-23 20:26:43 -05:00
|
|
|
echo " )"
|
|
|
|
} >> $WORK_DIR$FILE_NAME
|
|
|
|
|
|
|
|
# ADD NAMESERVERS!
|
|
|
|
{ echo "; TLD information"
|
|
|
|
echo " IN NS ns11.opennic.glue."
|
2019-03-25 19:06:44 -05:00
|
|
|
echo " IN NS ns9.opennic.glue."
|
2019-03-23 21:27:14 -05:00
|
|
|
echo " IN NS ns2.opennic.glue."
|
|
|
|
echo " IN NS ns6.opennic.glue."
|
|
|
|
echo " IN NS ns8.opennic.glue."
|
2019-03-23 20:26:43 -05:00
|
|
|
echo ";"
|
|
|
|
echo "; Additional zones"
|
|
|
|
echo ";"
|
|
|
|
} >> $WORK_DIR$FILE_NAME
|
|
|
|
|
|
|
|
|
2019-03-23 20:01:47 -05:00
|
|
|
for f in $FILES
|
|
|
|
do
|
|
|
|
cp $WORK_DIR$FILE_NAME $TMP_DEST
|
|
|
|
cat $f >> $TMP_DEST
|
|
|
|
|
2019-03-23 20:11:16 -05:00
|
|
|
TEST=$($CHECKZONE $TLD "$TMP_DEST" | tail -n 1)
|
2019-03-23 20:12:33 -05:00
|
|
|
if [ "$TEST" != "OK" ]; then
|
2019-03-23 20:01:47 -05:00
|
|
|
echo "Failed to add ${f}.o to the main zone!"
|
|
|
|
else
|
|
|
|
echo "Processed ${f}.o Successfully"
|
2019-03-23 20:26:43 -05:00
|
|
|
echo "; `git log --oneline -- $f | tail -n 1`" >> $FILE_NAME
|
2019-03-23 20:01:47 -05:00
|
|
|
cat $f >> $FILE_NAME
|
|
|
|
fi
|
|
|
|
|
2019-03-23 20:11:16 -05:00
|
|
|
VERIFY=$($CHECKZONE $TLD "$WORK_DIR$FILE_NAME" | tail -n 1)
|
2019-03-23 20:12:33 -05:00
|
|
|
if [ "$VERIFY" != "OK" ]; then
|
2019-03-23 20:01:47 -05:00
|
|
|
echo "Some unknown error occured: $WORK_DIR$FILE_NAME"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
rm ${OUTPUT_DIR}db*
|
2019-03-23 20:11:16 -05:00
|
|
|
cp $WORK_DIR$FILE_NAME $OUTPUT_DIR
|
2019-03-23 20:01:47 -05:00
|
|
|
|
|
|
|
systemctl reload bind9
|