Asterisk on Ubuntu Feisty

Geoff Shang Geoff at quitelikely.com
Tue Sep 11 07:27:25 UTC 2007


Christian wrote:

> Yes, I have installed the right packages. Did it from source.

Oh!  So you probably installed Asterisk 1.4.11 then.

Ok.  I've never run Asterisk 1.4.x but I would think you could do something 
like the following:

1.  Create /etc/init.d/asterisk with the following:

#!/bin/sh
# Start Asterisk on boot
echo Starting Asterisk...
/usr/sbin/asterisk

You may wish to pass one or more "-v" options to Asterisk if you wish to be 
able to get vurbose output.

2.  Save the file and make it executable:

chmod a+x /etc/init.d/asterisk

3.  Test your script (not sure what would happen if Asterisk was already 
running):

/etc/init.d/asterisk

4. Make a symlink from /etc/init.d/asterisk to the relevant runlevel 
directory at the point at which you would like it to start.  For example:

ln -s /etc/init.d/asterisk /etc/rc2.d/S30asterisk

(note the capital S in the above).

Note that Ubuntu's Upstart emulates runlevel 2 by default so this is 
probably the directory you should use.  You will need to make sure that 
Asterisk starts after all other services that it might depend on.

You could of course make your script more complicated, accepting the 
usual start/stop/restart/reload arguments typical of Debian startup 
scripts.  I guess you would use the -r and -x arguments to pass commands to 
an already running Asterisk.

If you do this, you might also want to get the system to shut down Asterisk 
gracefully when you shut down/reboot.  You'd want to send "stop now" to a 
running Asterisk.  You would then need to link it to an appropriate place 
in /etc/rc0.d and /etc/rc6.d (0 is shutdown, 6 is reboot).  Shutdown 
symlinks have a K prefix for kill.

Having automatically started your Asterisk, you can then connect to it 
with:

asterisk -r

I know this could be more tidy.  Perhaps someone running asterisk from 
Debian or Ubuntu packages could share the shipped init script.

Hope this is of some help.

Geoff.




More information about the Blinux-list mailing list