aboutsummarylogtreecommitdiffstats
path: root/motion.initd
blob: 61653c571fd4e870aabc37016f3f7a24744a76dd (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
#!/usr/bin/openrc-run
# Apache License 2015

user="${user:-root}"
group="${group:-root}"
daemon="${daemon:-/usr/bin/motion}"
conf="${defaultconf:-/etc/motion/motion.conf}"
startwait="${startwait:-500}"

depend() {
	need motion localmount
	use mysql postgresql logger dns
	after bootmisc
}

start_pre() {
	if [ ! -r "${conf}" ] ; then
		einfo "Cannot read configuration file '${conf}' - please create or edit '/etc/conf.d/motion'"
		return 1
	fi
}

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

	sh -c "start-stop-daemon \
		--start \
		--user ${user} \
		--group ${group} \
		--wait=${startwait} \
		--exec ${daemon} \
		-- -c ${conf}"
	eend $?
}

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

	start-stop-daemon \
		${DEBUG:+"--verbose"} \
		--stop \
		--exec "${daemon}"
	eend $?
	return 0;
}