PrintingServices   [plain text]


#!/bin/sh

##
# PrintingServices - a.k.a. CUPS
##

. /etc/rc.common

StartService ()
{
	if [ "${CUPS:=-YES-}" = "-YES-" ]; then
		ConsoleMessage "Starting printing services"
		/usr/sbin/cupsd
    fi
}

StopService ()
{
	# Until cupsd has a pid file...
	pid=`ps ax | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'`
	if test "$pid" != ""; then
		ConsoleMessage "Stopping printing services"
		kill "${pid}"
    fi
}

RestartService ()
{
	# Until cupsd has a pid file...
	pid=`ps ax | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'`
	if test "x$pid" != x; then
		ConsoleMessage "Restarting printing services"
		kill -HUP "${pid}"
	else
		StartService
	fi
}

RunService "$1"