| macVoIP.com the web home of Ted Wallingford |
|
|
|
Build a Mac PBX
Excerpted from my book VoIP Hacks (O'Reilly Media) 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 muscle-enough to handle a few dozen VoIP phone calls at the same-even if though most observer's didn't have VoIP in mind for it. At under five hundred bucks, the Mini is cost-conscious, and for those who don't trust the likes of Windows in a realtime application like IP telephony, a Macintosh provides a secure, friendly alternative. Of course, there are comparably-equipped small PCs, but none with the tiny (2 inches tall and 6 x 6 square) form factor of the Mac Mini. So, if you need a space-conscious, cheap VoIP server, you need look no further that 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 there are no multi-channel PCI telephony drivers 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 FXO/FXS cards can be snapped into place for connecting phone lines. This is where VoIP comes in handy. Just because the Mac Min can't connect directly to analog lines and phones, that doesn't mean they can't be used. If you need to connect analog lines and phones to a Mac Mini, you can do so by way of an ATA (analog telephone adapter) or FXO (Foreign Exchange Office) gateway device. An ATA will connect an analog phone to an Ethernet network, while 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 [of VoIP Hacks] is just one such device-an 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-comptaible distribution of Asterisk. The one I like was built by Benjamin Kowarsch, a Mac telephony hacker. It can be downloaded from http://www.astmasters.net. 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. 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 non-default settings that require the constant attention of a Unix snob, the boot volume should be adequate. $ sudo /usr/sbin/asterisk -vvvc The more v's you tack on, the more verbose Asterisk's debugging output will be-very useful when troubleshooting things. If you've issued this command in the OS X terminal and received the following message, or something similar, then you weren't using the root account when you launched Asterisk: Logger Warning: Unable to open log file '/var/log/asterisk/messages': Permission denied You'll need to be root, the all-powerful Unix administrator account, in order 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 manually turn it on. This practice is generally frowned upon, as using the root account gives you enormous capacity to harm your Mac's file system 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 in order to launch Asterisk, and then we'll return to the safe-zone of non-root 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 Asterisk command above. If you get a few screenfulls 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 pretty easy. In /System/Library/StartupItems, create a folder called Asterisk. In that folder, create a text file called Asteriskand 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 MacPBX will also automatically shutdown and restart Asterisk. Before you reboot, though, you'll also need to create a file called StartupParameters.plist in the same folder-a 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. |
|
|
|
(C) 2003 - 2006 Ted Wallingford
|