Asterisk on Apple TV Tutorial

Tom Keating : VoIP & Gadgets Blog
Randy Savicky
| VoIP & Gadgets blog - Latest news in VoIP & gadgets, wireless, mobile phones, reviews, & opinions

Asterisk on Apple TV Tutorial

My Apple on Asterisk blog post immediately drew a response from several Asterisk fans, including the person that "hacked" Apple TV to run Asterisk (l0rdrock). I emailed l0rdr0ck and Steven Sokol about how to get Asterisk running on Apple TV and they provided me with the information on how to do this. The Asterisk 1.4.2 on AppleTV "soup to nuts" tutorial is courtesy of Steven Sokol from Sokol & Associates, Inc., who was the initiator behind this project when he proposed a "bounty" on loading Asterisk on Apple TV and which successfully won by Jeff Gambera (aka l0rdr0ck). The information below is a combination of material from www.appletvhacks.net (for the SSH stuff) and emailed information from l0rdr0ck and Steven Sokol for the main tutorial on loading Asterisk on Apple TV.

Ok, let the fun commence.

Installing Asterisk on Apple TV Steps:


First, get Apple TV. (obviously)

Enable ssh by using this tutorial:

http://www.appletvhacks.net/2007/03/24/enable-ssh-and-afp-on-your-apple-tv/
Since AppleTVHacks has been "dugg" to death, I am including the SSH instructions below taken from the Google Cache. The images weren't cached, so they may not appear below until AppleTVHacks go back online. Credit for the original information used in making this how-to goes to TylerL82 over at the SomethingAwful.com forums. Written up here by Jonathan Bare.

So while you have your Apple TV open and you’re installing a new hard drive or just following along with the people over at SomethingAwful.com forums to get Xvid working, you might as well un-break SSH so you can access the Apple TV remotely.

Opening the Apple TV and connecting the hard drive to your Intel Mac are covered in the hard drive upgrade and elsewhere, so we’ll skip those steps and jump right to the point where you have the OSBoot and Media volumes mounted on your Mac.

This process assumes using an Intel Mac because the sshd binary may or may not be the same in the PowerPC version of Mac OS X; we haven’t checked. If someone would like to try using the PowerPC binary and let us know if it works, that would be great!

There are 2 ways to go about this; using the finder, or via the terminal. The finder method is probably best if you aren’t sure what is going on, whereas the Terminal method is quicker if you are confident.

Step 1 - Using the Finder
Note: ignore any missing images since the Google Cache didn't have them

Once you have OSBoot mounted in the Finder, double click on its icon. You’ll see something like this:



From the Finder’s Go menu, select Go To Folder, or press Command-Shift-G. Type in /Volumes/OSBoot/usr/sbin/ and click Go.



Open a new Finder window and do the same thing to go to a folder, this time, however, select /usr/sbin/. This is the same folder located on your Mac’s hard drive.



From the Mac’s sbin folder, drag the file “sshd” to the Apple TV’s sbin folder. Your cursor will change in to the green plus sign to indicate that you are making a copy of the file.

Note: If you have accidentally ended up in /usr/bin instead of /usr/sbin and you accidentally copy the “ssh” file instead of “sshd”, you’ve made a big mistake and ssh will not work on your Apple TV. Be sure you are working to and from the respective /usr/sbin directories.



You now have sshd installed on your OSBoot volume. Now we need sshd to start when the Apple TV boots up.

In the OSBoot window, choose Go To Folder again and this time, enter /Volumes/OSBoot/System/Library/LaunchDaemons/.



If you open the Apple TV’s ssh.plist file from the LaunchDaemons directory, you’ll see why we need to replace it. Apple left a dummy plist file to throw us off the trail.



You could copy the ssh.plist file from the same location in your Mac’s /System/Library/LaunchDaemons/, but for simplicity, we’ve included the contents of the plist here. Using TextEdit, BBEdit, or your favorite text editor, copy and paste this text, replacing the original ssh.plist contents:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>Label</key>
        <string>com.openssh.sshd</string>
        <key>Program</key>
        <string>/usr/libexec/sshd-keygen-wrapper</string>
        <key>ProgramArguments</key>
        <array>
                <string>/usr/sbin/sshd</string>
                <string>-i</string>
        </array>
        <key>SessionCreate</key>
        <true/>
        <key>Sockets</key>
        <dict>
                <key>Listeners</key>
                <dict>
                        <key>Bonjour</key>
                        <array>
                                <string>ssh</string>
                                <string>sftp-ssh</string>
                        </array>
                        <key>SockServiceName</key>
                        <string>ssh</string>
                </dict>
        </dict>
        <key>StandardErrorPath</key>
        <string>/dev/null</string>
        <key>inetdCompatibility</key>
        <dict>
                <key>Wait</key>
                <false/>
        </dict>
</dict>
</plist>

Close the file and save it. In a nut shell, the ssh daemon is activated by launchd whenever an incoming connection on port 22 is detected.

Step 1 - Using the Terminal

Firstly, copy the sshd binary from your Mac to the AppleTV drive:

cp /usr/sbin/sshd /Volumes/OSBoot/usr/sbin/.

Next, copy the ssh.plist file over, so launchd knows to start sshd on boot:

