ports/net/asterisk13/files/asterisk.in
Guido Falsi 5778ec1feb - Enable SPANDSP option by default
- Make startup script create pidfile directory if it does not exist

While here, reflow OPTIONS_DEFAULT lists.

Subitted/Requested by:	lidl@
2016-01-31 17:11:47 +00:00

65 lines
1.3 KiB
Bash

#!/bin/sh
#
# $FreeBSD$
#
# 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_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
#
. /etc/rc.subr
name=asterisk
rcvar=asterisk_enable
desc="Asterisk PBX server"
load_rc_config $name
: ${asterisk_enable:=NO}
: ${asterisk_user:=%%ASTERISK_USER%%}
: ${asterisk_args=-n}
: ${asterisk_pidfile:=/var/run/asterisk/asterisk.pid}
extra_commands=reload
start_precmd=asterisk_precmd
stop_cmd=asterisk_stop
reload_cmd=asterisk_reload
command="%%PREFIX%%/sbin/asterisk"
command_args="${asterisk_args} -F -U ${asterisk_user}"
pidfile=${asterisk_pidfile}
asterisk_precmd()
{
local rundir=${asterisk_pidfile%/*}
if [ ! -d $rundir ] ; then
install -d -m 0755 -o asterisk -g asterisk $rundir
fi
}
asterisk_stop()
{
echo 'Stopping asterisk'
$command -nqrx 'core stop now'
}
asterisk_reload()
{
echo 'Reloading asterisk'
$command -nqrx 'reload'
}
run_rc_command "$1"