summaryrefslogtreecommitdiff
path: root/support/dktools/initd-printqd.in
blob: 6482a415f3f90eb3b1afa718b07085cd78ca9b54 (plain)
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
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh

### BEGIN INIT INFO
# Provides:          printqd
# Required-Start:    $local_fs $network
# Required-Stop:     $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the printqd daemon
# Description:       Start the printqd daemon.
### END INIT INFO
#
# Author:       Dirk Krause <krause.dirk@web.de>
#

. /lib/init/vars.sh
. /lib/lsb/init-functions

prefix="@prefix@"
datarootdir="@datarootdir@"
exec_prefix="@exec_prefix@"
sysconfdir="@sysconfdir@"
bindir="@bindir@"
sbindir="@sbindir@"
libdir="@libdir@"
localstatedir="@localstatedir@"
RDIR="${localstatedir}/run"
PDIR="${localstatedir}/lib"
LDIR="${localstatedir}/log"

DAEMON="${sbindir}/printqd"
PIDFILE="${RDIR}/printqd/printqd.pid"
SOCKFILE="${RDIR}/printqd/printqd.sock"

set -e

case $1 in
	start)
		if [ ! -d "${RDIR}/printqd" ]
		then
			mkdir -p "${RDIR}/printqd"
			chown -R daemon:lp "${RDIR}/printqd"
			chmod 770 "${RDIR}/printqd"
		fi
		if [ ! -d "${PDIR}/printqd" ]
		then
			mkdir -p "${PDIR}/printqd"
			chown -R daemon:lp "${PDIR}/printqd"
			chmod 770 "${PDIR}/printqd"
		fi
		if [ ! -d "${LDIR}/printqd" ]
		then
			mkdir -p "${LDIR}/printqd"
			chown -R daemon:lp "${LDIR}/printqd"
			chmod 770 "${LDIR}/printqd"
		fi
		if [ ! -d "${PDIR}/printqd/db" ]
		then
			mkdir -p "${PDIR}/printqd/db"
			chown -R daemon:lp "${PDIR}/printqd/db"
			chmod 770 "${PDIR}/printqd/db"
		fi
		if [ -e "${SOCKFILE}" ]
		then
			rm -f "${SOCKFILE}"
		fi
		if [ -e "${PIDFILE}" ]
		then
			rm -f "${PIDFILE}"
		fi
		log_daemon_msg "Starting print quota daemon" "printqd"
		start_daemon -p $PIDFILE $DAEMON
		log_end_msg $?
		;;
	stop)
		log_daemon_msg "Stopping print quota daemon" "printqd"
		killproc -p $PIDFILE $DAEMON
		log_end_msg $?
		;;
	reload)
		$0 stop
		sleep 1
		$0 start
		;;
	restart|force-reload)
		$0 stop
		sleep 1
		$0 start
		;;
	status)
		status_of_proc -p $PIDFILE $DAEMON printqd && exit 0 || exit $?
		;;
	*)
		echo "Usage: /etc/init.d/printqd {start|stop|reload|restart|force-reload|status}"
		exit 1
		;;
esac