summaryrefslogtreecommitdiff
blob: b0515eab3bea0bc2db5ce48bb611b7ccbf72921a (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
#!/sbin/runscript

# Copyright 2013-2014 Jonathan Vasquez <jvasquez1011@gmail.com>
# Distributed under the terms of the GNU General Public License v2

NAME="BitTorrent Sync"
SYNC_NAME="btsync"
SYNC_PATH="/opt/${SYNC_NAME}/"
SYNC_BINARY="${SYNC_PATH}/${SYNC_NAME}"
SYNC_OPTS="--nodaemon --config /etc/${SYNC_NAME}/config"
SYNC_PIDFILE="/var/run/${SYNC_NAME}.pid"

start() {
	ebegin "Starting ${NAME}"

	# Sets the umask for the process so that btsync creates files
	# with group write permissions
	start-stop-daemon --start --exec "${SYNC_BINARY}" \
	   --pidfile "${SYNC_PIDFILE}" --background \
	   -- ${SYNC_OPTS}

	eend $?
}

stop() {
	ebegin "Stopping ${NAME}"

	start-stop-daemon --stop --exec "${SYNC_BINARY}" \
	    --pidfile "${SYNC_PIDFILE}"

	eend $?
}

reload() {
	ebegin "Reloading ${NAME}"

	start-stop-daemon --signal HUP --exec "${SYNC_BINARY}" \
	    --pidfile "${SYNC_PIDFILE}"

	eend $?
}