Tuesday, October 27, 2009

Installing rutorrent on your AppleTV

My AppleTV experience started in June ‘09 with a 40gb version I bought used from craigslist.  I’ve made many hacks on it already, like installing XBMC and Boxee. I’ve set up samba filesharing service, installed rtorrent, fought a lot with python and rssdler, created special cron jobs, and expanded its capacity to 1.5TB via network streaming.  Rssdler allows it to watch RSS feeds and download torrents automatically via rtorrent.  I like rtorrent because it is very stable and utilizes little system resources.  With only 1.0Ghz and 256mb of ram, resources are always a concern.  So when I started to look for an easier way to control rtorrent, a small footprint was a factor.

My original plan was to install wtorrent, a web based client that allows you to view rtorrent’s information and control it in your web browser.  This requires a web server like apache or lighttpd running on the AppleTV, and uses memory.  wtorrent’s system requirements were pretty high actually, needing not only httpd, but also php, scgi, ajax, etc…  I looked for alternative web clients and came across rutorrent.

rutorrent has many good features, the best of which are a light footprint, easy install, and nice interface.  I want it to be easy to use so Alison can benefit from it.  It doesn’t have multi-user support or password protection, but my AppleTV isn’t accessible from the outside world so I don’t have much use for that.  You can set up passwords with .htaccess if you need it though.  I spent many hours trying several different combinations of web servers and rtorrent frontends, finding information spread widely around the internet.  I ended up using the following configuration which is working out quite nicely.  I’ll detail it here in hopes that someone else who is interested can save some time and effort as well.

In this tutorial, I assume that you’ve hacked your AppleTV with the patchstick already, and you’re familiar with ssh, nano, unix filesystems, apache httpd, and copying files to your AppleTV.  I’ll still try to make it easy to follow for those of you who just type what you are told.  Items in bold should be typed into the console.

  1. Install rtorrent.
    • This has been documented pretty well already by a few different sites.  Try
      http://dyve.posterous.com/a-proper-rtorrent-install-for-apple-tv and come back when you’re done.
    • Enable scgi in your rtorrent configuration file
      nano ~/.rtorrent.rc
      type scgi_port = 127.0.0.1:5000 in the global section (just make it the first line if you’re unsure)
    •  
  2. Install XAMPP 0.7.4.
    XAMPP is an all-in-one apache http/php/perl/mysql solution for linux and mac os x.

    • Goto http://sourceforge.net/projects/xampp/files/ and download xampp-macosx-0.7.4.tar.gz.
      I used the newest version that was available as a tar file because you’ll need to extract it with the -p option to preserve file permissions.  If someone verifies that the files from the .dmg files work, I will make an update.
    • Copy the tar file over to the AppleTV via scp or samba.  I copied it to /Users/frontrow/xampp-macosx-0.7.4.tar.gz
    • Login to the AppleTV with SSH and navigate to the folder you uploaded it to and type:
      sudo tar xfvpz xampp-macosx-0.7.4.tar.gz -C /Users/frontrow/
      • This will install the app to /Users/frontrow/Applications/xampp.  Other sites will tell you to extract it to / so it installs in /Applications/xampp, but the 40gb AppleTV will give you an error saying “Cannot write: No space left on device.”  This is because /Applications is in a separate partition on the hard drive.
    • Creating a symbolic link in /Applications will give you the same functionality as if it was installed in /Applications.  Type
      sudo ln -s /Users/frontrow/Applications/xampp /Applications/xampp

    • Set up your httpd.conf
      sudo nano /Applications/xampp/etc/httpd.conf

      • Set up the httpd.conf however you like.  Other sites like this can explain it better than I can. You can also skip this and come back at the end.
    • Start the xampp services
      sudo /Applications/xampp/xamppfiles/mampp start

      • If you get php errors, it’s because you didn’t use the -p flag when extracting the tar file contents.  If/When this completes successfully, you should be able to type http://the-ip-address-of-your-AppleTV in your web browser and get a page.
    • Setup XAMPP security
      sudo /Applications/xampp/xamppfiles/mampp security

      • Creating a password for mysql will cause the demo html page to not work.  Not that that is a big deal, you’ll be replacing it with rutorrent later
    • Create a LaunchAgent to start the program automatically on boot.  You can download my launchagent here.  Copy it over to the AppleTV and then copy it to /Library/LaunchAgents/ by typing
      mv org.awkwardtv.httpd.plist /Library/LaunchAgents/

      • Congratulations, at this point your web server is installed and will start automatically with the AppleTV.  Now it’s time to install the http frontend for rtorrent.
  3. Installing rutorrent.
    • Download the latest version from the homepage: http://code.google.com/p/rutorrent/ and extract the files to the directory your xampp httpd.conf file uses as default for web pages.  If you didn’t change it, this folder will be /Applications/xampp/htdocs/
      • I found it easiest to extract the files on a desktop computer, and then move them over to the AppleTV via samba.
        Alternatively:
        • Copy the tar.gz file via scp
        • Navigate to the folder in SSH
        • gunzip rtorrent-2.7.tar.gz
        • tar -xf rtorrent-2.7
        • cd rtorrent
        • mv * /Applications/xampp/htdocs/
    • Download the RPC plugin (rpc-1.0.tar.gz) from http://code.google.com/p/rutorrent/downloads/list.  Copy it over to the AppleTV.
      • gunzip rpc-1.0.tar.gz
      • tar -xf rpc-1.0.tar -C /Applications/xampp/htdocs/plugins/
    • Make sure it works by going to http://the-ip-address-of-your-AppleTV

Posted by eclipse on 10/27/2009 at 12:52 AM
TechApple • (6) CommentsLink to this entry