4
# Required-Start: $remote_fs $syslog $network
5
# Required-Stop: $remote_fs $syslog
6
# Default-Start: 2 3 4 5
8
# Short-Description: p910nd daemon providing network printer access
9
# Description: Start p910nd to provide port 9100+n printer service
12
# Author: Mario Izquierdo (mariodebian) <mariodebian@gmail.com>
17
# PATH should only include /usr/* if it runs after the mountnfs.sh script
18
PATH=/sbin:/usr/sbin:/bin:/usr/bin
19
DESC="network print daemon"
21
DAEMON=/usr/sbin/$NAME
22
PIDFILE=/var/run/p9100d.pid
23
SCRIPTNAME=/etc/init.d/$NAME
25
# Exit if the package is not installed
26
[ -x "$DAEMON" ] || exit 0
28
# create /var/run and /var/lock/p910nd (Debian policy 3.8.1)
29
[ ! -d /var/run ] && mkdir -p /var/run
30
[ ! -d /var/lock/p910nd ] && mkdir -p /var/lock/p910nd
35
# Read configuration variable file if it is present
36
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
39
DAEMON_ARGS=" $P910ND_OPTS $P910ND_NUM"
41
# Load the VERBOSE setting and other rcS variables
44
# Define LSB log_* functions.
45
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
46
. /lib/lsb/init-functions
49
# Function that starts the daemon/service
54
# 0 if daemon has been started
55
# 1 if daemon was already running
56
# 2 if daemon could not be started
57
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
59
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
65
# Function that stops the daemon/service
70
# 0 if daemon has been stopped
71
# 1 if daemon was already stopped
72
# 2 if daemon could not be stopped
73
# other if a failure occurred
74
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
76
[ "$RETVAL" = 2 ] && return 2
77
# Wait for children to finish too if this is a daemon that forks
78
# and if the daemon is only ever run from this initscript.
79
# If the above conditions are not satisfied then add some other code
80
# that waits for the process to drop all resources that could be
81
# needed by services started subsequently. A last resort is to
82
# sleep for some time.
83
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
84
[ "$?" = 2 ] && return 2
85
# Many daemons don't delete their pidfiles when they exit.
93
if [ "$P910ND_START" != "1" ]; then
94
log_warning_msg "Not starting p910nd daemon. Please edit /etc/default/p910nd first."
98
log_daemon_msg "Starting $DESC" "$NAME"
101
0|1) log_end_msg 0 ;;
106
log_daemon_msg "Stopping $DESC" "$NAME"
109
0|1) log_end_msg 0 ;;
113
restart|force-reload)
115
# If the "reload" option is implemented then remove the
116
# 'force-reload' alias
118
log_daemon_msg "Restarting $DESC" "$NAME"
125
1) log_end_msg 1 ;; # Old process is still running
126
*) log_end_msg 1 ;; # Failed to start
136
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2