blob: 8f8d617fe377f8de159a6411b0137fc2dea3820a (
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
57
58
59
60
61
62
|
#!/bin/sh
# PROVIDE: jackd
# REQUIRE: LOGIN
#
# Add the following line to /etc/rc.conf to enable jackd:
#
# jackd_enable="YES"
#
: ${jackd_enable="NO"}
: ${jackd_user=""}
: ${jackd_args="--no-realtime -doss -r48000 -p1024 -w32"}
. /etc/rc.subr
name=jackd
rcvar=jackd_enable
procname=%%PREFIX%%/bin/jackd
start_cmd="start_jackd"
fail() {
echo "JACK failed to start: $1" >&2
exit 1
}
check_config() {
# check that jackd_user is set
if [ -z "$jackd_user" ]; then
fail "jackd_user has to be defined"
fi
# detect intent to use realtime priority
if { echo "$jackd_args" | grep -q -- "oss" && \
{ echo "$jackd_args" | grep -qw -- "--realtime" || \
echo "$jackd_args" | grep -qw -- "-[A-Za-mo-z]*R[A-Za-z]*"; }; }; then
# check that mac_priority(4) is enabled
if [ "$(sysctl -qn security.mac.priority.realtime)" != "1" ]; then
fail "Realtime priority requires mac_priority(4) to be loaded"
fi
# check that the user has realtime privileges
if ! (su -m "$jackd_user" -c "rtprio 10 test -z"); then
fail "User jackd_user=$jackd_user is not a member of the realtime group"
fi
fi
}
start_jackd() {
echo "Starting ${name}."
# check that setup is valid
check_config
# log the date and parameters
echo -e "\n[`date`] Starting the daemon, user=$jackd_user args=\"$jackd_args\"" >> /var/log/${name}.log
# start the daemon
daemon -p /var/run/${name}.pid -u "$jackd_user" %%PREFIX%%/bin/jackd $jackd_args
}
load_rc_config ${name}
run_rc_command "$1"
|