File: init.debian

package info (click to toggle)
lprng 3.8.B-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,344 kB
  • sloc: ansic: 35,071; sh: 3,040; perl: 1,896; makefile: 380
file content (86 lines) | stat: -rw-r--r-- 1,894 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#! /bin/sh
# install this files as /etc/init.d/lprng.sh (or some other name)
# and run:
#	update-rc.d lprng.sh defaults
#
# most of this file is stolen from Debian

# replace with the place you configured:
DAEMON=/usr/local/sbin/lpd
CONFIGDIR=/usr/local/etc/lpd
PRINTCAP=/etc/printcap
LPDPRINTCAP=/usr/local/etc/lpd/lpd_printcap

# Check for printcap file, if there isn't one, there is no need to start
test -f $PRINTCAP || test -f $LPDPRINTCAP || exit 0

# Work out what port we are running on
LPD_PORT=$(grep "^[[:space:]]*lpd_port" $CONFIGDIR/lpd.conf | cut -d "=" -f 2)
if [ -z $LPD_PORT ]
then
  LPD_PORT=515
fi

# Check lpd.conf for lockfile
LOCKFILE=$(grep "^[[:space:]]*lockfile" $CONFIGDIR/lpd.conf | cut -d "=" -f 2)
if [ -z $LOCKFILE ]
then
  LOCKFILE=/var/run/lprng/lpd
fi

PIDFILE=$LOCKFILE.$LPD_PORT

cleanup()
# description:
#   Removes all lock and control files on this host.
{
  rm -f "${PIDFILE}"

  for dir in $(find /var/spool/lpd/* -type d -print)
  do
    rm -f ${dir}/lock.pr
    rm -f ${dir}/control.pr
    rm -f ${dir}/unspooler.pr
  done
}

test -f $DAEMON  || exit 0

set -e

case "$1" in
  start)
	echo -n "Starting LPRng: "
	checkpc -f > /dev/null
	start-stop-daemon --start --quiet --oknodo --pidfile "${PIDFILE}" \
		--exec $DAEMON
	echo "done."
	;;
  stop)
	echo -n "Stopping LPRng: "
	start-stop-daemon --stop --quiet --oknodo --pidfile "${PIDFILE}"
	cleanup
	echo "done."
	;;
  reload)
	 echo "Reloading LPRng: "
	 start-stop-daemon --stop --signal 1 --quiet --pidfile \
		"${PIDFILE}" --oknodo
	 echo "done."
  	;;
  restart|force-reload)
	echo -n "Restarting LPRng: "
	start-stop-daemon --stop --quiet --pidfile "${PIDFILE}"
	sleep 1
	checkpc -f > /dev/null
	start-stop-daemon --start --quiet --pidfile "${PIDFILE}" \
	    --exec $DAEMON
	echo "done."
	;;
  *)
	echo "Usage: /etc/init.d/lprng {start|stop|restart|force-reload}" >&2
	exit 1
	;;
esac

exit 0