You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
1.7 KiB

  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2014 Noah Meyerhans <frodo@morgul.net>
  3. # Licensed under the terms of the GNU General Public License version 2
  4. # or (at your discretion) any later later version
  5. USE_PROCD=1
  6. START=22
  7. config_file=/etc/bind/named.conf
  8. config_dir=$(dirname $config_file)
  9. named_options_file=/etc/bind/named-rndc.conf
  10. rndc_conf_file=/etc/bind/rndc.conf
  11. pid_file=/var/run/named/named.pid
  12. rndc_temp=$(mktemp /tmp/rndc-confgen.XXXXXX)
  13. logdir=/var/log/named/
  14. cachedir=/var/cache/bind
  15. libdir=/var/lib/bind
  16. dyndir=/tmp/bind
  17. conf_local_file=$dyndir/named.conf.local
  18. fix_perms() {
  19. for dir in $libdir $logdir $cachedir $dyndir; do
  20. test -e "$dir" || {
  21. mkdir -p "$dir"
  22. chgrp bind "$dir"
  23. chmod g+w "$dir"
  24. }
  25. done
  26. }
  27. reload_service() {
  28. rndc -q reload
  29. }
  30. start_service() {
  31. user_exists bind 57 || user_add bind 57
  32. group_exists bind 57 || group_add bind 57
  33. fix_perms
  34. rndc-confgen > $rndc_temp
  35. sed -r -n \
  36. -e '/^# options \{$/,/^\};$/{ s/^/# / }' \
  37. -e p \
  38. -e '/^# End of rndc\.conf$/q' \
  39. < $rndc_temp > $rndc_conf_file
  40. sed -r -n \
  41. -e '1,/^# End of rndc\.conf$/ { b done }' \
  42. -e '/^# Use with the following in named.conf/ { p ; b done }' \
  43. -e '/^# End of named\.conf$/ { p ; b done }' \
  44. -e '/^# key /,$ { s/^# // ; p }' \
  45. -e ': done' \
  46. < $rndc_temp > $named_options_file
  47. rm -f $rndc_temp
  48. touch $conf_local_file
  49. procd_open_instance
  50. procd_set_param command /usr/sbin/named -u bind -f -c $config_file
  51. procd_set_param file $config_file \
  52. $config_dir/bind.keys \
  53. $named_options_file \
  54. $conf_local_file \
  55. $config_dir/db.*
  56. procd_set_param respawn
  57. procd_close_instance
  58. }