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
27
# Exit if the package is not installed
28
[ -x "$DAEMON" ] || exit 0
30
# Read configuration variable file if it is present
31
[ -r /etc/default/$NAME ] && . /etc/default/$NAME
33
# Load the VERBOSE setting and other rcS variables
34
[ -f /etc/default/rcS ] && . /etc/default/rcS
36
# Define LSB log_* functions.
37
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
38
. /lib/lsb/init-functions
41
# Function that starts the daemon/service
46
# 0 if daemon has been started
47
# 1 if daemon was already running
48
# 2 if daemon could not be started
49
start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE \
50
--chuid $USER:$GROUP --background --exec $DAEMON --test > /dev/null \
52
start-stop-daemon --start --quiet --make-pidfile --pidfile $PIDFILE \
53
--chuid $USER:$GROUP --background --exec $DAEMON -- \
54
serve $DAEMON_ARGS --directory $REPO \
56
# Add code here, if necessary, that waits for the process to be ready
57
# to handle requests from services started subsequently which depend
58
# on this one. As a last resort, sleep for some time.
62
# Function that stops the daemon/service
67
# 0 if daemon has been stopped
68
# 1 if daemon was already stopped
69
# 2 if daemon could not be stopped
70
# other if a failure occurred
71
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
73
[ "$RETVAL" = 2 ] && return 2
74
# Wait for children to finish too if this is a daemon that forks
75
# and if the daemon is only ever run from this initscript.
76
# If the above conditions are not satisfied then add some other code
77
# that waits for the process to drop all resources that could be
78
# needed by services started subsequently. A last resort is to
79
# sleep for some time.
80
start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
81
[ "$?" = 2 ] && return 2
82
# Many daemons don't delete their pidfiles when they exit.
89
[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
92
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
93
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
97
[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
100
0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
101
2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
104
restart|force-reload)
106
# If the "reload" option is implemented then remove the
107
# 'force-reload' alias
109
log_daemon_msg "Restarting $DESC" "$NAME"
116
1) log_end_msg 1 ;; # Old process is still running
117
*) log_end_msg 1 ;; # Failed to start
127
echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2