#!/bin/sh
#
# hpoj        A wrapper script for ptal-init
#
# chkconfig: 2345 59 61
# description: hpoj is the init script and device setup utility \
#              for the HP OfficeJet Linux driver.
# Should be started before and stopped after your print spooler (lpd or CUPS).

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

PINIT=/usr/sbin/ptal-init

[ -x $PINIT ] || exit 0
RETVAL=0

start()
{
        action "Starting the HP OfficeJet Linux driver:" $PINIT start "${PARAMS[@]}"
        RETVAL=$?
        return $RETVAL
}

stop()
{
        action "Stopping the HP OfficeJet Linux driver:" $PINIT stop "${PARAMS[@]}"
        RETVAL=$?
        return $RETVAL
}

restart()
{
        stop
        start
}

condstop()
{
        if $PINIT status "${PARAMS[@]}" &> /dev/null; then
                stop
        fi
}

condrestart()
{
        if $PINIT status "${PARAMS[@]}" &> /dev/null; then
                restart
        fi
}

COMMAND="$1"
shift
PARAMS=("$@" "-quiet")
for opt in "$@"
do
        if [ "$opt" = "-v" -o "$opt" = "-verbose" ]; then
                PARAMS=("$@")
                break
        fi
done

case "$COMMAND" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart|reload)
        restart
        ;;
  condstop)
        condstop
        ;;
  condrestart)
        condrestart
        ;;
  *)
        $PINIT $COMMAND "$@"
        RETVAL=$?
esac

exit $RETVAL
