
|
Welcome to the wonderful word of Apple. Your new Mac comes chock filled with a variety of intriguing software and helpful, built-in utilities, and we're sure that you'll enjoy your new machine for years to come. However, you may be wondering what in the heck to do with your old PC. Surely, that Windows machine gave you some good years, before it became plagued with menacing viruses and fattening bloatware. So, why not give it a new lease on life by reconfiguring your old PC to serve as a Linux media server for your Mac? It's the perfect trade-off and will ensure that no old computers rise up out of the ashes with revenge on the mind.
Before we get started, we'd like to caution that you'll probably need to upgrade the hard drive in your PC to correspond with the amount of media that you have. If you plan on using the heck out of this media service, we recommend you procure a gigabit ethernet networking card and a lightening fast router in order to maximize speed. In any case, most current rigs should work fine. We used an Intel Celeron 1.2GHz processor with 384MB of RAM.
Difficulty Level
Hard
What You Need
> Crunchbang Linux Standard Edition (www.crunchbanglinux.org)
> A Blank CD
> InfraRecorder (Windows only -- infrarecorder.org)
> PulpTunes (www.pulptunes.com)
> A PC that is connected to the Internet at all times
> One (or more) Macs
1) Partition + Install Linux
The first thing you need to decide is whether to delete Windows entirely or keep your PC as a dualboot machine. There is a certain euphoria attached to the act of deleting Windows, but we can understand if you want to keep it in case something goes awry.
However, server software performs best when the operating system uses a minimal amount of system resources, so we will be using a pared down version of Linux for this tutorial. We recommend Crunchbang Linux, a variant of Ubuntu that uses the lightweight OpenBox window manager, or Puppy Linux. Though this guide will use Crunchbang, the same steps will work for both. Once you have downloaded either ISO, use a program like InfraRecorder on Windows or Disk Utility on OS X to burn that image to CD.
If you happen to be using an older Mac for this project, check out our guide to installing Linux on it. All of the subsequent steps will remain the same.
On a PC, boot from the CD. To do this, you will need to press one of the F keys during startup, depending on your computer's model. Usually, this will be F12.
Once you reach the Crunchbang installer, either choose to install it side by side with Windows, and move the slider to give Crunchbang the majority of space, or select "use entire hard drive" to delete Windows completely. Proceed with the default install options.
Crunchbang In Action
2) Update Linux
Once you have installed Linux, it is time to boot into it and configure it. In the install process, you would have installed the GRUB boot menu, so when you start up your computer, you should be able to select which operating system to launch. Choose Crunchbang and log in.
The first thing you need to do is make sure your system is updated and running properly. Instead of using a menubar, every function in Crunchbang is accessible via the right click menu. With this in mind, right click and select System > System Upgrade. This will update your operating system with the latest software and patches. The Terminal window will close when finished updating the OS.

Next, make sure your repositories are up to date. Open Terminal (right click > Terminal), and type
sudo aptitude update
Every time you run a sudo command, it will ask you for your sudo password. This is the same, by default, as the password of the first account you set up.
Now, you are ready to start installing server software.
3) Configure SSH
Since this is a server, you don't want it to be plugged in to a monitor, keyboard, and mouse at all times. The best way to control it remotely is via SSH, which essentially lets you run terminal commands remotely. In Crunchbang, unlike other distros, SSH is not included by default, so we will have to install it manually.

Open Terminal and type in
sudo apt-get install ssh
It will ask you if you want to proceed. Type 'y'.
Now you need to test the SSH connection. First, take note of your IP address. To do this, go to Terminal and type
ifconfig
You will see a long string of text, but the important thing to note is what comes after "inet addr:" This is your server's IP address.

Now, go to your Mac and open up its Terminal (Applications > Utilities > Terminal). Type:
ssh {your username on linux}@{the ip address of your linux server}
It should ask you to add the RSA key to a list of trusted ones. Type 'yes.'
Now, you should be able to run commands as if you were typing them into the Linux computer directly. You can test this by running sudo aptitude update -- this will only work if your ssh connection works.
If you're so inclined. you can now use SSH for the remainder of the steps.
Next: Install AFP and an iTunes server
Netatalk is software that allows you to broadcast using the Apple File Protocol, or AFP. Think of it as a Linux version of Bonjour.

First, install the software. Either search for Netatalk in the Synaptic Package manager, or go to Terminal (either on your new Linux box, or on your Mac, via ssh) and type:
sudo aptitude install netatalk
Now, you need to configure Netatalk to broadcast on a given connection. By default, your ethernet connection is named eth0, so that is what we will add to the configuration file.
To open the config file, type
sudo nano /etc/netatalk/atalkd.conf
in the terminal. This will open the file in the nano text buffer. At the bottom of the file (press the down arrow to scroll all the way down), type
eth0
Press Control+O to save, you'll be promted in the Terminal window to save to the defualt location. Press return to do so. Press Control+X to exit.
This version of netatalk is flawed, as it passes the password to the server in cleartext. By default, OSX does not allow this, but it is easy to enable it. Launch the Terminal application on your Mac and open a new tab or window (Command+T or Command+N), and type:
defaults write com.apple.AppleShareClient afp_cleartext_allow -bool true
Now, you should be able to connect to the server! In order to test the connection, go to Finder's menu barnavigate to
Go > Go to Server > afp://{ip address of server}
5) Install Avahi

