#!/bin/sh
#
-# "$Id$"
+# cups Common UNIX Printing System (CUPS)
#
-# Startup/shutdown script for the Common UNIX Printing System (CUPS).
-#
-# Linux chkconfig stuff:
-#
-# chkconfig: 0235 99 00
-# description: Startup/shutdown script for the Common UNIX \
-# Printing System (CUPS).
-#
-# Copyright 1997-2000 by Easy Software Products, all rights reserved.
-#
-# These coded instructions, statements, and computer programs are the
-# property of Easy Software Products and are protected by Federal
-# copyright law. Distribution and use rights are outlined in the file
-# "LICENSE.txt" which should have been included with this file. If this
-# file is missing or damaged please contact Easy Software Products
-# at:
-#
-# Attn: CUPS Licensing Information
-# Easy Software Products
-# 44141 Airport View Drive, Suite 204
-# Hollywood, Maryland 20636-3111 USA
-#
-# Voice: (301) 373-9603
-# EMail: cups-info@cups.org
-# WWW: http://www.cups.org
+# chkconfig: 2345 90 10
+# description: Startup/shutdown script for the Common UNIX \
+# Printing System (CUPS).
+# processname: cupsd
#
-# See what program to use for configuration stuff...
-case "`uname`" in
- IRIX*)
- IS_ON=/sbin/chkconfig
- ;;
+# Source function library
+. /etc/rc.d/init.d/functions
- *)
- IS_ON=/bin/true
- ;;
-esac
+# Get network config
+. /etc/sysconfig/network
+
+# Get service config - may override defaults
+[ -f /etc/sysconfig/cups ] && . /etc/sysconfig/cups
-# The verbose flag controls the printing of the names of
-# daemons as they are started.
-if $IS_ON verbose; then
- ECHO=echo
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down CUPS
+ exit 1
+ fi
else
- ECHO=:
+ exit 0
fi
-# See if the CUPS server is running...
-case "`uname`" in
- IRIX* | HP-UX | SunOS)
- pid=`ps -e | awk '{print $1,$4}' | grep cupsd | awk '{print $1}'`
- ;;
- OSF1)
- pid=`ps -e | awk '{print $1,$5}' | grep cupsd | awk '{print $1}'`
- ;;
- Linux)
- pid=`ps ax | awk '{print $1,$5}' | grep cupsd | awk '{print $1}'`
- ;;
- *)
- pid=""
- ;;
-esac
+start() {
+ # Check if the service is already running?
+ if [ -f /var/lock/subsys/cups ]; then
+ msg_already_running CUPS
+ return
+ fi
-# Start or stop the CUPS server based upon the first argument to the script.
-case $1 in
- start | restart | reload)
- if test "$pid" != ""; then
- if $IS_ON cups; then
- kill -HUP $pid
- $ECHO "cups: scheduler restarted."
- else
- kill $pid
- $ECHO "cups: scheduler stopped."
- fi
- else
- if $IS_ON cups; then
- prefix=/usr
- exec_prefix=/usr
- /usr/sbin/cupsd
- $ECHO "cups: scheduler started."
- fi
- fi
- ;;
+ msg_starting CUPS
+ daemon /usr/sbin/cupsd -c /etc/cups/cupsd.conf
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/cups
+}
- stop)
- if test "$pid" != ""; then
- kill $pid
- $ECHO "cups: scheduler stopped."
- fi
- ;;
+stop() {
+ # Stop daemons.
+ if [ ! -f /var/lock/subsys/cups ]; then
+ msg_not_running CUPS
+ return
+ fi
- status)
- if test "$pid" != ""; then
- echo "cups: Scheduler is running."
- else
- echo "cups: Scheduler is not running."
- fi
- ;;
+ msg_stopping CUPS
+ killproc cupsd
+ rm -f /var/lock/subsys/cups >/dev/null 2>&1
+}
- *)
- echo "Usage: cups {reload|restart|start|status|stop}"
- exit 1
- ;;
-esac
+reload() {
+ if [ ! -f /var/lock/subsys/cups ]; then
+ msg_not_running CUPS
+ RETVAL=7
+ return
+ fi
-exit 0
+ msg_reloading CUPS
+ killproc cupsd -HUP
+ RETVAL=$?
+}
+RETVAL=0
+# See how we were called.
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ reload|force-reload)
+ reload
+ ;;
+ status)
+ status cups cupsd
+ exit $?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
+ exit 3
+esac
-#
-# End of "$Id$".
-#
+exit $RETVAL