summaryrefslogtreecommitdiff
blob: b2ce999eb687ebd17e1fd9275bb9d37dd942a170 (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
#!/sbin/runscript
# Copyright 1999-2010 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
# $Header: /var/cvsroot/gentoo-x86/www-misc/vdradmin-am/files/vdradmin-3.6.7.init,v 1.1 2010/10/26 21:52:31 billie Exp $

depend() {
	use vdr
}

start() {
	ebegin "Starting vdradmin"

	: ${VDRADMIN_USER:=vdradmin}

	local dir vdradmin_opts

	# Prepare directories
	for dir in cache log run; do
		[ ! -d /var/${dir}/vdradmin ] && checkpath -d -m 0755 -o ${VDRADMIN_USER}:vdradmin "/var/${dir}/vdradmin"
	done

	if [ "${SSL}" = "yes" ]; then vdradmin_opts="${vdradmin_opts} --ssl"; fi
	if [ "${IPV6}" = "yes" ]; then vdradmin_opts="${vdradmin_opts} --ipv6"; fi
	vdradmin_opts="${vdradmin_opts} --log ${LOGLEVEL:=4}"

	if [ "${LOGGING}" = "syslog" ]; then
		sed -i -e "/LOGGING/s-LOGGING.*-LOGGING = 1-" /etc/vdradmin/vdradmind.conf
		sed -i -e "/LOGFILE/s-LOGFILE.*-LOGFILE = syslog-" /etc/vdradmin/vdradmind.conf
	elif [ "${LOGGING}" = "file" ]; then
		sed -i -e "/LOGGING/s-LOGGING.*-LOGGING = 1-" /etc/vdradmin/vdradmind.conf
		sed -i -e "/LOGFILE/s-LOGFILE.*-LOGFILE = vdradmind.log-" /etc/vdradmin/vdradmind.conf
	else
		sed -i -e "/LOGGING/s-LOGGING.*-LOGGING = 0-" /etc/vdradmin/vdradmind.conf
	fi

	if [ -n "${RC_UNAME}" ]; then
		# running on baselayout-2/openrc
		start-stop-daemon --start --background --user "${VDRADMIN_USER}" \
		--pidfile /var/run/vdradmin/vdradmind.pid \
		--exec /usr/bin/perl /usr/bin/vdradmind -- ${vdradmin_opts}
	else
		start-stop-daemon --start --background --chuid "${VDRADMIN_USER}" \
		--exec /usr/bin/vdradmind -- ${vdradmin_opts}
	fi
	eend $?
}

stop() {
	ebegin "Stopping vdradmin"
	start-stop-daemon --stop --quiet --pidfile /var/run/vdradmin/vdradmind.pid
	eend $?
}