bind.sysvinit 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/sh
  2. #
  3. # System-V init to control the bind DNS Daemon
  4. #
  5. NAME=named
  6. DAEMON=/usr/sbin/$NAME
  7. # this file contains a few tunable parameters
  8. test -r /etc/default/named && . /etc/default/named
  9. test -f $DAEMON || exit 0
  10. set -e
  11. case "$1" in
  12. start)
  13. test -z "$CHROOT" || ARGS="$ARGS -t $CHROOT"
  14. test -z "$SETUID" || ARGS="$ARGS -u $SETUID"
  15. if [ ! -f $CHROOT/etc/rndc.key ]; then
  16. echo "Initializing $NAME control key: rndc-confgen"
  17. set +e
  18. # if rndc.key is a symlink, the target must exist
  19. touch $CHROOT/etc/rndc.key
  20. touch etc/rndc.key
  21. rndc-confgen -a -r /dev/urandom $ARGS || true
  22. set -e
  23. fi
  24. test -z "$CONF" || ARGS="$ARGS -c $CONF"
  25. echo -n "Starting domain name daemon: $NAME"
  26. trap 'echo failed' 0
  27. start-stop-daemon -S -x $DAEMON -- $ARGS
  28. trap - 0
  29. echo "."
  30. ;;
  31. stop)
  32. echo -n "Stopping domain name daemon: $NAME"
  33. rndc stop || start-stop-daemon -K -x $DAEMON
  34. echo "."
  35. ;;
  36. restart)
  37. $0 stop || true
  38. sleep 2
  39. $0 start
  40. ;;
  41. reload|force-reload)
  42. rndc reload || $0 restart
  43. ;;
  44. *)
  45. echo "Usage: $0 {start|stop|restart|reload|force-reload}"
  46. exit 1
  47. esac
  48. exit 0