Monday, 23 November 2015

I've split these instructions into their own section just to make it easier to understand. We're going to go through the installation of Sickrage and Couchpotato on Ubuntu 14.04 using command line only to reduce the resources needed on the machine.

sudo cp /opt/CouchPotato/init/ubuntu /etc/init.d/couchpotatosudo chmod +x /etc/init.d/couchpotatocd /etc/init.d/sudo update-rc.d couchpotato defaultsAnd finally start it with sudo service couchpotato startNow connect to it with a browser at http://machinename:5050 to finish the setup.

##################### Configuration for /etc/init.d/deluge-daemon# The init.d script will only run if this variable non-empty.DELUGED_USER="username" # !!!CHANGE THIS!!!!# Should we run at startup?RUN_AT_STARTUP="YES"

Wednesday, 11 November 2015

Apologies if I've gone through this before, but I really wanted to start having a tidy up of my instructions and also wanted to to follow them to put things back from scratch. This time, I'm going to build a newsgroup indexer with NewzNab.

Now that I've offloaded my cloud server to a Raspberry Pi, I'm going to go and re-install Newznab onto my old broken Toshiba laptop. The laptop works well enough until you give it a graphical display, looks like something is up with the display chip but it's not needed here. The OS I'm going to use is Ubuntu server as it just seems to work.

All this work is done via SSH from a Linux desktop, you can just copy and paste the commands into a terminal window. First thing we need to do is run updates:

Under the resource limits section we need to change the maximum execution time to 120:

max_execution_time = 120

Then under Module Settings we need to change the time zone settings, in my case I'm the UK so I'm going to change it to:

date,timezone = Europe/London

There are other options depending on where you live, you can find these here.

Now it's SQL server time with:

sudo apt-get install mysql-client-5.5 libmysqlclient-dev apache2 mysql-server-5.5You will be asked to create a password for the SQL server, make sure it's a good strong one, then we edit another file.

sudo nano /etc/php5/apache2/php.ini

Under the resource limits section we need to change the maximum execution time to 120:

max_execution_time = 120andmemory_limit = -1

Then under Module Settings we need to change the time zone settings, in my case I'm the UK so I'm going to change it to:

date,timezone = Europe/London

Once you've saved that file create a new one with:

sudo nano /etc/apache2/sites-available/newznab.conf

And paste the following into it:

<VirtualHost *:80>

ServerAdmin webmaster@localhost

ServerName localhost

DocumentRoot /var/www/newznab/www

ErrorLog /var/log/apache2/error.log

LogLevel warn

</VirtualHost>

Change the port if you want it to run on a different port.

One more change to the Apache configuration file before we go on:

sudo nano /etc/apache2/apache2.conf

Find this bit

<Directory /var/www/>

Options Indexes FollowSymLinks

AllowOverride None

Require all granted

</Directory>

And change it to this:

<Directory /var/www/>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory>

We now need to get hold of Newznab itself, you can get it from here. Newznab classic works but there are some limitations, if you are serious just pay the money for a better product and you get free upgrades too.

Get the file downloaded and then we need to extract it and copy it to the right place,

As I have a paid for version I'm going to use a slightly different approach, for this you need to install subversion with the following command:

sudo apt-get install subversion

Then to get Newznab you enter the following command:

sudo svn co svn://svn.newznab.com/nn/branches/nnplus /var/www/newznab

At this point you will be asked for the root password for your system and the SVN login details that have been emailed to you by the Newznab team.

Now it's time to activate the changes:

sudo a2ensite newznab

sudo a2dissite 000-default

sudo a2enmod rewrite

sudo service apache2 restart

And now it's time to set permissions on the folders:

sudo chmod 777 /var/www/newznab/www/lib/smarty/templates_c

sudo chmod 777 /var/www/newznab/www/covers/movies

sudo chmod 777 /var/www/newznab/www/covers/music

sudo chmod 777 /var/www/newznab/www/covers/tv

sudo chmod 777 /var/www/newznab/www

sudo chmod 777 /var/www/newznab/www/install

