File unbound.init of Package unbound

#!/bin/bash
#
# chkconfig:    35 11 89
# description:  a validating, recursive, and caching DNS resolver
#
### BEGIN INIT INFO
# Provides:          unbound
# Required-Start:    $syslog $network $remote_fs
# Required-Stop:     $syslog $network $remote_fs
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: DNS resolver
# Description:       validating, recursive, and caching DNS resolver
### END INIT INFO

UNBOUND_BIN=/usr/sbin/unbound
UNBOUND_PID=/var/run/unbound.pid

if [ -r /etc/rc.status ]
then
  source /etc/rc.status
  START="/sbin/startproc"
  STATUS="/sbin/checkproc"
  SUCCESS="echo \$rc_done"
  FAILURE="echo \$rc_failed"
else
  source /etc/rc.d/init.d/functions
  START="daemon"
  STATUS="status"
  SUCCESS="success; echo"
  FAILURE="failure; echo"
fi

RETVAL=0

case "$1" in
  start)
    if $0 checkconf
    then
      echo -n "Starting Unbound: "
      ${START} ${UNBOUND_BIN}
      RETVAL=$?
    else
      exit 1
    fi
    ;;
  stop)
    echo -n "Stopping Unbound: "
    killproc ${UNBOUND_BIN} > /dev/null 2>&1
    RETVAL=$?
    ;;
  restart)
    if $0 checkconf
    then
      $0 stop
      $0 start
      unset RETVAL
    else
      exit 1
    fi
    ;;
  reload)
    if $0 checkconf
    then
      echo -n "Reloading configuration of Unbound: "
      killproc -HUP ${UNBOUND_BIN} > /dev/null 2>&1
      RETVAL=$?
    else
      exit 1
    fi
    ;;
  status)
    echo -n "Status of Unbound: "
    ${STATUS} ${UNBOUND_BIN} > /dev/null 2>&1
    RETVAL=$?
    ;;
  checkconf)
    echo -n "Checking configuration of Unbound: "
    unbound-checkconf > /dev/null 2>&1
    RETVAL=$?
    ;;
  *)
    echo "Usage: $0 {start|stop|status|restart|reload|checkconf}"
    exit 1
    ;;
esac
[ -z ${RETVAL} ] && exit
[ ${RETVAL} -eq 0 ] && eval "${SUCCESS}" || eval "${FAILURE}"
exit ${RETVAL}
openSUSE Build Service is sponsored by