#!/bin/sh
#
# cups-config-daemon:   Cups configuration daemon
#
# chkconfig: 345 98 02
# description:  This is a daemon for configuring printers through D-BUS
#
# processname: cups-config-daemon
# pidfile: /var/run/cups-config-daemon.pid
#

# Sanity checks.
[ -x /usr/bin/cups-config-daemon ] || exit 0

# Source function library.
. /etc/rc.d/init.d/functions

# so we can rearrange this easily
processname=cups-config-daemon
servicename=cups-config-daemon

RETVAL=0

start() {
    echo -n $"Starting cups-config-daemon: "
    daemon --check $servicename $processname
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$servicename && echo `/sbin/pidof $processname` > /var/run/cups-config-daemon.pid
}

stop() {
    echo -n $"Stopping cups-config-daemon: "

    killproc $servicename -TERM
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f /var/lock/subsys/$servicename
        rm -f /var/run/cups-config-daemon.pid
    fi
}

# See how we were called.
case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    status)
        status $processname
        RETVAL=$?
        ;;
    restart)
        stop
        start
        ;;
    condrestart)
        if [ -f /var/lock/subsys/$servicename ]; then
            stop
            start
        fi
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|condrestart}"
        ;;
esac
exit $RETVAL
