cvsdist afac77e
#!/bin/sh
cvsdist afac77e
#
cvsdist afac77e
# "$Id: cups.sh,v 1.10 2000/03/30 05:19:16 mike Exp $"
cvsdist afac77e
#
cvsdist afac77e
#   Startup/shutdown script for the Common UNIX Printing System (CUPS).
cvsdist afac77e
#
cvsdist afac77e
#   Linux chkconfig stuff:
cvsdist afac77e
#
5852cfd
#   chkconfig: 2345 25 10
cvsdist afac77e
#   description: Startup/shutdown script for the Common UNIX \
cvsdist afac77e
#                Printing System (CUPS).
cvsdist afac77e
#
cvsdist afac77e
#   Copyright 1997-2000 by Easy Software Products, all rights reserved.
cvsdist afac77e
#
cvsdist afac77e
#   These coded instructions, statements, and computer programs are the
cvsdist afac77e
#   property of Easy Software Products and are protected by Federal
cvsdist afac77e
#   copyright law.  Distribution and use rights are outlined in the file
cvsdist afac77e
#   "LICENSE.txt" which should have been included with this file.  If this
cvsdist afac77e
#   file is missing or damaged please contact Easy Software Products
cvsdist afac77e
#   at:
cvsdist afac77e
#
cvsdist afac77e
#       Attn: CUPS Licensing Information
cvsdist afac77e
#       Easy Software Products
cvsdist afac77e
#       44141 Airport View Drive, Suite 204
cvsdist afac77e
#       Hollywood, Maryland 20636-3111 USA
cvsdist afac77e
#
cvsdist afac77e
#       Voice: (301) 373-9603
cvsdist afac77e
#       EMail: cups-info@cups.org
cvsdist afac77e
#         WWW: http://www.cups.org
cvsdist afac77e
#
cvsdist afac77e
# heavily edited so that it's more like other scripts in init.d on Red Hat
cvsdist afac77e
# Linux
96ea82a
#
96ea82a
### BEGIN INIT INFO
96ea82a
# Provides: cups
96ea82a
# Required-Start: $syslog $local_fs
96ea82a
# Required-Stop: $syslog $local_fs
9b9807e
# Should-Start: portreserve
96ea82a
# Default-Start: 2 3 4 5
96ea82a
# Default-Stop: 0 1 6
96ea82a
# Short-Description: The CUPS scheduler
96ea82a
# Description: The CUPS scheduler
96ea82a
### END INIT INFO
cvsdist afac77e
cvsdist afac77e
# Source function library.
fa87387
. /etc/rc.d/init.d/functions
cvsdist afac77e
cvsdist afac77e
DAEMON=cupsd
fa87387
exec=/usr/sbin/cupsd
cvsdist 0519732
prog=cups
fa87387
config=/etc/cups/cupsd.conf
f0480cb
lockfile=/var/lock/subsys/cups
cvsdist 0519732
3f10348
check() {
3f10348
	# Check that we're a privileged user
3f10348
	[ `id -u` = 0 ] || exit 4
3f10348
	
3f10348
	# Check if cupsd is executable
fa87387
	[ -x $exec ] || exit 5
3f10348
}
3f10348
cvsdist afac77e
start () {
3f10348
	check
fa87387
	[ -f $config ] || exit 6
3f10348
cvsdist 0519732
	echo -n $"Starting $prog: "
cvsdist 0519732
72452c8
	# tell portreserve to release the port
72452c8
	[ -x /sbin/portrelease ] && /sbin/portrelease cups &>/dev/null || :
72452c8
cvsdist afac77e
	# start daemon
cvsdist afac77e
	daemon $DAEMON
cvsdist afac77e
        RETVAL=$?
cvsdist afac77e
	echo
fa87387
	[ $RETVAL = 0 ] && touch $lockfile
e65f669
6729d05
	udevadm trigger --subsystem-match=usb		\
6729d05
		--attr-match=bInterfaceClass=07		\
6729d05
		--attr-match=bInterfaceSubClass=01	\
6729d05
		--action=add &>/dev/null || :
6729d05
        udevadm trigger --subsystem-match=usb		\
6729d05
		--property-match=DEVNAME="/dev/usb/lp*" \
6729d05
		--action=add &>/dev/null || :
e65f669
4c05344
	return 0
cvsdist afac77e
}
cvsdist afac77e
cvsdist afac77e
stop () {
3f10348
	check
3f10348
cvsdist afac77e
	# stop daemon
cvsdist 79dcdc0
	echo -n $"Stopping $prog: "
cvsdist afac77e
	killproc $DAEMON
cvsdist afac77e
	RETVAL=$?
cvsdist afac77e
	echo
fa87387
	[ $RETVAL = 0 ] && rm -f $lockfile
4c05344
	return 0
cvsdist afac77e
}
cvsdist afac77e
cvsdist afac77e
restart() {
cvsdist afac77e
	stop
cvsdist afac77e
	start
cvsdist afac77e
}
cvsdist afac77e
cvsdist afac77e
case $1 in
cvsdist afac77e
	start)
cvsdist afac77e
		start
cvsdist afac77e
	;;
cvsdist afac77e
	stop)
cvsdist afac77e
		stop
cvsdist afac77e
	;;
cvsdist afac77e
	restart)
cvsdist afac77e
		restart
cvsdist afac77e
	;;
4c05344
	condrestart|try-restart)
fa87387
		[ -f $lockfile ] && restart || :
cvsdist afac77e
	;;	
cvsdist 0519732
	reload)
cvsdist 0519732
		echo -n $"Reloading $prog: "
cvsdist 0519732
		killproc $DAEMON -HUP
cvsdist 0519732
		RETVAL=$?
cvsdist 0519732
		echo
cvsdist 0519732
	;;
4c05344
	force-reload)
4c05344
		echo -n $"Reloading $prog: "
4c05344
		if ! killproc $DAEMON -HUP; then
4c05344
			restart
4c05344
		fi
4c05344
		echo
4c05344
	;;
cvsdist afac77e
	status)
f0480cb
		status -l $(basename $lockfile) $DAEMON
41fae3e
		RETVAL=$?
cvsdist afac77e
	;;
ea7be1d
	restartlog)
ea7be1d
		stop
ea7be1d
		cat /dev/null >/var/log/cups/error_log
ea7be1d
		start
ea7be1d
	;;
cvsdist afac77e
	*)
cvsdist afac77e
17626f1
	echo $"Usage: $prog {start|stop|restart|restartlog|condrestart|try-restart|reload|force-reload|status}"
3f10348
	exit 2
cvsdist afac77e
esac
cvsdist afac77e
cvsdist afac77e
exit $RETVAL