sudo chmod 777 /var/www/newznab/nzbfiles/

sudo chmod 777 /var/www/newznab/www/covers/anime

We need to install a few more applications:

sudo apt-add-repository ppa:kirillshkrogalev/ffmpeg-next

sudo apt-get update

sudo apt-get install unrar mediainfo lame ffmpeg

When you run the Newznab config and go in to edit the site you will need to put the paths in for these files, they normally are:

/usr/bin/unrar

/usr/bin/mediainfo

/usr/bin/ffmpeg

/usr/bin/lame

And now point your browser to

http://servername/install

And just follow the instructions and prompts to configure your very own Newznab server.

Once you have finished the comfiguration, run this following command to change permissions on one of the folders.

sudo chmod 777 /var/www/newznab/nzbfiles/tmpunrar

Big thanks to the howtogeek website for help with these instructions, I've added a few bits and pieces to get to this stage.

Now that we have made it to this stage it's time to finish off the setting up and then we can add some newsgroups and get the server scanning these for updated files.

Go to the edit site option from your browser and fill in the information required, including the paths for the files we installed earlier such as unrar etc.

You also need to enter the newznab ID you got when you bought the software.

I want it to check and delete password protected releases.

And finally, I want to enable spotnab, just fill in the gaps with your information, it doesn't seem to want you to create any accounts.

Once you've done all that, you can save the settings and click on bulk add groups, in the group list box type *binaries* and in the active box select no. This will populate Newznab with the available binary groups but won't download anything from them initially.

Now click on "View Groups" and type in "Television" into the search box, click on go and it will display the name of all groups with the word "Television" in them. Click on "Activate" to activate the ones you want to scan and then we go back to the command line.

First we change to root with:

sudo -i

Then we change to the script directory with:

cd /var/www/newznab/misc/update_scripts

Then we run:

php update_binaries_threaded.php

This downloads all the updates from the active groups, followed by:

php update_binaries_releases.php

We should now have some files in newznab and we can think about adding some new groups, but we really need to get this process running on startup. So we can create a script in /usr/bin with the following command:

sudo nano /usr/bin/newznab

Paste the following text into it:

cd /var/www/newznab/misc/update_scripts

php update_binaries_threaded.php

php update_binaries_releases.php

Save it and run:

sudo chmod +x /usr/bin/newznab

So far the script looks like this:

cd /var/www/newznab/misc/update_scripts

php update_binaries_threaded.php

php update_binaries_releases.php

This means it's going to run once and then quit, so we need to make it loop back to the start once it's finished.

while :

do

cd /var/www/newznab/misc/update_scripts/

echo "Optimising Database"

php optimise_db.php

echo "Updating TV Schedule"

php update_tvschedule.php

echo "Updating Binaries"

php update_binaries_threaded.php

echo "Updating Releases"

php update_releases.php

echo "Resting"

echo "Press [CTRL+C] to stop.."

sleep 30

done

This will now continue until you press Control + C, the only thing is that you need to manually start it from the command line when you want to run it.

If you want it to run on startup, add it to the /etc/rc.local file as follows

sudo nano /etc/rc.local

Add a line before exit at the bottom that says

/usr/bin/newznab &

Save the file and then make it executable with:

sudo chmod +x /etc/rc.local

Finally, test it by running sudo /etc/rc.local

The only problem with this method is that there's no easy way to break the cycle.

I'm open to suggestions for better options, in the meantime, have fun with it.

By the way, you will need to have an account with a usenet provider, I tend to stick with Newsdemon as they are quite reliable,

Saturday, 7 November 2015

