aboutsummaryrefslogtreecommitdiff
path: root/audio/squeezeboxserver/files/slimserver.sh.in
blob: bea293be52f4d4395ddcab470757aab6e3ecd822 (plain) (blame)
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
#!/bin/sh
#
# $FreeBSD$
#

# PROVIDE: slimserver
# REQUIRE: LOGIN
# KEYWORD: FreeBSD shutdown

#
# Add the following lines to /etc/rc.conf to enable slimserver:
#
#slimserver_enable="YES"
#

. %%RC_SUBR%%

name=slimserver
stop_cmd="slimserver_stop"
rcvar=`set_rcvar`

command=%%PREFIX%%/%%SLIMDIR%%/slimserver.pl
pidfile=/var/run/${name}.pid
conffile=/var/db/slimserver/slimserver.conf
logfile=/var/log/slimserver.log
u=slimserv
g=slimserv
command_args="--daemon --prefsfile=${conffile} --logfile=${logfile} --user=${u} --group=${g} --pidfile=${pidfile}"

slimserver_stop()
{
	if [ ! -f ${pidfile} ]; then
		exit
	fi
	echo 'Stopping SlimServer.'
	rc_pid=`cat ${pidfile}`
	rc_pid=`pgrep -u ${u} | grep ${rc_pid}`
	if [ -n "${rc_pid}" ]; then
		rc_pids="${rc_pid} `pgrep -u ${u} mDNSResponderPosix`"

		kill $sig_stop $rc_pids
		wait_for_pids $rc_pids
	else
		echo "${name} not running? (check ${pidfile})"
	fi

	rm -f ${pidfile}
}

# set defaults

slimserver_enable=${slimserver_enable:-"NO"}
slimserver_flags=${slimserver_flags:-""}

load_rc_config ${name}
run_rc_command "$1"