The system we just set up is slightly annoying -- we recognize that you probably don't want to click through the Finder's menu bar every time you need to grab a file from the server. Installing Avahi will force the server to broadcast via AppleTalk, which will make it pop up in your Finder menu every time you are on the same network as it.

First, install the software. On the Linux box launch Terminal, type
sudo aptitude install avahi-daemon
Now, you need to configure the avahi daemon, which will run when the server starts up. Type
sudo update-rc.d avahi-daemon defaults
and then
sudo nano /etc/avahi/services/afpd.service

In the blank file that opens, copy and paste this:
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_afpovertcp._tcp</type>
<port>548</port>
</service>
</service-group>
This will configure Avahi to use port 548, which is the default port for AFP. Press Control+X to exit and save the changes you've made

Now restart the daemon to configure the changes. In the terminal, type
sudo /etc/init.d/avahi-daemon restart
6) Firefly
Now you have a basic file server, but it isn't media ready just yet. To make your server more robust, you need to install several server applications. The first of these is Firefly, a basic iTunes server.

First, in Terminal, install the software by typing
sudo aptitude install mt-daapd
and then
sudo aptitude install libid3tag0
Mt-DAAPD is the iTunes server, and libid3tag0 installs standard ID3 tags, so that mt-daapd can interpret your music metadata properly.
Now, since you probably don't want to broadcast your main account, create a separate account that will contain your media. You can do this by right clicking > System > Users and Groups, or via the Terminal.
In Terminal, type
sudo adduser media
You'll be prompted to add a name, room number and phone number after this command. You can jsut add a name and hit return to skip through the rest of the queries.
su media
mkdir /home/media/music
exit
This will create a user named media. Make a directory called Music in media's home folder, and then exit.
Now, you can start the iTunes server. To do this, type
sudo /etc/init.d/mt-daapd start
Now, reset the server to the default configuration. Type
sudo update-rc.d mt-daapd default
In order to test the server, in a web browser, type http://{server ip address}:3689
This takes you to the Firefly admin page (the default Firefly port is 3689). It will now prompt you for a username and password. By default, both of these are 'mt-daapd'.

Click on "Configuration." You can now reset the default username and password. Next, in the text box labeled "extensions," add .MOV and .M4V, separated by commas. This will allow the server to scan for video files, playable by iTunes.
You can check the status of the server by clicking "server status." This will tell you which computers Firefly is streaming to, and what it is streaming. This is where you should go if you need to troubleshoot.
Click "save" to save the changes. To check your work, open iTunes on your Mac. You should see a shared library with any songs you have in the /home/media/music folder. Be sure to add media files to the Music folder we created above. You can drag and drop songs over the network from your Mac to the Linux box.
Next: Install PulpTunes and Torrent Server
7) Install PulpTunes
Shared iTunes is great, but Firefly will not work if you are outside your home network. PulpTunes is software that will display your music as a webpage, and stream it through a flash based player. Unfortunately, PulpTunes is not in the Ubuntu repositories, so installing it is a bit more work than sudo apt-get. You will need to download the .zip file manually from their website. Drag the unzipped PulpTunes folder to some folder on your server. The location is relatively unimportant -- we recommend the home directory.
PulpTunes works by using the file locations in your iTunes Library.xml file, which is in ~/Music/iTunes/ on your Mac. Unfortunately, the iTunes Library.xml file points to folder locations on your Mac, and PulpTunes doesn't remap the locations automatically. To fix this, create a copy of the iTunes Library.xml file, and open it with your favorite text editor (we used Smultron). Find and replace all instances of file://localhost/Users/{your Mac username}/Music/iTunes/iTunes Music/ with the location of the folder you plan to put your music in on the server.
The easiest way to do this is to copy line 10 of the iTunes Library.xml file, press Command+F (find) and use the "replace all" function. Save the file, and drag it to some location on your server.
Now, copy your music over, preserving the artist hierarchy, to the server. Use the location that you provided in the modified iTunes Library.xml file. This will only work if you let iTunes manage your music for you when you first configured it on your Mac.
Finally, run PulpTunes by running the pt_linux.sh script. This will install and run PulpTunes. To do this, type the file path of the script into the terminal. For example, if the script is in /home/media/pulptunes/, in Terminal, type
/home/media/pulptunes/pt_linux.sh

The installer will ask you for the location of the iTunes Library.xml file that you created in the previous step. Select it through the file browser that pops up. Once the PulpTunes server is running, an icon of an orange will show up in the taskbar of the server.

Finally, to test your PulpTunes setup, browse to
http://{server ip address}:15000
You should see a web interface where you can see all the music referenced in your iTunes Library.xml file. Note that you can only play back music that you have actually uploaded to the server.

8) Torrent Server
One of the touted features of dedicated Network Access Storage boxes, more commonly known as NAS, is a server torrent interface. Of course, we don't advocate torrenting illegally, but if you want to torrent directly to your server, it is relatively easy to set it up.
First, install Torrentflux, the server interface we will be using. In the terminal, type
sudo apt-get install torrentflux
Torrentflux uses the LAMP (Linux, Apache, MySQL, PHP) stack to power its web interface, so it will install it automatically when you use sudo apt-get. Now, you should be able to browse to the Torrentflux interface by navigating to
http://{server ip address}/torrentflux/

Torrentflux will ask you to log in with your Linux username and password
In the TorrentFlux interface, you can choose to upload a torrent file, download directly from a magnet link, or search for a torrent with one of the built in search engines (PirateBay, etc.). The file will download directly to the server.

Now you're ready to stream Media from your old PC to your new Mac!