Upset that your old AppleTV is left in the dust following the release of the new $99 AppleTV? Get Linux installed on that thing, and make it useful again!
After getting Debian successfully installed on the AppleTV, I wondered exactly how many services can run on it without overloading it. So far, the following services are running:
- Netatalk / avahi-daemon
- Samba
- GKrellMd
- OpenVPN
- Apache 2 + PHP5
- Asterisk 1.6 + Cepstral TTS + Lobstertech VoiceChanger + PHPAGI
- ircd-hybrid – IRC Server
- Nagios 3 with ircd-hybrid integration
Netatalk / avahi-daemon
This allows the AppleTV to show up on the network as a Macintosh OS X shared drive. We could easily plug in a USB external drive and this extra drive would also be shared on the network. If you want more information on configuring Netatalk on Linux, check my earlier blog posts on the subject.
Samba
This allows the AppleTV to show up on the network as a Windows shared drive.
GKrellMd
My favorite little monitoring app for Gnome, GKrellM allows you to monitor the server in real time from a little desktop widget.
OpenVPN
A simple VPN server which allows you to tunnel home from work or coffee shops.
Apache 2 + PHP5
A standard Apache 2+PHP5 install is running on this machine. Here is a screenshot of the default page I created for it:
In order to conserve memory, decrease some Apache config values:
[code]
<IfModule mpm_prefork_module>
StartServers 1
MinSpareServers 1
MaxSpareServers 5
MaxClients 50
MaxRequestsPerChild 0
</IfModule>
[/code]
WebDAV is enabled so I am able to quickly and easily edit this site using Coda.
Asterisk 1.6 + Cepstral TTS + Lobstertech VoiceChanger + PHPAGI
This AppleTV runs my VoIP phone server. Phone service is through Flowroute. If you call my phone number, it speaks out text to the caller using Cepstral TTS. Anyone placing calls using this phone system can spoof any outgoing number or change their voice with the help of the Lobstertech VoiceChanger module. Incoming spoofed CallerID numbers are “unmasked” and the true number is revealed. The main phone script is written with PHP code using PHPAGI. Surprisingly, the AppleTV CPU handles the Text to Speech very well and I don’t notice any CPU strain. Very flexible and fun phone system.
Here is a sample of what the code looks like:
[php]
function doMainMenu() {
global $debug;
global $fh;
global $agi;
$count = 0;
while ($count < 5) {
// Say Main Menu Script
$result = $agi->swift_get_data(‘Press 1 to ring the house phones or press 0 to leave a voice message.’);
// Capture which keys were pressed
$keys = $result[‘result’];
$key = $keys[0];
if ($debug) fwrite($fh, "Key Press:[". $keys[‘data’] . "]\n");
// Do something, based on which keys they pressed
if ($key == "1") doRingHousePhones();
elseif ($key == "0") doGoToVoicemail();
elseif ($key == "*") doLoginToVoicemail();
else {
$agi->swift("You didnt pick any options.");
}
$count++;
}
$agi->swift("Goodbye.");
}
[/php]
ircd-hybrid
The IRC server is used for Nagios 3 logging at the moment
Nagios 3 with ircd-hybrid integration
This is the newest addition, and a very sweet setup at that. Nagios 3 is an open source monitoring software. It monitors all of my equipment and servers and the services which are running on them. If CPU gets a little hot, or hard drive starts filling up, or website stops responding, it sends email/SMS notifications, and also sends a color coded notification to #nagios on the IRC server. Nagios uses Apache for the web front end.
General AppleTV tweaks
It turned out that the swap partition that I created was only 25MB or was only showing up as 25MB. This is a problem since this AppleTV only has 256MB of internal RAM. I ended up setting up a loopback swap file which basically allows you to have a ‘file’ on your main partition which will behave as a partition. This 512MB file is mounted as the swap for the system and is working perfectly.
[bash]
dd if=/dev/zero of=swapfile bs=1k seek=512k count=1
mkswap swapfile
losetup -f
losetup /dev/loop0 swapfile
swapon /dev/loop0
[/bash]
You can verify that it worked with either of these:
[bash]
cat /proc/meminfo | grep -i swap
free
[/bash]
Here is a screenshot of ‘top’ running on the AppleTV with all of these services running:
Check out the load average! This machine is simply kickin’ back!
If anyone is interested in more detail how any of these services are configured or if you have any suggestions on what other services should be added to this project, drop me a comment.
Leave a Reply