4
# Required-Start: $remote_fs $syslog
5
# Required-Stop: $remote_fs $syslog
6
# Default-Start: 2 3 4 5
8
# Short-Description: initscript to start the camo image proxy service
11
# Author: Luke Faraone <lfaraone@debian.org>
13
# PATH should only include /usr/* if it runs after the mountnfs.sh script
14
PATH=/sbin:/usr/sbin:/bin:/usr/bin
15
DESC="manage the camo image proxy service"
17
SCRIPT_PATH=/usr/share/camo/server.js
18
DAEMON="/usr/bin/nodejs $SCRIPT_PATH"
19
PIDFILE=/var/run/$NAME.pid
20
SCRIPTNAME=/etc/init.d/$NAME
22
# Load the VERBOSE setting and other rcS variables
25
# Define LSB log_* functions.
26
# Depend on lsb-base (>= 3.2-14) to ensure that this file is present
27
# and status_of_proc is working.
28
. /lib/lsb/init-functions
30
# Exit if the package is not installed
31
[ -e "$SCRIPT_PATH" ] || exit 0
35
# Read configuration variable file if it is present
36
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
40
if [ "$ENABLED" != "yes" ]; then
41
log_warning_msg "Service is disabled"
46
# Function that starts the daemon/service
51
# 0 if daemon has been started
52
# 1 if daemon was already running
53
# 2 if daemon could not be started
54
start-stop-daemon --start --quiet --pidfile $PIDFILE -bm --exec $DAEMON --no-close -c nobody --test > /dev/null \
56
start-stop-daemon --start --quiet --pidfile $PIDFILE -bm --no-close -c nobody --exec $DAEMON -- \
57
$DAEMON_ARGS >> /var/log/camo/camo.log \
59
# Add code here, if necessary, that waits for the process to be ready
60
# to handle requests from services started subsequently which depend
61
# on this one. As a last resort, sleep for some time.
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.
92
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
95
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
96
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
100
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
103
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
104
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
108
status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
110
#reload|force-reload)
112
# If do_reload() is not implemented then leave this commented out
113
# and leave 'force-reload' as an alias for 'restart'.
115
#log_daemon_msg "Reloading $DESC" "$NAME"
119
restart|force-reload)
121
# If the "reload" option is implemented then remove the
122
# 'force-reload' alias
124
log_daemon_msg "Restarting $DESC" "$NAME"
131
1) log_end_msg 1 ;; # Old process is still running
132
*) log_end_msg 1 ;; # Failed to start
142
#echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
143
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2