#!/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).

# Do not load RH compatibility interface.
WITHOUT_RC_COMPAT=1

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

PINIT=/usr/sbin/ptal-init

[ -x $PINIT ] || exit 0
RETVAL=0
export PI_WRAPPER=1

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

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

restart()
{
        stop "$@"
        start "$@"
}

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

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

COMMAND="$1"
shift

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

exit $RETVAL
