blob: aaa2ce8cdd8f842b99dee9bd827924c057983f65 (
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/bin/sh
# PROVIDE: asterisk
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable asterisk:
#
# asterisk_enable (bool): Set it to "YES" to enable asterisk
# Default is "NO"
# asterisk_user (string): User asterisk runs as
# Default is %%ASTERISK_USER%%
# asterisk_group (string): Group asterisk runs as
# Default is %%ASTERISK_GROUP%%
# asterisk_args (string): Extra argumeents to pass to asterisk at startup
# Default is "-n"
# asterisk_pidfile (string): Location of the asterisk pid file
# Default is /var/run/asterisk/asterisk.pid
# asterisk_stopsleep (int): Number of seconds to sleep before sending stop command
# Default is 0, which disables it
# asterisk_umask (string): File creation mode mask to run asterisk with
#
. /etc/rc.subr
name=asterisk
rcvar=asterisk_enable
desc="Asterisk PBX server"
load_rc_config $name
: ${asterisk_enable:=NO}
: ${asterisk_user:=%%ASTERISK_USER%%}
: ${asterisk_group:=%%ASTERISK_GROUP%%}
: ${asterisk_args=-n}
: ${asterisk_pidfile:=/var/run/asterisk/asterisk.pid}
: ${asterisk_stopsleep:=0}
extra_commands=reload
start_precmd=asterisk_precmd
stop_cmd=asterisk_stop
reload_cmd=asterisk_reload
pidfile="${asterisk_pidfile}"
command="%%PREFIX%%/sbin/asterisk"
command_args="${asterisk_args} -F -U ${asterisk_user}"
asterisk_precmd()
{
local rundir=${asterisk_pidfile%/*}
if [ ! -d $rundir ] ; then
install -d -m 0750 -o "${asterisk_user}" -g "${asterisk_group}" "$rundir"
fi
if [ -n "${asterisk_umask}" ]; then
umask ${asterisk_umask}
fi
}
asterisk_stop()
{
if [ -z "$rc_pid" ]; then
[ -n "$rc_fast" ] && return 0
_run_rc_notrunning
return 1
fi
echo 'Stopping asterisk.'
if [ ${asterisk_stopsleep} -gt 0 ]; then
sleep ${asterisk_stopsleep}
fi
$command -nqrx 'core stop now'
wait_for_pids $rc_pid
}
asterisk_reload()
{
if [ -z "$rc_pid" ]; then
_run_rc_notrunning
return 1
fi
echo 'Reloading asterisk.'
$command -nqrx 'reload'
}
run_rc_command "$1"
|