4
# Required-Start: $local_fs $remote_fs
5
# Required-Stop: $local_fs $remote_fs
6
# Default-Start: 2 3 4 5
7
# Default-Stop: S 0 1 6
8
# Short-Description: bazaar Smart Server
9
# Description: bazaar Smart Server
12
# Author: John Ferlito <johnf@inodes.org>
14
# PATH should only include /usr/* if it runs after the mountnfs.sh script
15
PATH=/usr/sbin:/usr/bin:/sbin:/bin
16
DESC="Bazaar Smart Server"
20
PIDFILE=/var/run/$NAME.pid
21
SCRIPTNAME=/etc/init.d/$NAME
28
# Exit if the package is not installed
29
[ -x "$DAEMON" ] || exit 0
31
# Read configuration variable file if it is present
32
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
34
# Load the VERBOSE setting and other rcS variables
35
[ -f /etc/default/rcS ] && . /etc/default/rcS
37
test "$ENABLED" != "0" || exit 0
39
# Define LSB log_* functions.
40
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
41
. /lib/lsb/init-functions
44
# Function that starts the daemon/service
49
# 0 if daemon has been started
50
# 1 if daemon was already running
51
# 2 if daemon could not be started
52
start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE \
53
--chuid $USER:$GROUP --background --exec $DAEMON --test > /dev/null \
55
start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE \
56
--chuid $USER:$GROUP --background --exec $DAEMON -- \
57
serve $DAEMON_ARGS --directory $REPO \
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 ;;
107
restart|force-reload)
109
# If the "reload" option is implemented then remove the
110
# 'force-reload' alias
112
log_daemon_msg "Restarting $DESC" "$NAME"
119
1) log_end_msg 1 ;; # Old process is still running
120
*) log_end_msg 1 ;; # Failed to start
130
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2