I've decided to use a Raspberry Pi as a cloud server, I'm going to install Raspbian on it, setup a couple of hard drives as an lvm and install owncloud. There were a few issues with lvm with the drives not mounting at boot time, I've come up with a workaround. But more of that later.We'll start by writing the image to an SD card first, you can get the image from here. I'm using Linux here so your method of writing the image to an SD card will be different depending on your OS.In Linux you use the dd command, in this case the SD card is appearing as /dev/sdg when I connect it to my deskstop, you can find out by type dmesg after connecting it.Once you've identified the correct device use the following command, the version of raspbian may be different than the one I've shown and please make sure you are using the correct device or you may write the image to an Ipod which is what I did originally.sudo dd bs=4M if=2015-09-24-raspbian-jessie.img of=/dev/sdgOnce it's finished writing, put the card into the Raspberry Pi and give it some electric.You should be able to look at the connected devices on your router to find out it's IP address. Once you have login to it with ssh pi@192.168.0.251 or whatever IP address it shows, the password is raspberry.One you login, enter the command sudo raspi-config for the configuration utility.

You should get the screen shown above, go down to advanced options and select update, once that's completed select Expand Filesystem so that it fills the card. Then, I'm going to boot options and I'm going to select the top option to boot to a text console and require a login. Next we go to Internationalisation Options and select your country. Then we go back to advanced options and select hostname, I'm changing mine to Andromeda because I can. And then finally back to Advanced Options to make sure that ssh starts on boot. Once you've done all that, go to finish to write the changes and reboot.Once it's rebooted, log back in and now it's time to add another user with the command:sudo adduser username Followed by:sudo adduser username sudoIf this is the same as the username on your desktop it means you won't have to enter your username everytime you want to connect and you can run commands as root with that user. Logout as pi and log back in as your user.Now, it's time to update it and setup the external hard drives, sudo apt-get updatesudo apt-get upgradeThen we install lvm so we can pool some hard drives together.sudo apt-get install lvm2Now plug in your external drives, I've got a 1Tb drive and a 512Mb drive showing up as /dev/sda and /dev/sdb.We need to partition them now with the command:sudo fdisk /dev/sda Use whatever device your drive is showing as.To delete any existing partitions we type "d", then "n" to create a new one, then "p" for primary, press enter on the next 3 screens to accept the defaults and then type "t" followed by "8e" to identify the drive as an lvm partition. Finally type "w" to write the information to the drive and quit, we then need to do the same for the other drive or drives.Now we prepare the partitions with:sudo pvcreate /dev/sda1 /dev/sdb1Now we create a "Volume Group" with the command:sudo vgcreate owncloud /dev/sda1 /dev/sdb1Now we give all the drive space to the volume with:sudo lvcreate -l 100%FREE -n owncloudlv owncloudThis creates a device called /dev/owncloud/owncloudlvNext it's time to create the filesystem with the command:sudo mkfs.ext4 /dev/owncloud/owncloudlvNow we can create the mount point for the volume, as this is going to be used as storage for my cloud server, I'm going to mount it at /var/www. So first we create the mount point with:sudo mkdir /var/wwwThen we mount it with sudo mount /dev/owncloud/owncloudlv /var/wwwNormally at this point we can add the UUID of the device to fstab to get the drive starting up at boot time, but there appears to be an issue with the OS here in that the lvm service won't start automatically. I've come up with a not very elegant workaround which is to use the rc.local file to start the service and mount the drive when it boots. So we edit the file with:sudo nano /etc/rc.localAnd at the end of the file above "exit" we need to add the following:## Stuff to make the lvm run on startupservice lvm2 startsleep 10/sbin/vgchange -a ysleep 10mount /dev/owncloud/owncloudlv /mnt/wwwsleep 10service apache2 restart## End of stuffThe apache2 line will just give an error at the moment until Apache is installed, it needs to be restarted after mounting the drive. I don't know if the sleep options are really needed but they are there to give the drives time to spin up.We now make sure that the file is executable with:sudo chmod +x /etc/rc.localGive it a reboot to make sure it all worksNow it's time to install owncloudWe begin by installing php:sudo apt-get install php5 php5-dev php-pear php5-gd php5-mysql php5-curlThen we change the config file:sudo nano /etc/php5/cli/php.iniUnder the resource limits section we need to change the maximum execution time to 120:

max_execution_time = 120

Then under Module Settings we need to change the time zone settings, in my case I'm the UK so I'm going to change it to:

