update_o.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #!/bin/bash
  2. #Update script for ".o" on BIND9/Ubuntu 18.04
  3. #Variables
  4. TLD='o'
  5. NS='ns11.opennic.glue.'
  6. EMAIL='jonah.opennic.org.'
  7. CHECKZONE=/usr/sbin/named-checkzone
  8. TMP_DEST='/tmp/db.o'
  9. WORK_DIR='/opt/tld/o/'
  10. FILE_NAME='db.o'
  11. OUTPUT_DIR='/etc/bind/zone/master/o/'
  12. FILES=${WORK_DIR}zone/*
  13. cd $WORK_DIR
  14. git fetch origin master > /dev/null
  15. git reset --hard origin/master > /dev/null
  16. # ADD NEW SOA!
  17. { echo "@ IN SOA $NS $EMAIL ("
  18. echo " `date +%s` ; serial"
  19. echo " 300 ; refresh"
  20. echo " 180 ; retry"
  21. echo " 604800 ; expire"
  22. echo " 3600 ; minimum"
  23. echo " )"
  24. } >> $WORK_DIR$FILE_NAME
  25. # ADD NAMESERVERS!
  26. { echo "; TLD information"
  27. echo " IN NS ns11.opennic.glue."
  28. echo " IN NS ns9.opennic.glue."
  29. echo " IN NS ns2.opennic.glue."
  30. echo " IN NS ns6.opennic.glue."
  31. echo " IN NS ns8.opennic.glue."
  32. echo ";"
  33. echo "; Additional zones"
  34. echo ";"
  35. } >> $WORK_DIR$FILE_NAME
  36. for f in $FILES
  37. do
  38. cp $WORK_DIR$FILE_NAME $TMP_DEST
  39. cat $f >> $TMP_DEST
  40. TEST=$($CHECKZONE $TLD "$TMP_DEST" | tail -n 1)
  41. if [ "$TEST" != "OK" ]; then
  42. echo "Failed to add ${f}.o to the main zone!"
  43. else
  44. echo "Processed ${f}.o Successfully"
  45. echo "; `git log --oneline -- $f | tail -n 1`" >> $FILE_NAME
  46. cat $f >> $FILE_NAME
  47. fi
  48. VERIFY=$($CHECKZONE $TLD "$WORK_DIR$FILE_NAME" | tail -n 1)
  49. if [ "$VERIFY" != "OK" ]; then
  50. echo "Some unknown error occured: $WORK_DIR$FILE_NAME"
  51. exit 1
  52. fi
  53. done
  54. rm ${OUTPUT_DIR}db*
  55. cp $WORK_DIR$FILE_NAME $OUTPUT_DIR
  56. systemctl reload bind9