Hack93.Build a Mac PBX


Hack 93. Build a Mac PBX

The Mac mini is a very tiny and rugged PC, making it a great small-office PBX.

When Apple introduced the Mac mini, most onlookers were pleased to see a smaller machine with plenty of muscleenough to handle a few dozen VoIP phone calls at a timeeven though most observers didn't have VoIP in mind for it. At less than $500, the mini is great for the cost-conscious, and for those who don't trust the likes of Windows in a real-time application like IP telephony, a Mac provides a secure, friendly alternative. Of course, there are comparably equipped "small" PCs, but none with the tiny (two inches tall, and six by six inches square) form factor of the Mac mini. So, if you need a space-conscious, cheap VoIP server, you need look no further than the mini.

Would you rather use an Xserve with this hack? Great idea! The Xserve has faster processors and a RAID hard-drive array. This means high-performance PBX action. It also has an extra Ethernet interface and a swappable power supply, making it better in mission-critical situations than the mini.


But, since the Mac mini has no card slots (and since multichannel PCI telephony drivers are not available for OS X), attaching analog phones and phone lines to a Mac mini isn't the same as in a traditional, PCI-equipped server chassis, where you can snap foreign exchange office/foreign exchange station (FXO/FXS) cards into place to connect phone lines. This is where VoIP comes in handy. Just because the Mac mini can't connect directly to analog lines and phones doesn't mean you can't use them with it.

You can connect analog lines and phones to a Mac mini by way of an analog telephone adapter (ATA) or an FXO gateway device. An ATA will connect an analog phone to an Ethernet network, and an FXO gateway will attach a phone line to the Ethernet network. These devices provide a signaling proxy that allows analog phones and lines to be used with VoIP servers like that Mac mini PBX we're about to set up. The Clipcomm CG-410 referenced elsewhere in this chapter is one such devicean FXO gateway device.

This hack works on any Mac with OS X 10.2 or higher. To get started, let's download an installation package for a Mac-compatible distribution of Asterisk. The one I like was built by Benjamin Kowarsch, a Mac telephony hacker. You can download it from http://www.astmasters.net/ or http://www.macvoip.com/. You'll probably want to grab the latest version available from one of those sites. Unpack it (StuffIt should prompt you to unpack it as soon as you download it) and launch the Asterisk.pkg file. This package looks like most Mac installer packages. Step through the Introduction, Read Me, and License screens; agree to the license; and select the volume where you want to install Asterisk (Figure 7-6). Your boot volume is the only place you can install Asterisk, so don't bother yourself with trying to figure out how to install it elsewhere. Besides, unless you like time-consuming nondefault settings that require the constant attention of a Unix snob, the boot volume should be adequate.

The quickest way to launch Asterisk (on any system), once it's installed, is to issue this command:

 $ sudo /usr/sbin/asterisk -vvvc 

The more v's you tack on, the more verbose Asterisk's debugging output will bevery useful when troubleshooting things.

If you've issued this command in the OS X terminal and received the following message, or something similar, you weren't using the root account when you launched Asterisk:

Logger Warning: Unable to open log file '/var/log/asterisk/messages': Permission denied

Figure 7-6. The Asterisk installer package


You'll need to be root, the all-powerful Unix administrator account, to launch Asterisk as installed by the installer package. Becoming root on OS X isn't as simple as it is on Linux, however. The root account itself is actually hidden away and disabled until you go in and "turn it on" manually. This practice is generally frowned upon, as using the root account gives you enormous capacity to harm your Mac's filesystem and settings, so don't say I didn't warn you. We're just going to do this once, so you can see how it's done to launch Asterisk, and then we'll return to the safe zone of nonroot access. As the default user (the first user created when you first installed OS X on your Mac), open a terminal and issue this command:

 $ sudo passwd root 

You'll be prompted for a password. This password will establish the root user's password so that you can use the root account from now on. Yes, that simple command "turns on" the root account. Now, you should be able to launch Asterisk on the Mac using the preceding Asterisk command. If you get a few screens full of log output that eventually ends up at a PBX prompt, you've launched Asterisk successfully.

Yet even after all that, Asterisk won't be set to start automatically every time you boot your Mac, so you'll need to make sure it's launching every time. This is easy. In /System/Library/StartupItems, create a folder called Asterisk.

In that folder, create a text file called Asterisk and place the following code inside:

 #!/bin/sh ## # Ted's Asterisk Telephony Server Startupitem ## . /etc/rc.common StartService ( ) { echo "Starting Asterisk telephony" /usr/sbin/asterisk -vvvg & } StopService ( ) { echo "Stopping Asterisk telephony" /usr/sbin/asterisk -rx "stop when convenient" } RestartService ( ) { echo "Restarting Asterisk" StopService StartService } RunService "$1" 

This script handles the proper startup (and shutdown) of Asterisk when the system boots (and shuts down). Likewise, rebooting your Mac PBX will also automatically shut down and restart Asterisk. Before you reboot, though, you'll also need to create a file called StartupParameters.plist in the same foldera text file with the following contents:

 { Description = "Asterisk"; Provides = ("Asterisk"); Uses = ("Disks", "NFS"); } 

Once those two files are in place, give your OS X machine a reboot, and your Mac PBX is built. Now all you need is somebody to call.




VoIP Hacks
VoIP Hacks: Tips & Tools for Internet Telephony
ISBN: 0596101333
EAN: 2147483647
Year: 2005
Pages: 156

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net