[Asterisk-bsd] setting permissions for asterisk and dahdi

Kurt Lidl lidl at pix.net
Thu Aug 26 09:18:59 CDT 2010


I've got an IP-only Asterisk-1.6 installation running on FreeBSD.

(IP only in that the inbound trunking is coming over IAX,
and then I have several SIP extensions registered to that
installation.)

I need to have dahdi timing for the IAX trunking to work.

This has been working fine, but I had to change the Asterisk
startup script to chmod the devices that dahdi creates.
I'm sure there is some fancy devfs goo that could be done
to make this happen, but I couldn't figure it out in 5 minutes,
so I changed the startup script.  (Included at the end of this
message.)

I wanted to run the entire asterisk configuration as a non-root
user, which is also have I run the apache22 on that machine,
which has "FreePBX" installed on it.  (I submitted a couple of
patches just before FreePBX 2.8 was released.  Some of those made
it into FreePBX tree, and some did not, but you can find them
via their bug tracker interface.)

It would be nice if there was a "reserved" UID:GID combination
for running asterisk on FreeBSD in the /usr/ports framework.
I have added some locally so my script can work, but I'd rather
there was a "well known" default set that the Asterisk port
would install on the system.

-Kurt

---- snip, snip ----
#!/bin/sh

# PROVIDE: asterisk
# REQUIRE: DAEMON dahdi
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf to enable asterisk:
#
# asterisk_enable="YES"
#

. /etc/rc.subr

name="asterisk"
rcvar=`set_rcvar`

sig_stop=KILL

start_cmd="asterisk_start"
#stop_cmd="asterisk_stop"
stop_precmd=asterisk_shutdown

rundir=/var/run/asterisk
command=/usr/local/sbin/asterisk

load_rc_config $name
: ${asterisk_enable="NO"}
: ${asterisk_args=""}

asterisk_user="asterisk"
asterisk_group="asterisk"
pidfile=${asterisk_pidfile:-"$rundir/asterisk.pid"}

asterisk_start () {
	echo -n " ${name}"
	mkdir -p $rundir
	chown ${asterisk_user}:${asterisk_group} $rundir
	find /dev/dahdi /var/db/asterisk -print | \
		xargs chown ${asterisk_user}:${asterisk_group}
	sleep 1
	$command -U ${asterisk_user} -G ${asterisk_group} ${asterisk_args}
}

asterisk_shutdown () {
	$command -qrx 'stop now'
	sleep 1
	return 0
}

run_rc_command "$1"
---- snip, snip ----



More information about the Asterisk-BSD mailing list