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.

80 lines
1.9 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. logdir=/var/log/named/
  13. cachedir=/var/cache/bind
  14. libdir=/var/lib/bind
  15. dyndir=/tmp/bind
  16. conf_local_file=$dyndir/named.conf.local
  17. fix_perms() {
  18. for dir in $libdir $logdir $cachedir $dyndir; do
  19. test -e "$dir" || {
  20. mkdir -p "$dir"
  21. chgrp bind "$dir"
  22. chmod g+w "$dir"
  23. }
  24. done
  25. }
  26. reload_service() {
  27. rndc -q reload
  28. }
  29. start_service() {
  30. user_exists bind 57 || user_add bind 57
  31. group_exists bind 57 || group_add bind 57
  32. fix_perms
  33. local runnamed=$(dirname $pid_file)
  34. # with dropped privileges, we need this created for us
  35. [ -d $runnamed ] || {
  36. mkdir -m 0755 $runnamed
  37. chown bind.bind $runnamed
  38. }
  39. local rndc_temp=$(mktemp /tmp/rndc-confgen.XXXXXX)
  40. rndc-confgen > $rndc_temp
  41. sed -r -n \
  42. -e '/^# options \{$/,/^\};$/{ s/^/# / }' \
  43. -e p \
  44. -e '/^# End of rndc\.conf$/q' \
  45. < $rndc_temp > $rndc_conf_file
  46. sed -r -n \
  47. -e '1,/^# End of rndc\.conf$/ { b done }' \
  48. -e '/^# Use with the following in named.conf/ { p ; b done }' \
  49. -e '/^# End of named\.conf$/ { p ; b done }' \
  50. -e '/^# key /,$ { s/^# // ; p }' \
  51. -e ': done' \
  52. < $rndc_temp > $named_options_file
  53. rm -f $rndc_temp
  54. touch $conf_local_file
  55. procd_open_instance
  56. procd_set_param command /usr/sbin/named -u bind -f -c $config_file
  57. procd_set_param file $config_file \
  58. $config_dir/bind.keys \
  59. $named_options_file \
  60. $conf_local_file \
  61. $config_dir/db.*
  62. procd_set_param respawn
  63. procd_close_instance
  64. }