3
# Provides: fp-facilitator
4
# Required-Start: $remote_fs $syslog
5
# Required-Stop: $remote_fs $syslog
6
# Default-Start: 2 3 4 5
8
# Short-Description: Flash proxy facilitator
9
# Description: Debian init script for the flash proxy facilitator.
12
# Author: David Fifield <david@bamsoftware.com>
15
# Based on /etc/init.d/skeleton from Debian 6.
17
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
18
DESC="Flash proxy facilitator"
23
PIDFILE=/var/run/$NAME.pid
24
LOGFILE=/var/log/$NAME.log
25
CONFDIR=/etc/flashproxy
26
RELAYFILE=$CONFDIR/facilitator-relays
27
PRIVDROP_USER=fp-facilitator
28
DAEMON=${exec_prefix}/bin/$NAME
29
DAEMON_ARGS="--relay-file $RELAYFILE --log $LOGFILE --pidfile $PIDFILE --privdrop-user $PRIVDROP_USER"
30
DEFAULTSFILE=/etc/default/$NAME
32
# Exit if the package is not installed
33
[ -x "$DAEMON" ] || exit 0
35
# Read configuration variable file if it is present
36
[ -r "$DEFAULTSFILE" ] && . "$DEFAULTSFILE"
39
. /lib/lsb/init-functions
41
[ "$UNSAFE_LOGGING" = "yes" ] && DAEMON_ARGS="$DAEMON_ARGS --unsafe-logging"
42
[ -n "$PORT" ] && DAEMON_ARGS="$DAEMON_ARGS --port $PORT"
45
# Function that starts the daemon/service
50
# 0 if daemon has been started
51
# 1 if daemon was already running
52
# 2 if daemon could not be started
53
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
55
start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
61
# Function that stops the daemon/service
66
# 0 if daemon has been stopped
67
# 1 if daemon was already stopped
68
# 2 if daemon could not be stopped
69
# other if a failure occurred
70
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE
72
[ "$RETVAL" = 2 ] && return 2
73
# Wait for children to finish too if this is a daemon that forks
74
# and if the daemon is only ever run from this initscript.
75
# If the above conditions are not satisfied then add some other code
76
# that waits for the process to drop all resources that could be
77
# needed by services started subsequently. A last resort is to
78
# sleep for some time.
79
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
80
[ "$?" = 2 ] && return 2
87
if [ "$RUN_DAEMON" != "yes" ]; then
88
log_action_msg "Not starting $DESC (Disabled in $DEFAULTSFILE)."
91
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
94
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
95
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
99
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
102
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
103
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
107
status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
109
restart|force-reload)
110
log_daemon_msg "Restarting $DESC" "$NAME"
117
1) log_end_msg 1 ;; # Old process is still running
118
*) log_end_msg 1 ;; # Failed to start
128
echo "Usage: $0 {start|stop|status|restart|force-reload}" >&2