cp /System/Library/LaunchDaemons/ssh.plist
/Volumes/OSBoot/System/Library/LaunchDaemons/ssh.plist

(The above is all on 1 line - I hit enter so the above line didn't wrap into the middle column of my blog)

Alternatively, you could use the contents of the file from above to create an ssh.plist file.

Step 2
Unmount the OSBoot and Media volumes, reassemble your Apple TV, and power it on. You need to get the IP address of the Apple TV from the Settings menu, once you know that, open a Terminal window from your Mac (or any OS that has ssh installed) and type:

ssh frontrow@your.apple.tv.ip.address

Press return. Type “yes” when it asks if you want to permanently store the key. Then enter “frontrow” as the password.

You’re in.

Now What?
SSH opens up a lot of doors to accessing the Apple TV. For example, you can now type sudo /usr/sbin/AppleFileServer and cause the built-in Apple File Protocol (AFP) server to start. Then you can connect to the Apple TV from your Mac by using the Connect to Server command in the Finder. AFP, SCP or SFTP can now be used to copy files to the Apple TV!!

You can type ps auxww to see a list of running processes on your Apple TV. (Hey, what is /usr/bin/ripstop and why is it running under the frontrow user?)

One thing we’ve already learned from SSH is that the root filesystem on the Apple TV (aka OSBoot) is apparently mounted as a read-only filesystem. That means it’s not initially possible to copy any files to the root mount point (/etc, /usr, /var, for example) while it is running. TylerL82 has commented to point out you can remedy this with the sudo mount -uw / command.

It’s also important to note that any changes you make to the OSBoot volume will be wiped out by a Factory Restore of the Apple TV. It appears that a disk image of the stock Apple TV operating system exists on the unlabeled partition on the drive and is used to restore the OSBoot volume when Factory Restore is selected.
 ---
 ssh into the appletv using the tutorial above. everything below
 will be through ssh:

 ----
 Download Bison 2.3 from:
 http://ftp.gnu.org/gnu/bison/bison-2.3.tar.gz

 (use curl via ssh)

 Decompress, open terminal, do:

 ./configure
 make
 sudo make install

 ------

 get wget:

 http://ftp.wayne.edu/pub/gnu/wget/wget-1.10.2.tar.gz

 decompress, terminal:

 ./configure
 make
 sudo make install


 close terminal.app and reopen
 ----

 do i need mysql here? is it installed?

 asterisk 1.4.2

 get http://ftp.digium.com/pub/asterisk/releases/asterisk-1.4.2.tar.gz

 decompress, open terminal, type:

 ./configure
 make
 sudo make install
 sudo make samples

 done. everything installed.

 --

 install a launchd service to start Asterisk.

 /Library/LaunchDaemons/com.asterisk.org.asterisk

 with contents:

 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC
 "-//Apple Computer//DTD PLIST 1.0//EN"
 "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
 <key>Disabled</key>
 <false/>
 <key>Label</key>
 <string>com.asterisk.org.asterisk</string>
 <key>ProgramArguments</key>
 <array>
 <string>/usr/sbin/asterisk</string>
 <string>-f</string>
 </array>
 <key>UserName</key>
 <string>frontrow</string>
 <key>GroupName</key>
 <string>frontrow </string>
 <key>OnDemand</key>
 <false/>
 <key>ServiceDescription</key>
 <string>Asterisk PBX</string> </dict> </plist>

 then do in terminal via ssh:

 sudo launchctl load -w /Library/LaunchDaemons/
 com.asterisk.org.asterisk

 ----
 GUI:

 svn checkout http://svn.digium.com/svn/asterisk-gui/trunk
 asterisk-gui
 cd in asterisk-gui
 ./configure (might not be needed) make sudo make install make
 samples sudo install samples

 mod the config files:
 cd /etc/asterisk

 manager.conf:

 enabled = yes
 webenabled = yes

 We will have to add a new user to `manager.conf`:
 [administrator]
 secret = wrxiur
 read = system,call,log,verbose,command,agent,user,config
 write = system,call,log,verbose,command,agent,user,config

 `http.conf`
 enabled=yes
 enablestatic=yes
 bindaddr=0.0.0.0

 make checkconfig to see if you messed up anywhere
 --
 change any other asterisk config files and reboot appletv. all
 Done!
 --

 gui can be accessed at:
 http://appletv.local:8088/asterisk/static/config/cfgbasic.html
 http://appletv.local:8088/asterisk/static/config/cfgadvanced.html

 If appletv.local is not the host, then change to the ip of the appletv.

You now should have a running version of Asterisk on Apple TV that should look like this:



Finally, if you want a PDF version of these instructions which has some additional interesting information (courtesy of Steven Sokol), click here to download. For instance, in the PDF, it states, "There is alot of testing needed and some call applications may not work yet. It's also unfortunate that the installation requires cracking the case and voiding the warranty. Hopefully in the near future somebody will come up with a reliable way to boot from USB and the SSH daemon, obviating the need for a hardware hacking."

Update
Sokol has also published a tutorial that is worth a look.


Related Articles to 'Asterisk on Apple TV Tutorial'
hiperpbx-cp-3000.png
webrtc2sip-click-to-call.png

Featured Events