Repository URL to install this package:
|
Version:
2.58-1 ▾
|
#!/bin/sh
############################################################################
# tpdaemon
#
# Script to start/stop TurboPrint printer port daemon
# (c) ZEDOnet GmbH
# Created 15-Nov-07
# 22-12-08 added Required-Start / Required-Stop entries in header
# 19-01-12 removed "&" after "tprintdaemon" (start in background)
# as it caused problems with systemd
############################################################################
### BEGIN INIT INFO
# Provides: tpdaemon
# Required-Start:
# Required-Stop:
# Should-Start: $ALL
# Default-Start: 2 3 5
# Default-Stop: 0 1 6
# Short-Description: TurboPrint usb port daemon
# Description: monitor usb ports while no print jobs are active
# make printer status information available to
# turboprint-monitor and kde/gnome applets
### END INIT INFO
########
# get Turboprint settings
########
eval $(cat "/etc/turboprint/system.cfg")
# set default user if not set in system.cfg
if [ -z $TPDAEMON_USER ] ; then
TPDAEMON_USER="lp"
fi
# set default start mode if not set in system.cfg
if [ -z $TPDAEMON_START ] ; then
TPDAEMON_START="1"
fi
########
# get pid of tprintdaemon
########
pid=$(pgrep tprintdaemon)
case $1 in
restart)
killall tprintdaemon
sleep 1
su $TPDAEMON_USER -c "/usr/bin/tprintdaemon 0" || /usr/bin/tprintdaemon 0
echo "TurboPrint daemon restarted"
;;
forcestart)
su $TPDAEMON_USER -c "/usr/bin/tprintdaemon 0" || /usr/bin/tprintdaemon 0
echo "TurboPrint daemon started"
;;
start)
if [ $TPDAEMON_START -eq 1 ] ; then
su $TPDAEMON_USER -c "/usr/bin/tprintdaemon 0" || /usr/bin/tprintdaemon 0
echo "TurboPrint daemon started"
else
echo "TPDAEMON_START not set - TurboPrint daemon not started"
echo "use instead: tpdaemon forcestart"
fi
;;
stop)
killall tprintdaemon
echo "TurboPrint daemon stopped"
;;
status)
if [ $pid ] ; then
echo "TurboPrint daemon is running, pid=$pid"
else
echo "TurboPrint daemon is not running"
fi
;;
*)
echo "Usage: tpdaemon {start|stop|status|forcestart}"
esac
# write / delete pid file
pid=$(pgrep tprintdaemon)
if [ $pid ] ; then
echo $pid > /var/spool/turboprint/tpdaemon.pid
else
rm /var/spool/turboprint/tpdaemon.pid
fi
exit 0