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