summaryrefslogtreecommitdiff
path: root/contrib/debian/bbstored.in
blob: 48fc47f1026a4121c6d97dd6bd5255889c468ca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#! /bin/sh

# Start and stop the Box Backup server daemon.
# Originally by James Stark, modified by Chris Wilson and James O'Gorman
# For support, visit http://www.boxbackup.org/trac/wiki/MailingLists

NAME=bbstored
LONGNAME="Box Backup Server daemon"
BINARY=@sbindir_expanded@/$NAME
CONFIG=@sysconfdir_expanded@/box/$NAME.conf
PIDFILE=@localstatedir_expanded@/run/$NAME.pid

test -x $BINARY || exit 0
test -f $CONFIG || exit 0

start_stop() {
	start-stop-daemon --quiet --exec $BINARY --pidfile $PIDFILE "$@"
}

start_stop_verbose() {
	if start_stop "$@"; then
		echo "."
	else
		echo " failed!"
		exit 1
	fi
}

case $1 in
	start)
		echo -n "Starting $LONGNAME: $NAME"
		start_stop_verbose --start
		;;
	
	stop)
		echo -n "Stopping $LONGNAME: $NAME"
		start_stop_verbose --stop
		;;
	
	reload|force-reload)
		echo -n "Reloading $LONGNAME configuration"
		start_stop_verbose --stop --signal 1
		;;
	
	restart)
		echo -n "Restarting $LONGNAME: $NAME"
		if start_stop --stop --retry 5 && start_stop --start; then
			echo "."
		else
			echo " failed!"
			exit 1
		fi
		;;
	
	*)
		echo "Usage: $0 {start|stop|reload|force-reload|restart}"
esac

exit 0