Saturday, 22 August 2015

My little EE Box is feeling the strain with all the work it does on top of just file sharing. I've come across a slightly broken Toshiba laptop which works until you try to do anything graphical on it. But just running a text based desktop works fine, so I've decided to offload some of the tasks from the other machine on it.The first thing I'm going to do is install Ubuntu 14.04 server with just the basic packages and the ssh server so I can do the rest remotely. I'll configure the router to give it a static IP. I'm not going to go into any detail on that lot as you really shouldn't be doing the rest of this if you can't do that.But first I'm going to install Midnight Commander and a few other files as I'm going to be accessing an nfs share with this server, it's not essential and if this is going to be a standalone machine then you don't need the following:sudo apt-get install mc nfs-common nfs-serverThen with the help of some instructions from NoobsLabs, I'm going to setup my own cloud server using OwnCloud, it's going to take some time so go with me on this.Quite a few command to type so let's make a start:This is all one line:sudo sh -c "echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.10/ /' >> /etc/apt/sources.list.d/owncloud.list"And so is this:wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_14.10/Release.keysudo apt-key add - < Release.key

sudo apt-get update

sudo apt-get install owncloud

During the installation it's going to ask you to create a password for the SQL server, please remember this password and if you are going to get access while away from home make sure it's a good password.Then we have to set the permissions for the Owncloud folders:sudo chown -R www-data:www-data /var/www/owncloudandsudo chmod 0777 -R -v /var/www/*

Then we setup SSL to enable an encrypted connection, we are going to use self certification for this so you will get security alerts from some browsers when connecting.sudo apt-get install openssl

Now run ifconfig to find the IP address of the machine, mine is 192.168.0.251

And then past the following text in to the file you are about to create, replacing the IP address with the one for your server:sudo nano /etc/apache2/sites-enabled/owncloud.conf

<VirtualHost 192.168.0.251:80>

#### Redirect to port 443 ###

RewriteEngine on

ReWriteCond %{SERVER_PORT} !^443$

RewriteRule ^/(.*) https://%{HTTP_HOST}/$1 [NC,R,L]

#### End of Redirection configuration ###

DocumentRoot /var/www/owncloud/

<Directory /var/www/owncloud>

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

<VirtualHost 192.168.0.251:443>

####Configuration for SSL #####

SSLEngine on

SSLCertificateFile /etc/apache2/ssl/owncloud.pem

SSLCertificateKeyFile /etc/apache2/ssl/owncloud.key

#### End of SSL Configuration ####

DocumentRoot /var/www/owncloud/

<Directory /var/www/owncloud>

Options Indexes FollowSymLinks MultiViews

AllowOverride All

Require all granted

</Directory>

</VirtualHost>

And now we restart Apache with:sudo service apache2 restartYou should now be able to connect to the server with a browser using:https://machinenameCreate a login and get on with the initial configuration, if you are asked to add the server as a trusted domain just do it.Then you need to setup some port forwarding on your router so you can access the cloud from the outside world. And that's your cloud server all setup.Next up I'm going to install Newznab to index some newsgroups.Now we need to install some files:

Now we create the file structure with:

sudo mkdir /var/www

sudo mkdir /var/www/newznab

sudo chmod 0777 /var/www/newznab

Next we need to install php with the following:

sudo apt-get install php5 php5-dev php-pear

Then we install some php extensions with:

sudo apt-get install php5-gd php5-mysql php5-curl

Now we make some changes to the php configuration file:

sudo nano /etc/php5/cli/php.ini

Under the resource limits section we need to change the maximum execution time to 120:

max_execution_time = 120

Then under Module Settings we need to change the time zone settings, in my case I'm the UK so I'm going to change it to:

Now we need to create a configuration file for Newznab, so type the following to create an empty file:

sudo nano /etc/apache2/sites-available/newznab.conf

And then paste the following into the file:

<VirtualHost *:8080>

ServerAdmin webmaster@localhost

ServerName localhost

DocumentRoot /var/www/newznab/www

ErrorLog /var/log/apache2/error.log

LogLevel warn

</VirtualHost>

This will run Newznab on port 8080, change this if you want it to run on another port.Save this file to continue.We also need to enter another Apache file with:nano /etc/apache2/ports.confAdd Listen 8080 to the list or whatever port you have Newznab on.# If you just change the port or add more ports here, you will likely also# have to change the VirtualHost statement in# /etc/apache2/sites-enabled/000-default.confListen 80Listen 8080<IfModule ssl_module> Listen 443</IfModule><IfModule mod_gnutls.c> Listen 443</IfModule># vim: syntax=apache ts=4 sw=4 sts=4 sr noet

We now need to get hold of Newznab itself, you can get it from here. Newznab classic works but there are some limitations, if you are serious just pay the money for a better product and you get free upgrades too.

Get the file downloaded and then we need to extract it and copy it to the right place, if you have decided to use a graphical desktop you can follow these pictures.

As I have a paid for version I'm going to use a slightly different approach, for this you need to install subversion with the following command:

sudo apt-get install subversion

Then to get Newznab you enter the following command:

svn co svn://svn.newznab.com/nn/branches/nnplus /var/www/newznab

At this point you will be asked for the root password for your system and the SVM login details that have been emailed to you by the Newznab team.

You also need to edit /etc/apache2/apache2.conf and make this change:sudo nano/etc/apache2/apache2.conf

#########################################Now we change the permissions of this file with:

sudo chmod 755 /etc/init.d/deluge-daemon

Now we get it running on startup

sudo update-rc.d deluge-daemon defaults

We can then start it with this command:sudo invoke-rc.d deluge-daemon startAnd stop it with this command:sudo invoke-rc.d deluge-daemon stop

You should now be able to access it with http://machinename:8112Next up is SickRage to track and download the TV series you want to watchThere are some things that we need to install first:sudo apt-get install git-core python python-cheetahNow this bit gets installed as a normal user and not root:cd ~git clone https://github.com/SiCKRAGETV/SickRage.git .sickrageWe now need to create a file to get this working properlycd ~/.sickragecp -a autoProcessTV/autoProcessTV.cfg.sample autoProcessTV/autoProcessTV.cfg

And then we start it with:python ~/.sickrage/SickBeard.py -qNow connect to it with http://machinename:8081 and follow all the configuration steps, once that's done , shut it down from inside it's web interface and then it's time to get it running automatically.cd ~/.sickrage/runscriptsAnd then:sudo cp init.debian /etc/init.d/sickragesudo chmod +x /etc/init.d/sickrageNow we need to edit a file with:sudo nano /etc/default/sickrage

And add the following to it:

# COPY THIS FILE TO /etc/default/sickrage

#########################################################

# Change user below to the username you have installed SickRage into

#########################################################

SR_HOME=/home/user/.sickrage/

SR_DATA=/home/user/.sickrage/

SR_USER=user

SR_GROUP=user

Now we make this file executable

sudo chmod +x /etc/default/sickrage

And then update the boot sequence:

sudo update-rc.d sickrage defaults

We can now start and stop it with the following commands:

sudo service sickrage start

sudo service sickrage stopAnd now we move onto Couchpotato for films, so it's back to root for this lot and first up we run the following command:

sudo git clone https://github.com/RuudBurger/CouchPotatoServer.git /opt/CouchPotatoWe then need to change the file ownership with the following command:sudo chown -R username:username /opt/CouchPotatoReplace username with the username you will be running this under.

Now we make it a script to start it automaticallysudo nano /etc/default/couchpotatoPaste this lot in, replacing username with your usernameCP_HOME=/opt/CouchPotatoCP_USER=usernameCP_PIDFILE=/home/username/.couchpotato.pidCP_DATA=/opt/CouchPotatoNow we copy over the init filesudo cp /opt/CouchPotato/init/ubuntu /etc/init.d/couchpotatoThen we make it executablesudo chmod +x /etc/init.d/couchpotatoAnd finally make it run on startupcd /etc/init.d/sudo update-rc.d couchpotato defaults