#!/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 "$pid" != ""; then
		ConsoleMessage "Stopping printing services"
		kill "${pid}"
	else
		StartService
	fi
}

RunService "$1"
