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
#
Tim Waugh 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
Tim Waugh 96ea82
#
Tim Waugh 96ea82
### BEGIN INIT INFO
Tim Waugh 96ea82
# Provides: cups
Tim Waugh 96ea82
# Required-Start: $syslog $local_fs
Tim Waugh 96ea82
# Required-Stop: $syslog $local_fs
Tim Waugh 9b9807
# Should-Start: portreserve
Tim Waugh 96ea82
# Default-Start: 2 3 4 5
Tim Waugh 96ea82
# Default-Stop: 0 1 6
Tim Waugh 96ea82
# Short-Description: The CUPS scheduler
Tim Waugh 96ea82
# Description: The CUPS scheduler
Tim Waugh 96ea82
### END INIT INFO
cvsdist afac77
cvsdist afac77
# Source function library.
Jiří Popelka fa8738
. /etc/rc.d/init.d/functions
cvsdist afac77
cvsdist afac77
DAEMON=cupsd
Jiří Popelka fa8738
exec=/usr/sbin/cupsd
cvsdist 051973
prog=cups
Jiří Popelka fa8738
config=/etc/cups/cupsd.conf
f0480c
lockfile=/var/lock/subsys/cups
cvsdist 051973
Jiří Popelka 3f1034
check() {
Jiří Popelka 3f1034
	# Check that we're a privileged user
Jiří Popelka 3f1034
	[ `id -u` = 0 ] || exit 4
Jiří Popelka 3f1034
	
Jiří Popelka 3f1034
	# Check if cupsd is executable
Jiří Popelka fa8738
	[ -x $exec ] || exit 5
Jiří Popelka 3f1034
}
Jiří Popelka 3f1034
cvsdist afac77
start () {
Jiří Popelka 3f1034
	check
Jiří Popelka fa8738
	[ -f $config ] || exit 6
Jiří Popelka 3f1034
cvsdist 051973
	echo -n $"Starting $prog: "
cvsdist 051973
Tim Waugh 72452c
	# tell portreserve to release the port
Tim Waugh 72452c
	[ -x /sbin/portrelease ] && /sbin/portrelease cups &>/dev/null || :
Tim Waugh 72452c
cvsdist afac77
	# start daemon
cvsdist afac77
	daemon $DAEMON
cvsdist afac77
        RETVAL=$?
cvsdist afac77
	echo
Jiří Popelka fa8738
	[ $RETVAL = 0 ] && touch $lockfile
Tim Waugh e65f66
Tim Waugh 6729d0
	udevadm trigger --subsystem-match=usb		\
Tim Waugh 6729d0
		--attr-match=bInterfaceClass=07		\
Tim Waugh 6729d0
		--attr-match=bInterfaceSubClass=01	\
Tim Waugh 6729d0
		--action=add &>/dev/null || :
Tim Waugh 6729d0
        udevadm trigger --subsystem-match=usb		\
Tim Waugh 6729d0
		--property-match=DEVNAME="/dev/usb/lp*" \
Tim Waugh 6729d0
		--action=add &>/dev/null || :
Tim Waugh e65f66
Tim Waugh 4c0534
	return 0
cvsdist afac77
}
cvsdist afac77
cvsdist afac77
stop () {
Jiří Popelka 3f1034
	check
Jiří Popelka 3f1034
cvsdist afac77
	# stop daemon
cvsdist 79dcdc
	echo -n $"Stopping $prog: "
cvsdist afac77
	killproc $DAEMON
cvsdist afac77
	RETVAL=$?
cvsdist afac77
	echo
Jiří Popelka fa8738
	[ $RETVAL = 0 ] && rm -f $lockfile
Tim Waugh 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
	;;
Tim Waugh 4c0534
	condrestart|try-restart)
Jiří Popelka 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
	;;
Tim Waugh 4c0534
	force-reload)
Tim Waugh 4c0534
		echo -n $"Reloading $prog: "
Tim Waugh 4c0534
		if ! killproc $DAEMON -HUP; then
Tim Waugh 4c0534
			restart
Tim Waugh 4c0534
		fi
Tim Waugh 4c0534
		echo
Tim Waugh 4c0534
	;;
cvsdist afac77
	status)
f0480c
		status -l $(basename $lockfile) $DAEMON
Tim Waugh 41fae3
		RETVAL=$?
cvsdist afac77
	;;
Tim Waugh ea7be1
	restartlog)
Tim Waugh ea7be1
		stop
Tim Waugh ea7be1
		cat /dev/null >/var/log/cups/error_log
Tim Waugh ea7be1
		start
Tim Waugh ea7be1
	;;
cvsdist afac77
	*)
cvsdist afac77
Jiří Popelka 17626f
	echo $"Usage: $prog {start|stop|restart|restartlog|condrestart|try-restart|reload|force-reload|status}"
Jiří Popelka 3f1034
	exit 2
cvsdist afac77
esac
cvsdist afac77
cvsdist afac77
exit $RETVAL