As part of my quest to learn Linux I decided to replace my download machine which was running Windows 7 with Ubuntu Server 12.04.
I started with a fresh Ubuntu Server install on my VMWare ESXi server. I only made the drive 20GB because that’s all I really need for the OS. I made a second drive 250GB persistent and added it to the VM. This is where I store all of the pending and unorganized downloads.
Once the machine was loaded, I had to mount the 250GB persistent VM drive and my 10TB DroboFS share.
I won’t cover how to set up SABnzbd, SickBeard or CouchPotato because you can find those tutorials all over the place and they are all pretty much the same. The only thing I will cover is how to install them and make them automatically start on boot.
First I need to get the filesystem and folders set up.
Mounting the storage drive
I had originally intended to use LVM for the mass storage device but it caused problems with taking snapshots in ESXi. Instead I decided to go with just a regualr EXT3 drive. You lose the ability to easly grow the drive (although it can still be done) or add it to the OS drive, but for this situation it doesn’t really matter.
Anyway, this is what I had to do.
First, find the drive.
fdisk (fixed disk) is a tool for partitioning a drive. The -l flag lists the drives.
I know my drive is 250GB so I can see it is /dev/sdb. I will refer to this throughout the rest of the tutorial.
Now we need to partition the drive.
-
- Press m for menu.
- Press n for new partition.
- Press p to create a primary partition.
- Press 1 to make it the first partition.
- Press enter to accept the default start cylinder.
- Press enter to accept the default end cylinder.
- Now set the type. Press t for type.
- Press l to the list the format types.
- Look for LVM. Press 8e to select the LVM type.
- Now write the changes by pressing w.
- Check to make sure the partition was created.
Now list the drives again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
$ sudo fdisk -l Disk /dev/sda: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders, total 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x000c9f84 Device Boot Start End Blocks Id System /dev/sda1 * 2048 499711 248832 83 Linux /dev/sda2 501758 41940991 20719617 5 Extended /dev/sda5 501760 41940991 20719616 8e Linux LVM Disk /dev/sdb: 268.4 GB, 268435456000 bytes 100 heads, 39 sectors/track, 134432 cylinders, total 524288000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x7ae6b515 Device Boot Start End Blocks Id System /dev/sdb1 2048 524287999 262142976 83 Linux Disk /dev/mapper/services-root: 19.1 GB, 19050528768 bytes 255 heads, 63 sectors/track, 2316 cylinders, total 37208064 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/services-root doesn't contain a valid partition table Disk /dev/mapper/services-swap_1: 2143 MB, 2143289344 bytes 255 heads, 63 sectors/track, 260 cylinders, total 4186112 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Disk /dev/mapper/services-swap_1 doesn't contain a valid partition table |
Now I see /dev/sdb1.
Now I need to mount the drive so I can write files to it.
|
|
$ sudo mkdir /mnt/mass_storage $ sudo mount -t ext3 /dev/vgroup /mnt/mass_storage |
Now we check to make sure it is mounted correctly.
Mounting the DroboFS (NAS)
Now I need to mount my Media folder on the NAS. This is where all of my finished movies and TV shows are. I created a generic user/pass for it to make things easy.
First, make sure you have Samba and smbfs installed. More than likely it already is, but lets just make sure.
|
|
$ sudo apt-get install samba smbfs |
Now we need to mount it.
|
|
$ sudo mkdir /mnt/Media $ sudo mount -o guest,file_mode=0777,dir_mode=0777,rw -t cifs //192.168.1.30/Media /mnt/Media |
Mounting the NAS was a problem because I wasn’t able to write files to it. After about an hour I finally figured out what I was doing wrong. Even though I was mounting it with a user that had read/write, I wasn’t able to write any changes unless I was sudo. file_mode=0777 mounts the NAS under chmod 777 which allows read, write, execute (same for dir_mode).
I have my Media folder unprotected, but if you have your’s password protected you can use username=<username>,password=<password>.
The rw at the end means read/write. Probably not necessary since I set chmod to 777.
Make some shortcuts that we will need later.
|
|
$ cd ~ $ sudo mkdir /mnt/mass_storage/downloads $ sudo chown ryan /mnt/mass_storage/downloads $ ln -s /mnt/mass_storage/downloads downloads $ mkdir media $ cd media $ ln -s /mnt/Media/Movies Movies $ ln -s /mnt/Media/Music Music $ ln -s /mnt/Media/TV Shows TVShows |
This will create shortcuts for your new downloads (and those that are still downloading) and the location of your archived movies, music and TV shows. Make sure you set these directories to the correct respective path.
Installing SABnzbd
First lets organize our folders. TV Shows and Movies refers to the location of your TV Shows and movies. For me it is in the Media folder.
|
|
$ cd ~ $ sudo mkdir /mnt/mass_storage downloads $ ln -s /mnt/mass_storage/downloads downloads $ ln -s /mnt/Media/TV Shows TVShows $ ln -s /mnt/Media/Movies Movies |
This puts shortcuts to the folders in our home folder.
Now to install SABnzbd. You can install from apt-get, but the version in there is out of date. Instead lets add another repo to pull from, then install it from apt.
|
|
$ echo "deb http://ppa.launchpad.net/jcfp/ppa/ubuntu $(lsb_release -c -s) main" | sudo tee -a /etc/apt/sources.list && sudo apt-key adv --keyserver hkp://pool.sks-keyservers.net:11371 --recv-keys 0x98703123E0F52B2BE16D586EF13930B14BB9F05F $ sudo apt-get update $ sudo apt-get install sabnzbdplus $ sudo nano /etc/default/sabnzbdplus |
Enter your username where it says USER=.
Now you can reboot if you want to test that it automatically starts.
You may not be able to access the web interface the first time because it defaults to only allow access from the localhost. Here is how to fix it:
|
|
$ cd ~/.sabnzbd $ nano sabnzbd.ini |
Search for host (use CTRL+W to search). Change localhost to 0.0.0.0. Exit and restart sabnzbd.
|
|
$ /etc/init.d/sabnzbd restart |
Note: DO NOT USE SUDO TO START ANY OF THESE SERVICES! Only start these services as the local user.
Installing SickBeard
We will install SickBeard and CouchPotato with git. First make sure it is installed.
|
|
$ sudo apt-get install git |
Now lets download the source code.
|
|
$ cd ~ $ mkdir tmp $ cd tmp $ git clone https://github.com/midgetspy/Sick-Beard.git sickbeard |
When it is finished it should look like this:
|
|
ryan@services:~/tmp$ git clone https://github.com/midgetspy/Sick-Beard.git sickbeard Cloning into 'sickbeard'... remote: Counting objects: 20879, done. remote: Compressing objects: 100% (6847/6847), done. remote: Total 20879 (delta 14226), reused 19584 (delta 13111) Receiving objects: 100% (20879/20879), 7.73 MiB | 859 KiB/s, done. Resolving deltas: 100% (14226/14226), done. |
You can put it in your home folder if you want (mv sickbeard ../.sickbeard) which is where most people put it, but I like to put it in my /usr/share folder. Just remember where you put it.
Now we need to make it start on boot. This startup script and the one for CouchPotato are by daemox over at ainer.org.
|
|
$ sudo nano /etc/init.d/sickbeard |
Enter the following code in the file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
#! /bin/sh # Author: daemox # Basis: Parts of the script based on and inspired by work from # tret (sabnzbd.org), beckstown (xbmc.org), # and midgetspy (sickbeard.com). # Fixes: Alek (ainer.org), James (ainer.org), Tophicles (ainer.org), # croontje (sickbeard.com) # Contact: http://www.ainer.org # Version: 3.1 ### BEGIN INIT INFO # Provides: sickbeard # Required-Start: $local_fs $network $remote_fs # Required-Stop: $local_fs $network $remote_fs # Should-Start: $NetworkManager # Should-Stop: $NetworkManager # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts and stops sick beard # Description: Sick Beard is an Usenet PVR. For more information see: # http://www.sickbeard.com ### END INIT INFO #Required -- Must Be Changed! USER="CHANGEME" #Set Linux Mint, Ubuntu, or Debian user name here. #Required -- Defaults Provided (only change if you know you need to). HOST="127.0.0.1" #Set Sick Beard address here. PORT="8081" #Set Sick Beard port here. #Optional -- Unneeded unless you have added a user name and password to Sick Beard. SBUSR="" #Set Sick Beard user name (if you use one) here. SBPWD="" #Set Sick Beard password (if you use one) here. #Script -- No changes needed below. case "$1" in start) #Start Sick Beard and send all messages to /dev/null. cd /home/$USER/.sickbeard echo "Starting Sick Beard" sudo -u $USER -EH nohup python /home/$USER/.sickbeard/SickBeard.py -q > /dev/null 2>&1 & ;; stop) #Shutdown Sick Beard and delete the index.html files that wget generates. echo "Stopping Sick Beard" wget -q --user=$SBUSR --password=$SBPWD "http://$HOST:$PORT/home/shutdown/" --delete-after sleep 6s ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0 |
Change USER=”ChangeMe” to your username.
Make the file executable so it will actually run.
|
|
$ sudo chmod +x /etc/init.d/sickbeard |
Again, you can now reboot if you want to test it, or you can go on to installing CouchPotato.
Installing CouchPotato
The installation of CouchPotato is the same as SickBeard. We are going to install from the source on GitHub and create an autorun.
|
|
$ git clone https://github.com/RuudBurger/CouchPotato.git couchpotato |
Now make the auto run file.
|
|
$ sudo nano /etc/init.d/couchpotato |
Paste this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
#! /bin/sh # Author: RuudBurger # Edited by: daemox # Details: Cleaned up script to make it easier to enter in the USER info for the guide on Ainer.org. # Last updated: August 3, 2011 ### BEGIN INIT INFO # Provides: CouchPotato application instance # Required-Start: $local_fs $network $remote_fs # Required-Stop: $local_fs $network $remote_fs # Should-Start: $NetworkManager # Should-Stop: $NetworkManager # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts instance of CouchPotato # Description: starts instance of CouchPotato using start-stop-daemon ### END INIT INFO #Required -- Must be changed! USER="ChangeMe" #Set Ubuntu or Linux Mint username here. #Required -- Defaults provided (only change if you know you need to!). DAEMON=/usr/bin/python DAEMON_OPTS=" CouchPotato.py -q" NAME=couchpotato DESC=CouchPotato PID_FILE=/var/run/couchpotato.pid #Script -- No changes should be needed below! test -x $DAEMON || exit 0 set -e case "$1" in start) echo "Starting $DESC" start-stop-daemon -d /home/$USER/.couchpotato -c $USER --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS ;; stop) echo "Stopping $DESC" start-stop-daemon --stop --pidfile $PID_FILE ;; restart|force-reload) echo "Restarting $DESC" start-stop-daemon --stop --pidfile $PID_FILE sleep 15 start-stop-daemon -d /home/$USER/.couchpotato -c $USER --start --background --pidfile $PID_FILE --make-pidfile --exec $DAEMON -- $DAEMON_OPTS ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|force-reload}" >&2 exit 1 ;; esac exit 0 |
Again, change USER=”ChangeMe” to your username.
Make the file executable.
|
|
$ sudo chmod +x /etc/init.d/couchpotato $ sudo update-rc.d couchpotato defaults |
Wrapup
Ok, now you have SABnzbd, SickBeard, and CouchPotato setup. I also have a second hard drive and my NAS mounted.