Installing VoiceOne / Asterisk on an OS X Server

This is how to get Asterisk and VoiceOne working on an OS X server box. This is not an idiots guide by any measure… and a lot of assumptions about your technical skills are made.

First of all – you will need to enable MySQL (see link)

Do you have XCode installed? You need that to compile anything… It is here.

If you don’t already have a /usr/src to hold everything in… make one
sudo mkdir /usr/src
sudo chown -R root:admin /usr/src/
sudo chmod 775 /usr/src/

Get Asterisk… and install it
cd /usr/src
 
curl -O http://ftp.digium.com/pub/asterisk/releases/asterisk-1.2.14.tar.gz
 
curl -O http://ftp.digium.com/pub/asterisk/releases/asterisk-addons-1.2.5.tar.gz
 
curl -O http://ftp.digium.com/pub/asterisk/releases/asterisk-sounds-1.2.1.tar.gz
 
find . -name asterisk-*.tar.gz -exec tar zxvf {} ;
 
cd asterisk-1.2.14
 
#(to isolate the asterisk install - NOT REQUIRED) cat Makefile | sed "s:?=:?=/usr/local/asterisk:" > Makefile.new
 
#(if you do the above) mv Makefile.new Makefile
 
make
 
sudo make install
 
cd ../asterisk-addons-1.2.5 && make && sudo make install && cd ..
 
cd asterisk-sounds-1.2.1 && sudo make install && cd ..
 
echo 'asterisk::1026:1026::0:0:Asterisk Server:/dev/null:/bin/bash' | sudo niload -v passwd /
 
echo 'asterisk:*:1026:asterisk' | sudo niload -v group /
 
sudo mkdir /var/run/asterisk
 
curl -O http://superb-west.dl.sourceforge.net/sourceforge/voiceone/voiceone-0.4.2.tar.gz
 
cd /Library/WebServer/Documents/ && tar zxvf /usr/src/voiceone-0.4.2.tar.gz
 
cat voiceone/admin/config/config.inc.php | sed "s:$soapPassword = "voiceone";:$soapPassword = "NEW-PASSWORD";:" > voiceone/admin/config/config.inc.php.new && mv voiceone/admin/config/config.inc.php.new voiceone/admin/config/config.inc.php
 
cat voiceone_webservices/config/config.inc.php | sed "s:$htaccessPassword="voiceone";:$htaccessPassword="NEW-PASSWORD";:" > voiceone_webservices/config/config.inc.php.new && mv voiceone_webservices/config/config.inc.php.new voiceone_webservices/config/config.inc.php
 
cat voiceone_webservices/config/config.inc.php | sed "s:$synDbUser="root";:$synDbUser="voiceone";:" > voiceone_webservices/config/config.inc.php.new && mv voiceone_webservices/config/config.inc.php.new voiceone_webservices/config/config.inc.php
 
cat voiceone_webservices/config/config.inc.php | sed "s:$synDbPassword="voiceone";:$synDbPassword="NEW-PASSWORD";:" > voiceone_webservices/config/config.inc.php.new && mv voiceone_webservices/config/config.inc.php.new voiceone_webservices/config/config.inc.php
 
cat voiceone_webservices/config/script/vo-tools.sh | sed "s:/var/www/html:`pwd`:" > voiceone_webservices/config/script/vo-tools.sh.new && mv voiceone_webservices/config/script/vo-tools.sh.new voiceone_webservices/config/script/vo-tools.sh
 
cat voiceone_webservices/config/script/vo-tools.sh | sed "s:-d "/proc/`cat $AST_RUN_DIR/asterisk.pid`":"$(ps ax | grep `cat $AST_RUN_DIR/asterisk.pid` | grep -v grep)":" > voiceone_webservices/config/script/vo-tools.sh.new && mv voiceone_webservices/config/script/vo-tools.sh.new voiceone_webservices/config/script/vo-tools.sh
 
cat voiceone_webservices/config/script/vo.cfg | sed "s:/usr/sbin/safe_asterisk:"/System/Library/StartupItems/Asterisk/Asterisk start":" > voiceone_webservices/config/script/vo.cfg.new && mv voiceone_webservices/config/script/vo.cfg.new voiceone_webservices/config/script/vo.cfg
 
cat voiceone_webservices/config/script/vo.cfg | sed "s:/etc/init.d/asterisk:"/System/Library/StartupItems/Asterisk/Asterisk":" > voiceone_webservices/config/script/vo.cfg.new && mv voiceone_webservices/config/script/vo.cfg.new voiceone_webservices/config/script/vo.cfg
 
cat voiceone_webservices/config/script/vo.cfg | sed "s:"astgenkey:"`which astgenkey`:" > voiceone_webservices/config/script/vo.cfg.new && mv voiceone_webservices/config/script/vo.cfg.new voiceone_webservices/config/script/vo.cfg

Now you have some file maintaining to do…

In /etc/asterisk create the following files

asterisk.conf

[directories]
astetcdir => /etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astagidir => /var/lib/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run/asterisk
astlogdir => /var/log/asterisk
[files]
astctlpermissions = 0660
astctlowner = asterisk
astctlgroup = asterisk
astctl = asterisk.ctl

logger.conf
[general]
[logfiles]
console => notice,warning,error
messages => notice,warning,error
full => notice,warning,error,debug,verbose

modules.conf
[modules]
autoload=yes
noload => pbx_gtkconsole.so
noload => pbx_kdeconsole.so
noload => chan_modem.so
noload => chan_modem_aopen.so
noload => chan_modem_bestdata.so
noload => chan_modem_i4l.so
load => res_musiconhold.so
noload => chan_alsa.so
preload => res_config_mysql.so
[global]

extconfig.conf
[settings]
extensions.conf => mysql,voiceone,ast_config
iax.conf => mysql,voiceone,ast_config
meetme.conf => mysql,voiceone,ast_config
misdn.conf => mysql,voiceone,ast_config
musiconhold.conf => mysql,voiceone,ast_config
queues.conf => mysql,voiceone,ast_config
sip.conf => mysql,voiceone,ast_config
zapata.conf => mysql,voiceone,ast_config
iaxusers => mysql,voiceone,iax_buddies
iaxpeers => mysql,voiceone,iax_buddies
sipusers => mysql,voiceone,sip_buddies
sippeers => mysql,voiceone,sip_buddies
voicemail => mysql,voiceone,voicemail_users
extensions => mysql,voiceone,extensions_table

res_mysql.conf
NOTE The password in here should match what you used in the section above
[general]
dbhost = localhost
dbname = voiceone
dbuser = voiceone
dbpass = NEW-PASSWORD-FROM-ABOVE
dbport = 3306
dbsock = /private/var/mysql/mysql.sock

cdr_mysql.conf
NOTE The password in here should match what you used in the section above
[global]
hostname=localhost
dbname=voiceone
table=cdr
user=voiceone
password=NEW-PASSWORD-FROM-ABOVE
port=3306
sock=/private/var/mysql/mysql.sock
userfield=1

manager.conf
[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
;displayconnects = yes
[admin]
secret=qwerty_123_mnbvc
deny=0.0.0.0/0.0.0.0
permit=127.0.0.1/255.255.255.0
read=system,call,log,verbose,command,agent,user
write=system,call,log,verbose,command,agent,user

Now you need to give VoiceOne (the websever) permission to run a control script as root. This is done with the command “visudo”. Call it as below
sudo visudo
And add the line below to the end of the file
www ALL=NOPASSWD: /Library/WebServer/Documents/voiceone_webservices/config/script/vo-tools.sh

Now we shall create the MySQL database. (This will require your root DB password)
mysqladmin --user=root -p create voiceone

Create the voiceone MySQL user and grant it permissions. Replace the password below with the one you have been using throughout this ordeal
echo "GRANT ALL PRIVILEGES ON voiceone.* TO 'voiceone'@'localhost' IDENTIFIED BY 'NEW-PASSWORD' WITH GRANT OPTION;" | mysql --user=root -p mysql

Some permissions and ownership cleaning
sudo find / -name asterisk -type d -exec chown -R asterisk:asterisk {} ;
sudo find /Library/WebServer/TokyoPV.com/ -name *.sh -exec chmod 755 {} ;
sudo chmod -R 777 /Library/WebServer/TokyoPV.com/voiceone/sandbox
sudo chmod -R 777 /Library/WebServer/TokyoPV.com/voiceone/admin/public/template/cache

Create a startup item for Asterisk…
cd ~
Create the file below – call it mkastgo.sh
#!/bin/bash
mkdir -p /System/Library/StartupItems/Asterisk
cd /System/Library/StartupItems/Asterisk
curl -O http://purpleoranges.com/asterisk/osx/asterisk_startup.txt
curl -O http://purpleoranges.com/asterisk/osx/startupparameters_plist.txt
mv /System/Library/StartupItems/Asterisk/asterisk_startup.txt /System/Library/StartupItems/Asterisk/Asterisk
mv /System/Library/StartupItems/Asterisk/startupparameters_plist.txt /System/Library/StartupItems/Asterisk/StartupParameters.plist
chmod 755 /System/Library/StartupItems/Asterisk/Asterisk
chmod 644 /System/Library/StartupItems/Asterisk/StartupParameters.plist

Now give that file permission to execute and run it as root
chmod 750 mkastgo.sh
sudo ./mkastgo.sh

Now – add Asterisk to the hostconfig file
sudo sh -c 'echo "ASTERISK=-YES-" >> /etc/hostconfig'
And get rid of our shell script
rm -f ./mkastgo.sh

Agree, disagree? Tell somebody!

Leave a Reply

Switch to our mobile site