#!/bin/sh
#########################################################################
#
# Start / stop script for mtinkd
#
# In order to be distibution independant, the server known a few
# extra commands:
#   start
#   stop
#   status
#
# other typical commands as restart are implemented as
# call from start and restart
#
# Author Jean-Jacques Sarton
#        jj.sarton@ t-online.de
#        http://xwtools.automatix.de
#
# Version 0.3-Mdk 29-08-2002
#
##########################################################################


# define the device file, adapt this
#DEV_FILE=/dev/lp0
DEV_FILE=/dev/usb/lp0

# Special options, adapt this
# add name of printer
NAME=

# use the first line for USB printers, the second for parallel port printers
SPEC="-name $NAME -usbbase /dev/usb/lp"
#SPEC="-name $NAME"
# or if /etc/mtinkd.conf exist for this file.
if [ -f /etc/mtinkd.conf ]
then
   SPEC=`sed -n 1p /etc/mtinkd.conf`
fi

# where the program is located

PROG=/usr/local/sbin/mtinkd

case $1 in
   start|stop|status)
      echo "$1 `basename $0` for $DEV_FILE $SPEC"
      $PROG $1 -dev $DEV_FILE $SPEC
      RETVAL=$?;;
   restart)
      echo "stop `basename $0` for $DEV_FILE $SPEC"
      $PROG stop -dev $DEV_FILE $SPEC
      sleep 2
      echo "start `basename $0` for $DEV_FILE $SPEC"
      $PROG start -dev $DEV_FILE $SPEC
      RETVAL=$?;;
   *)
      echo "Syntax `basename $0` start|stop|status|restart"
      RETVAL=1;;
esac

exit $RETVAL
