This series of articles describes how to build a complete linux media server for finding, downloading, organising and streaming media.
Before we start, it goes without saying (but I’m saying it here anyway!) that this is a grey area, that you should already have legal entitlement to watch these shows through your terrestrial TV / cable TV provider and that downloading shows is your backup option.
This is simply a way to change how you store, manage and view the shows which you have already paid for – if people don’t pay for the shows, production companies cut their budgets, actors eschew parts in great dramas and instead plump for making adverts for Coca Cola – in a nutshell, all the cute bunnies and kittens die because of you!! You get the message.
To implement the full stack you will need to have usenet access from either your internet provider or one of the many monthly subscription usenet services. There are a few examples of these listed in the usenet configuration article.
We will approach this project in the following order:
This article details how to create a standard, headless debian server install. For our linux media server project we will be using the latest version distribution available at the time of writing: Debian 8.3.
You can also use the process below to build a standard debian server. It will be headless, i.e. no desktop environment e.g. Gnome as we don’t want to waste resources on running a desktop environment we won’t be using after setup is complete.
The net installer is about 315MB, the complete CD is around 650MB. If you are going to ever install more than one machine then the complete CD is far better value!
Create a new virtual machine (or prepare your physical server if that’s what you will use)
Go through a default install as shown below:
Choose “Install” from the boot up screen
Configure your language, keyboard and country fro the options given – here we are using UK English
Give your server a hostname, in this case we are using “merlin”
When asked to input a root password, we advise leaving this blank – this disables root login which is more secure
Enter a username – we are using “merlin” again here. This user will be able to carry out root permission commands using “sudo”, i.e. it will be a member of the “wheel” group
Accept all the default disk partitioning prompts (guided, use entire disk) then click to finish and write the partitions to disk
When prompted to scan another disk, answer “no” – CD1 is enough to create what we need for our debian server
Choose “yes” to use a network mirror in the next step. Don’t worry! We will not be downloading large amounts in the initial configuration but we will need it for the installation of individual packages later on. Pick your country and the relevant local network mirror site for quicker access to packages.
For the “Select and install software” use the arrow and spacebar keys to deselect “Debian Desktop Environment” and “print server”, select “SSH server” and leave “standard system utilities” selected as shown below:
Choose the default to install grub to the master boot record, in our case /dev/sda and then “continue to finish the installation.
Set a static IP address
This is important so that you can always find your server! The article > here < details how to do this via the /etc/network/interfaces file.
Make sure you can connect via SSH
Use a terminal client like putty to make sure you can connect – this install will all be done via console or SSH as we do not have a desktop environment.
sudo apt-get update
sudo apt-get upgrade
to make sure you have all the latest updates, including security patches.
Give “nobody” a Home!
If you are following this guide as part of the Linux Media Server project then you must create a home directory for the nobody user – this is so that our media applications have somewhere central to store their configuration data.
For this, we need to edit the /etc/passwd file, create some directories and assign permissions:
You could be forgiven for thinking that a simple “apt-get install” would suffice to install transmission-daemon and thoretically it does.
However! We want this set up securely and neatly as there are other components which need to interact with transmission and its files and directories and ideally we will have all of these running as user “nobody:nogroup”.
We need to make the following edits and permission changes:
Stop the daemon:
Edit /etc/init.d/transmission-daemon and change the user:
change USER=debian-transmission to USER=nobody:nogroup and save the file
As debian now uses systemd to manage services we also need to change the service “Unit” to reflect the different user. Edit the /lib/systemd/system/transmission-daemon.service file and change the following:
User=debian-transmission to User=nobody
Add the absolute path of the config file to the end of the ExecStart line to workaround a slight bug with $HOME variables, the line should read:
merlin@merlin:~$ ps aux | grep trans
nobody 418 0.5 1.7 60628 18512 ? Ssl 09:38 0:14 /usr/bin/transmission-daemon -f --log-error --config-dir=/var/lib/transmission-daemon/info
Tailing /var/log/syslog while restarting the service shows the following errors:
UDP Failed to set receive buffer: requested 4194304, got 327680 (tr-udp.c:78)
Failed to set send buffer: requested 1048576, got 327680 (tr-udp.c:89)
Transmission is requesting a 4MB receive buffer and a 1MB send buffer but not getting them. This can be swiftly corrected by adding the values to the sysctl.conf file and then refreshing with “sysctl -p”:
Once the values have been applied, a restart should be smooth and error free.
Change Default User Credentials & Allow Network GUI Access
As this is a headless server we are unlikely to be accessing it from localhost very often. Default settings allow only connections from 127.0.0.1 so edit the /etc/transmission-daemon/settings.json file and either add allowed IPs to the whitelist or disable the whitelist altogether (change rpc-enabled to false) – the latter should only be done if the server is not directly connected to the internet where anyone could access it!
Stop the daemon before editing, otherwise your changes will be overwritten when the service is stopped / started later: