Guest User

Untitled

a guest
Jan 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.19 KB | None | 0 0
  1. #!/bin/sh -e
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides: bind9
  5. # Required-Start: $remote_fs
  6. # Required-Stop: $remote_fs
  7. # Should-Start: $network $syslog
  8. # Should-Stop: $network $syslog
  9. # Default-Start: 2 3 4 5
  10. # Default-Stop: 0 1 6
  11. # Short-Description: Start and stop bind9
  12. # Description: bind9 is a Domain Name Server (DNS)
  13. # which translates ip addresses to and from internet names
  14. ### END INIT INFO
  15.  
  16. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  17.  
  18. # for a chrooted server: "-u bind -t /var/lib/named"
  19. # Don't modify this line, change or create /etc/default/bind9.
  20. OPTIONS=""
  21. RESOLVCONF=no
  22.  
  23. test -f /etc/default/bind9 && . /etc/default/bind9
  24.  
  25. test -x /usr/sbin/rndc || exit 0
  26.  
  27. . /lib/lsb/init-functions
  28. PIDFILE=/var/named/run-root/var/run/named/named.pid
  29.  
  30. check_network() {
  31. if [ -x /usr/bin/uname ] && [ "X$(/usr/bin/uname -o)" = XSolaris ]; then
  32. IFCONFIG_OPTS="-au"
  33. else
  34. IFCONFIG_OPTS=""
  35. fi
  36. if [ -z "$(/sbin/ifconfig $IFCONFIG_OPTS)" ]; then
  37. #log_action_msg "No networks configured."
  38. return 1
  39. fi
  40. return 0
  41. }
  42.  
  43. case "$1" in
  44. start)
  45. log_daemon_msg "Starting domain name service..." "bind9"
  46.  
  47. modprobe capability >/dev/null 2>&1 || true
  48.  
  49. # dirs under /var/run can go away on reboots.
  50. mkdir -p /var/run/named
  51. chmod 775 /var/run/named
  52. chown root:bind /var/run/named >/dev/null 2>&1 || true
  53.  
  54. if [ ! -x /usr/sbin/named ]; then
  55. log_action_msg "named binary missing - not starting"
  56. log_end_msg 1
  57. fi
  58.  
  59. if ! check_network; then
  60. log_action_msg "no networks configured"
  61. log_end_msg 1
  62. fi
  63.  
  64. if start-stop-daemon --start --oknodo --quiet --exec /usr/sbin/named \
  65. --pidfile ${PIDFILE} -- $OPTIONS; then
  66. if [ "X$RESOLVCONF" != "Xno" ] && [ -x /sbin/resolvconf ] ; then
  67. echo "nameserver 127.0.0.1" | /sbin/resolvconf -a lo.named
  68. fi
  69. log_end_msg 0
  70. else
  71. log_end_msg 1
  72. fi
  73. ;;
  74.  
  75. stop)
  76. log_daemon_msg "Stopping domain name service..." "bind9"
  77. if ! check_network; then
  78. log_action_msg "no networks configured"
  79. log_end_msg 1
  80. fi
  81.  
  82. if [ "X$RESOLVCONF" != "Xno" ] && [ -x /sbin/resolvconf ] ; then
  83. /sbin/resolvconf -d lo.named
  84. fi
  85. pid=$(/usr/sbin/rndc stop ; sleep 1 ; killall -9 named -p | awk '/^pid:/ {print $2}') || true
  86. if [ -z "$pid" ]; then # no pid found, so either not running, or error
  87. pid=$(pgrep -f ^/usr/sbin/named) || true
  88. start-stop-daemon --stop --oknodo --quiet --exec /usr/sbin/named \
  89. --pidfile ${PIDFILE} -- $OPTIONS
  90. fi
  91. if [ -n $pid ]; then
  92. while kill -0 $pid 2>/dev/null; do
  93. log_progress_msg "waiting for pid $pid to die"
  94. sleep 1
  95. done
  96. fi
  97. log_end_msg 0
  98. ;;
  99.  
  100. reload|force-reload)
  101. log_daemon_msg "Reloading domain name service..." "bind9"
  102. if ! check_network; then
  103. log_action_msg "no networks configured"
  104. log_end_msg 1
  105. fi
  106.  
  107. /usr/sbin/rndc reload >/dev/null && log_end_msg 0 || log_end_msg 1
  108. ;;
  109.  
  110. restart)
  111. if ! check_network; then
  112. log_action_msg "no networks configured"
  113. exit 1
  114. fi
  115.  
  116. $0 stop
  117. $0 start
  118. ;;
  119.  
  120. status)
  121. ret=0
  122. status_of_proc -p ${PIDFILE} /usr/sbin/named bind9 2>/dev/null || ret=$?
  123. exit $ret
  124. ;;
  125.  
  126. *)
  127. log_action_msg "Usage: /etc/init.d/bind9 {start|stop|reload|restart|force-reload|status}"
  128. exit 1
  129. ;;
  130. esac
  131.  
  132. exit 0
Add Comment
Please, Sign In to add comment