{"id":615,"date":"2010-09-11T11:31:35","date_gmt":"2010-09-11T18:31:35","guid":{"rendered":"http:\/\/chriscarey.com\/wordpress\/?p=615"},"modified":"2015-09-27T14:57:39","modified_gmt":"2015-09-27T22:57:39","slug":"tricking-out-your-appletv-running-linux","status":"publish","type":"post","link":"https:\/\/chriscarey.com\/blog\/2010\/09\/11\/tricking-out-your-appletv-running-linux\/","title":{"rendered":"Tricking out your AppleTV running Linux"},"content":{"rendered":"<p>Upset that your old AppleTV is left in the dust following the release of the new $99 AppleTV? <a href=\"\/\/chriscarey.com\/wordpress\/2010\/08\/22\/running-debian-on-appletv-aug-2010\/\">Get Linux installed on that thing<\/a>, and make it useful again!<\/p>\n<p>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:<\/p>\n<ul>\n<li>Netatalk \/ avahi-daemon<\/li>\n<li>Samba<\/li>\n<li>GKrellMd<\/li>\n<li>OpenVPN<\/li>\n<li>Apache 2 + PHP5<\/li>\n<li>Asterisk 1.6 + Cepstral TTS + Lobstertech VoiceChanger + PHPAGI<\/li>\n<li>ircd-hybrid &#8211; IRC Server<\/li>\n<li>Nagios 3 with ircd-hybrid integration<\/li>\n<\/ul>\n<h4>Netatalk \/ avahi-daemon<\/h4>\n<p>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 <a href=\"http:\/\/chriscarey.com\/wordpress\/2009\/04\/17\/netatalk-on-intrepid-once-again\/\">my earlier blog posts on the subject<\/a>.<\/p>\n<h4>Samba<\/h4>\n<p>This allows the AppleTV to show up on the network as a Windows shared drive. <\/p>\n<h4>GKrellMd<\/h4>\n<p>My favorite little monitoring app for Gnome, <a href=\"http:\/\/members.dslextreme.com\/users\/billw\/gkrellm\/gkrellm.html\">GKrellM<\/a> allows you to monitor the server in real time from a little desktop widget.<\/p>\n<h4>OpenVPN<\/h4>\n<p>A simple VPN server which allows you to tunnel home from work or coffee shops.<\/p>\n<h4>Apache 2 + PHP5<\/h4>\n<p>A standard Apache 2+PHP5 install is running on this machine. Here is a screenshot of the default page I created for it:<\/p>\n<p><a href=\"\/\/chriscarey.com\/wordpress\/wp-content\/uploads\/2010\/09\/debiantv-shot.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"618\" data-permalink=\"https:\/\/chriscarey.com\/blog\/2010\/09\/11\/tricking-out-your-appletv-running-linux\/debiantv-shot\/\" data-orig-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/debiantv-shot.png\" data-orig-size=\"697,486\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"debiantv shot\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/debiantv-shot-300x209.png\" data-large-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/debiantv-shot.png\" src=\"\/\/chriscarey.com\/wordpress\/wp-content\/uploads\/2010\/09\/debiantv-shot-300x209.png\" alt=\"\" title=\"debiantv shot\" width=\"300\" height=\"209\" class=\"alignnone size-medium wp-image-618\" srcset=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/debiantv-shot-300x209.png 300w, https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/debiantv-shot.png 697w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>In order to conserve memory, decrease some Apache config values:<\/p>\n<p>[code]<br \/>\n&lt;IfModule mpm_prefork_module&gt;<br \/>\n    StartServers          1<br \/>\n    MinSpareServers       1<br \/>\n    MaxSpareServers      5<br \/>\n    MaxClients          50<br \/>\n    MaxRequestsPerChild   0<br \/>\n&lt;\/IfModule&gt;<br \/>\n[\/code]<\/p>\n<p>WebDAV is enabled so I am able to quickly and easily edit this site using Coda.<\/p>\n<h4>Asterisk 1.6 + Cepstral TTS + Lobstertech VoiceChanger + PHPAGI<\/h4>\n<p>This AppleTV runs my VoIP phone server. Phone service is through <a href=\"http:\/\/flowroute.com\">Flowroute<\/a>. 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 &#8220;unmasked&#8221; 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&#8217;t notice any CPU strain. Very flexible and fun phone system.<\/p>\n<p>Here is a sample of what the code looks like:<br \/>\n[php]<br \/>\nfunction doMainMenu() {<\/p>\n<p>    global $debug;<br \/>\n    global $fh;<br \/>\n    global $agi;<\/p>\n<p>    $count = 0;<\/p>\n<p>    while ($count &lt; 5) {<br \/>\n    \/\/ Say Main Menu Script<br \/>\n    $result = $agi-&gt;swift_get_data(&#8216;Press 1 to ring the house phones or press 0 to leave a voice message.&#8217;);<\/p>\n<p>    \/\/ Capture which keys were pressed<br \/>\n    $keys = $result[&#8216;result&#8217;];<br \/>\n    $key = $keys[0];<br \/>\n    if ($debug) fwrite($fh, &quot;Key Press:[&quot;. $keys[&#8216;data&#8217;] . &quot;]\\n&quot;);<\/p>\n<p>    \/\/ Do something, based on which keys they pressed<br \/>\n    if ($key == &quot;1&quot;) doRingHousePhones();<br \/>\n    elseif ($key == &quot;0&quot;) doGoToVoicemail();<br \/>\n    elseif ($key == &quot;*&quot;) doLoginToVoicemail();<br \/>\n    else {<br \/>\n      $agi-&gt;swift(&quot;You didnt pick any options.&quot;);<br \/>\n    }<br \/>\n    $count++;<br \/>\n    }<\/p>\n<p>    $agi-&gt;swift(&quot;Goodbye.&quot;);<br \/>\n  }<br \/>\n[\/php]<\/p>\n<h4>ircd-hybrid<\/h4>\n<p>The IRC server is used for Nagios 3 logging at the moment<\/p>\n<h4>Nagios 3 with ircd-hybrid integration<\/h4>\n<p>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. <\/p>\n<p><a href=\"\/\/chriscarey.com\/wordpress\/wp-content\/uploads\/2010\/09\/nagios-shot.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"644\" data-permalink=\"https:\/\/chriscarey.com\/blog\/2010\/09\/11\/tricking-out-your-appletv-running-linux\/nagios-shot\/\" data-orig-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/nagios-shot.png\" data-orig-size=\"400,240\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"nagios shot\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/nagios-shot-300x180.png\" data-large-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/nagios-shot.png\" src=\"\/\/chriscarey.com\/wordpress\/wp-content\/uploads\/2010\/09\/nagios-shot.png\" alt=\"\" title=\"nagios shot\" width=\"400\" height=\"240\" class=\"alignnone size-full wp-image-644\" srcset=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/nagios-shot.png 400w, https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/nagios-shot-300x180.png 300w\" sizes=\"auto, (max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<h3>General AppleTV tweaks<\/h3>\n<p>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 <b>loopback swap file<\/b> which basically allows you to have a &#8216;file&#8217; 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.<\/p>\n<p>[bash]<br \/>\ndd if=\/dev\/zero of=swapfile bs=1k seek=512k count=1<br \/>\nmkswap swapfile<br \/>\nlosetup -f<br \/>\nlosetup \/dev\/loop0 swapfile<br \/>\nswapon \/dev\/loop0<br \/>\n[\/bash]<\/p>\n<p>You can verify that it worked with either of these:<br \/>\n[bash]<br \/>\ncat \/proc\/meminfo | grep -i swap<br \/>\nfree<br \/>\n[\/bash]<\/p>\n<p>Here is a screenshot of &#8216;top&#8217; running on the AppleTV with all of these services running:<\/p>\n<p><a href=\"\/\/chriscarey.com\/wordpress\/wp-content\/uploads\/2010\/09\/appletv-top.png\"><img loading=\"lazy\" decoding=\"async\" data-attachment-id=\"652\" data-permalink=\"https:\/\/chriscarey.com\/blog\/2010\/09\/11\/tricking-out-your-appletv-running-linux\/appletv-top\/\" data-orig-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/appletv-top.png\" data-orig-size=\"667,392\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"appletv top\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/appletv-top-300x176.png\" data-large-file=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/appletv-top.png\" src=\"\/\/chriscarey.com\/wordpress\/wp-content\/uploads\/2010\/09\/appletv-top.png\" alt=\"\" title=\"appletv top\" width=\"667\" height=\"392\" class=\"alignnone size-full wp-image-652\" srcset=\"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/appletv-top.png 667w, https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/appletv-top-300x176.png 300w\" sizes=\"auto, (max-width: 667px) 100vw, 667px\" \/><\/a><\/p>\n<p>Check out the load average! This machine is simply kickin&#8217; back!<\/p>\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":618,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[17],"tags":[],"class_list":["post-615","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-appletv"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/chriscarey.com\/blog\/wp-content\/uploads\/2010\/09\/debiantv-shot.png","jetpack_shortlink":"https:\/\/wp.me\/prpYG-9V","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts\/615","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/comments?post=615"}],"version-history":[{"count":51,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts\/615\/revisions"}],"predecessor-version":[{"id":1629,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/posts\/615\/revisions\/1629"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/media\/618"}],"wp:attachment":[{"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/media?parent=615"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/categories?post=615"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chriscarey.com\/blog\/wp-json\/wp\/v2\/tags?post=615"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}