#!/bin/sh
case "`uname`" in
IRIX*)
IS_ON=/sbin/chkconfig
if $IS_ON verbose; then
ECHO=echo
else
ECHO=:
fi
ECHO_OK=:
ECHO_ERROR=:
;;
*BSD*)
IS_ON=:
ECHO=echo
ECHO_OK=:
ECHO_ERROR=:
;;
Darwin*)
. /etc/rc.common
if test "${CUPS:=-YES-}" = "-NO-"; then
exit 0
fi
IS_ON=:
ECHO=ConsoleMessage
ECHO_OK=:
ECHO_ERROR=:
;;
Linux*)
IS_ON=/bin/true
if test -f /etc/init.d/functions; then
. /etc/init.d/functions
ECHO=echo
ECHO_OK="echo_success"
ECHO_ERROR="echo_failure"
else
ECHO=echo
ECHO_OK=:
ECHO_ERROR=:
fi
;;
*)
IS_ON=/bin/true
ECHO=echo
ECHO_OK=:
ECHO_ERROR=:
;;
esac
for file in /etc/TIMEZONE /etc/rc.config /etc/sysconfig/clock; do
if test -f $file; then
. $file
fi
done
if test "x$ZONE" != x; then
TZ="$ZONE"
fi
if test "x$TIMEZONE" != x; then
TZ="$TIMEZONE"
fi
if test "x$TZ" != x; then
export TZ
fi
case "`uname`" in
HP-UX* | AIX* | SINIX*)
pid=`ps -e | awk '{if (match($4, ".*/cupsd$") || $4 == "cupsd") print $1}'`
;;
IRIX* | SunOS*)
pid=`ps -e | nawk '{if (match($4, ".*/cupsd$") || $4 == "cupsd") print $1}'`
;;
UnixWare*)
pid=`ps -e | awk '{if (match($6, ".*/cupsd$") || $6 == "cupsd") print $1}'`
. /etc/TIMEZONE
;;
OSF1*)
pid=`ps -e | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'`
;;
Linux* | *BSD* | Darwin*)
pid=`ps ax | awk '{if (match($5, ".*/cupsd$") || $5 == "cupsd") print $1}'`
;;
*)
pid=""
;;
esac
case $1 in
start | restart | reload)
if $IS_ON cups; then
if test "$pid" != ""; then
kill -HUP $pid
else
prefix=/
exec_prefix=/usr
${exec_prefix}/sbin/cupsd
if test $? != 0; then
$ECHO_FAIL
$ECHO "cups: unable to $1 scheduler."
exit 1
fi
fi
$ECHO_OK
$ECHO "cups: ${1}ed scheduler."
fi
;;
stop)
if test "$pid" != ""; then
kill $pid
$ECHO_OK
$ECHO "cups: stopped scheduler."
fi
;;
status)
if test "$pid" != ""; then
echo "cups: scheduler is running."
else
echo "cups: scheduler is not running."
fi
;;
*)
echo "Usage: cups {reload|restart|start|status|stop}"
exit 1
;;
esac
exit 0