#!/bin/sh
########################################################################
# Begin cups
#
# Description : Start cups daemon
#
# Author      : Bruce Dubbs - bdubbs@linuxfromscratch.org
#
# Version     : LFS 7.0
#
########################################################################
#=================================================================
# Begin cups
#
# Description : Start cups daemon
# chkconfig: 2345 75 15
#
#=================================================================

### BEGIN INIT INFO
# Provides:            $cups
# Required-Start:      $network
# Should-Start:        $remote_fs haldaemon
# Required-Stop:       $network
# Should-Stop:         haldaemon $remote_fs
# Default-Start:       3 4 5
# Default-Stop:        0 1 2 6
# Short-Description:   Starts cups print daemon.
# Description:         Starts cups print daemon.
# X-LFS-Provided-By:   BLFS / LFS 7.0
### END INIT INFO

. /lib/lsb/init-functions

PROG="cupsd"
BIN_FILE="/usr/sbin/$PROG"
PID_FILE=/var/run/cups/$PROG.pid

do_start()

{
log_info_msg "Starting CUPS Printserver..."
$BIN_FILE < /dev/null > /dev/null 2>&1 &
evaluate_retval
}

do_stop()

{
log_info_msg "Stopping CUPS Printserver..."
killproc $BIN_FILE
evaluate_retval
}

case $1 in
   start)
      do_start
      ;;

   stop)
      do_stop
      ;;

   reload)
      log_info_msg "Reloading CUPS Printserver..."
      killproc $BIN_FILE -HUP
      evaluate_retval
      ;;

   restart)
      do_stop
      sleep 1
      do_start
      ;;

   condrestart)
      pid=`cat $PID_FILE 2>/dev/null`
      if [ -n "${pid}"  -a -d /proc/$pid ]; then
        do_stop
        sleep 1
        do_start
	fi
      ;;

   status)
      statusproc $BIN_FILE
      ;;

   *)
      echo "Usage: $0 {start|stop|reload|restart|condrestart|status}"
      exit 1
      ;;
esac

# End /etc/init.d/cups
