Deluge as daemon in Mac

Start Deluge as daemon in Mac

 Deluge is my all time favorite torrent client. I usually run deluge as daemon with Web UI enable.  This is how I do it in mac.

  1. Download Deluge < > for mac;
  2. Copy and past Deluge in /Application folder
  3. Create a file and past the code and save it.
exec /Applications/ && /Applications/

There are two way to run this script.
In terminal:


OR you can run the script as startup;

In Terminal: 

nano ~/Library/LaunchAgents/local.deluged.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">

Change /Path/To/ to the location of the script. 

  • Again In terminal:
launchctl load ~/Library/LaunchAgents/local.deluged.plist

Taadddaa! its done 🙂


End of Deluge Daemon in Mac



Colour Plate for Android

Colour Plate App for Android

I recently started to learn to create android apps and this is my first app for android. I am using Processing app which lets you create your application in various language including JAVA, Javascript, python and Android.

Code for the main program:

import java.util.Random; //import random library [1]

void setup()

size(480, 800); //canvas size
background(84, 213, 184); //Initial Bg color

//Text format for Welcome Text
fill(255, 255, 255);
text(“Welcome to Colour Plate”+”\n”, width/8, height/2);
text(“Tap Anywhere to Start”+”\n”, width/4, height/2+30);

//Developer detail at bottom-right corner of the screen
fill(0, 102, 153);
text(“by A Khadka – 2014”, width-250, height-20);

void draw() {

void mousePressed()

Random r = new Random(); //initialise the random object
int red = r.nextInt(254) + 1; //random range 1 – 255
int green = r.nextInt(254) + 1;
int blue = r.nextInt(254) + 1;

background(red, blue, green); //assign bg colour
textSize(32); //text size
fill(255, 255, 255); // fill in white colour
text(“Red: “+red+”\n”+”Green: “+green+”\n”+”Blue: “+blue, width/6, height/3); //display the text in the Red, Green and Blue and their values
String hex = String.format(“#%02x%02x%02x”, red, green, blue); // convert rgb to hex [2]
text(“Hex: “+hex, width/6, height/2+40); //display the text in the text field



End of Colour Plate App for Android


SSL Certificate for Sickbeard, Couchpotato and deluge in OMV

Installation –  SSL Certificate for Sickbeard, Couchpotato and deluge in OMV 

Currently I am using OMV 0.5.45 (Sardaukar) and forked version of Sickbeard (alpha tpb), Couchpotato (b69f8b7e) and deluge 1.3.6.

In OMV, there is an easy way to create SSL Certificate that can be used in Sickbeard, Couchpotato and deluge.

– [ Start PreparatioN ] –

First login to OMV and at left hand side,

click on Certificates under System.


Add >> Create

Image 1.1 – OMV Certificates

Image 1.2 – Create Certificates

Fill in the relevant details and save (see image 1.3).

Image 1.3 – Fill in Detail
Image 1.4 – SSL Certificate

Again, click on list and change comment to something useful (see image 1.4).

NoticeNote: the common name should be your ip or domain name.
– [ Creating KEy files ] –

Now copy & past of the Private Key content in a text pad and save it as private.key and do same thing for Certificate and save it as certificate.crt

Image 2.1 – Key

Image 2.2 – Certificate

Now copy these file in your server and place it somewhere safe. For example, /etc/myky

mkdir /etc/myky
chmod 700 /etc/myky
copy file >> /etc/myky
– [ Configure SickBeard / Couchpotato / Deluge ] –
– [ Sickbeard –

Go General and web interface

Setting >> General >> Web Interface

Enable HTTPS and enter the path for certificate and private key


Now save it and restart the sickbeard

– [ Couchpotato] –
Setting >> General >> Show advanced settings

enter the path and restart couchpotato

– [ Deluge ] –
Preference >> Interface >> Use SSL

And restart the daemon


Image 3.1 – Sickbeard Settings

Image 3.2 – Couchpotato

Image 3.3 – Deluge setting
NoticeNote: Using SSL in deluge cause problem with sickbeard so you might need to use black hole for this setup. Use https://yourip to access the web interface.
– [ END Configure SickBeard / Couchpotato / Deluge ] –
– [ End SickBeard ] –

SickBeard + CouchPotato + Deluge + Plex

Installation –   SickBeard  +CouchPotato  + Deluge

I am using Openmediavault as my base OS. Its a Debian derivatives OS so all debian apps and command work in it. As for couchpotato and sickbeard (tpb version), these two are the best rss reader out there for automatic download and process the tv shows and movies.

Image 1.1 – SickBeard
Image 1.2 – CouchPotato
– [ Start PreparatioN ] –

Before going any further, I would suggest you guys to install deluge or your preferred torrent client first and then you can go ahead and install these application.

Both of these application are dependent to python so check if you have python installed or not

python -V

If its not, install python

apt-get install python python-twisted python-twisted-web python-openssl python-simplejson python-setuptools intltool python-xdg python-chardet geoip-database python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako

First, we need to install git as both of these application are hosted there.

apt-get install git-core

Next, install Cheetah, Sickbeard utilise it (optional but recommanded).

apt-get install python-cheetah
– [ Start SickBeard ] –

To install Sickbeard

git clone git:// my-sickbeard-install
cd my-sickbeard-install

Start SickBeard


Now go to clients browser and put your server ip and port number


Goto setting >> help & info, keep note of SB Config Files

NoticeNote: I am using root to install sickbeard but you can use any other user with administrative right.

To make SickBeard start at boot, go back to [user]/my-sickbeard-install, in my case

cd /root/my-sickbeard-install
mv init.ubuntu /etc/init.d/sickbeard

Now we need to create sickbeard file in /etc/default

nano /etc/default/sickbeard

Mine looks like this, change yours accordingly, both path and user (red color: its double dash – – without space)


Now add sickbeard to start up

update-rc.d sickbeard defaults

Start the sickbeard

/etc/init.d/sickbeard start
update[UPDATE:] Sickbeard tpb version is no longer supported by developer so I have updated with new sickbead fork. This should work but has some bugs 😦
– [ Configure SickBeard ] –
– [ Web Interface ] –

Lock Web Interface and change port number if you are planning to port forward it

Setting >> General >> Web Interface

Encrypt Passwords

Setting >> General >> Advanced Setting >> Encrypt Passwords

Now goto Search Option and enter torrent clients detail

NoticeNote: if you have followed my deluge tutorial and have label plugin, you can assign that in here. Sickbeard can apply label to download torrent and deluge can deal with label settings. First setup deluge label with all settings then just provide label name in sickbeard. Don’t need to put deluge directory or torrent ratio as you can put that in deluge label.
Setting >> Search Options >> Torrent Search
– [ Search Provider ] –
Setting >> Search Provider

You can select as many provider as you like and also drag and drop to priorities the provider in order.

– [ Post Processing ] –

With post processing, sickbeard can do lot of things like move downloaded files to approperied TV Series folders, rename it, Unpack RAR archive, as well as download metadata [Fanart, Season Thumbnail etc]

Settings >> Post Processing
– [ My Sickbeard Setup ] –

There are few things I have done in Sickbeard and might come handy to you guys too..

1. Sickbeard Snatch torrent files {Image 1.4} and sends to deluge and apply label “tvshow.en” {image 1.3}
2. After deluge complete download, it moves that to completed folder and keeps seeding {image 1.4}
Image 1.3 – Deluge Settings
Image 1.4 – Label Setting
3. Sickbeard scans the completed folder of deluge {image 1.5} and hard links files {if you move, deluge will stop seeding : not recommended!! 😉 } to their folders {Eg. /TVShows/Spicy City/}
4. Process filename  {image 1.6; Eg. /TVShows/Spicy City/Spicy City.S01E01 – Love is a Download; plex can easily  recognised this filename}
Image 1.5 – Post-Processing
Image 1.6 – Custom FileName (Fix for plex)
5. Downloads metadata {image 1.7; plex will use the downloaded image, but this one is optional as plex can download it automatic }
6. Send notification to plex to scan library, and plex client {image 1.8}
Image 1.7 – Download ArtWork
Image 1.8 – Send Library Scan Command

infoUpdate: To enable Unpack (see image 1.5), you should install unrar first.

echo “deb squeeze-updates main non-free” >> /etc/apt/sources.list
echo “deb-src squeeze-updates main non-free”>> /etc/apt/sources.list
apt-get update & apt-get install unrar
– [ END Configure SickBeard ] –
– [ End SickBeard ] –
– [ Start Couchpotato ] –

Installation of CouchPotato is similar to Sickbeard.

Download CouchPotato from git

 git clone git:// couchpotato

Goto couchpotato folder

cd couchpotato

Start couchpotato


Now goto your browser and enter

your server id:5050

Finish the set wizard, just setup the login deal for now and scroll at the bottom and finish.

To start CouchPotato at boot; go to couchpotato folder

cd /root/couchpotato
mv /init/ubuntu /etc/init.d/couchpotato

Now create couchpotato default file

nano /etc/default/couchpotato

Mine looks like this


Add it to startup

update-rc.d couchpotato defaults

Start couchpotato

/etc/init.d/couchpotato start
/etc/init.d/sickbeard start
– [ Configure Couchpotato ] –
– [My Configuration] –
1. Select the desire Torrent Providers {see image 2.1}
2. Deluge option in CouchPotato didn’t work for me as it tries to run deluge demons but there is already one running so I am using black hole {drops snatch torrent in here, deluge with autoadd plugins will add / apply different attributes}
Image 2.1 – Searcher
Image 2.2 – Downloader
3. CouchPotato can automatic download any movies that in queue in various website {image 2.3}
4. Sends notifications to plex server and clients
Image 2.3 – Automation
Image 2.4 – Notification
– [ END Configure CouchPotato ] –
– [ End CouchPotato ] –

Custom Section Icons for Plex Media Client

Custom Section Icons for Plex Media Server ( Web Manager / Client )
Things you need
1. Plex media Server 😉
2. Firefox
3. SQLite Manager Plugin (here)
4. Icon Set ( I used
5. Free Image host ( I used Picasa web)
6. SSH Client ( I used Cyberduck)

Plex Media Server has three frontend OR client User Interface (UI). They are as follow:

1. Plex Media Client (Windows / Mac)
2. Plex Media Manager (Web Manager)
3. iOS / Android Apps (Mobile OS)

 All of these UI has a common icon for section which I think is not suitable to clearly distinguish the section. As shown in Image 1.1, TV shows, Documentary, Anime has a common icon. Similarly, movie and movie (Anime) has similar icon too. Plex should have given option to change these icon but as for now there is no option to change it.

myplexImage 1.1 – Default Web Manager Interface
iconImage 1.2 – Custom Icon Web Manager Interface

But there is workaround for this problem[1].  As plex use single SQL DB to manage its database its not difficult to change the icon. We need to change few attributes to assign new icons to these section.

So before we assign icon to section we need to host it online. ( I have tried putting icon locally in HD but it didn’t work 😦 ). I used picasa to host my icon. After upload, you need to share icon.

Now we modify SQL db. SQL db can be found under

[user]/Library/Application Support/Plex Media Server/Plugin-in Support/Databases/com.plexapp.plugins.library.db

SSH into server and Stop plexmediaserver

/etc/init.d/plexmediaserver stop

And make backup of the db file.

cd [user]/Library/Application\ Support/Plex\ Media\ Server/Plugin-in\ Support/Databases/
mv com.plexapp.plugins.library.db com.plexapp.plugins.library.db.bak

Now copy db file in your local HD (in desktop? 🙂 ) and run Firefox and click SQLite Manager and open the db file

Tools > SQLite Manager > open com.plexapp.plugins.library.db

Select library_sections at left hand side and list of section will appear at righthand side as shown in image 1.3. Double click on any section that you want to change.

Scroll down to number “9. user_thumb_url ( varchar (255))” as shown in Image 1.4. and enter the url for your image.

library_sections > double click section > 9. user_thumb_url > enter image url > OK
NoticeNote: url should be direct link to image not just link. For example, http://thisismyimage won’t work, where as http://thisismyimage.png will work. I have not tested other type of image so its best you convert image to png or you can test it yourself. (If you have used, the download highest resolution png from there and upload it to picasa)
sqlImage 1.3 – SQLite Manager
Section OptionImage 1.4 – Section Option

Press OK and copy db file back to server. Now start the server.

/etc/init.d/plexmediaserver start

Icon should change in all client. 🙂

update[UPDATE:] this does not work with iOS client. 😦
End of Custom Icon for Plex Media Server

Tightvnc Server + jDownloader in Openmediavault

Tightvnc Server + jDownloader in Openmediavault (debian)

Tightvnc server is very useful for remote management. This can be implemented in both with head/headless operating system (Debian / Openmediavault ).  Please go here to find out how you can install LXDE / Tightvnc server in Openmedivault.

jDownload is a java base platform independent downloader. It can download normal files as well as can download from various other host like rapid share, youtube, and many other host. For more information please visit (

Image 1.1 – JDownloader

To install jDownloader you need java install in the system. I will be installing latest Oracle Java 7. First we will add Webup D8 repo for Oracle Java 7. Run these command in terminal

echo “deb precise main” | tee -a /etc/apt/sources.list
echo “deb-src precise main” | tee -a /etc/apt/sources.list
apt-key adv –keyserver –recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer

Now it will ask you to accept their EUL and it will install Java 7

Again to set java environment

apt-get install oracle-java7-set-default

-=-=-= JDownloader Installation =-=-=-

Now installation of JDownloader. Its fairly simple.

 chmod +x

Now run tightvncserver

tightvncserver :1

open your desire vnc client and

Now double click of script it should load jdownloader installer and then finish the installation.

Optional (enable remote control)

Remote control option in jDownload is very helpful to send you link to jDownloader directly from your web browser. To enable remote control goto

jDownloader Settings >>  Plugins & Addons >> Extensions >> Tick JD Remote Control

Now under

Extensions >> JD Remote Control >> assign desire port, Default port : 10025

Download plugins for web browser:

Google Chrome : JDownloader Integration  (here)

Firefox : Push To JDownloader (here)

Once you install you need to set up these extension. Just assign your server ip and test it.

Tightvnc Server + jDownloader in Openmediavault

Openmediavault + Pydio ( Formally AjaXplorer) (Remote Web File Management)

– [ Installation – Pydio in OMV ] –

Openmediavault (OMV) has a Web UI to control and monitor the system but does not have a file explorer that you can use. So I thought there should be a web UI based application that I can install in OMV to access my files. I found Pydio which has very good UI (see image 1.1). It not only has Web UI but also have dedicated apps for iOS / Android OS.

Image 1.1 – Pydio (Formally AjaXplore) Web UI

Lets begin the installation. First we need to install openmediavault-website plugin from plugin section of OMV. Go to and select appropriate plugins. My current OMV version is 4 (Fedaykin) so I have downloaded the file >upload / install it from plugin section.

After installation you will have a section “” under System Folder.  Now select all the option and press OK.

NoticeNote: Both repository are either unstable / experimental. So by installing plugins from these repository you are accepting the challenge for any problem that might occur. In my experience plugin in unstable are much safer than those are in experimental stage. So install it with caution.

Now install website plugins.

Login > Plugins > Openmediavault-website *version > Install

After installation, refresh the browser. You will see website section under Services

Image 1.2 – Website Plugin – OMV

In this section, you need to first create folder where you want to store AjaXplore files.

Document root > click on plus > Create a folder  

We are going to use “Port Based” as Virtual host Type and 8181 as Virtual host port. Note: You can change port to any other number you like, make sure no other application are using it. [Maximum port = 65535]

 And then select user in User section select a user which is in User group. You can create user from Access Right Management > User and put that user into User group in Groups.

Document root > click on Enable Allow PHP Script to be executed > select User

After that go to share folder and select the folder that you created for website and give your user read/write privileges from privileges section.

Document root > click on Access Right Management > Shared Folders > [Website Folder] > Privileges > User > OK

Than go back to Website section 

Document root > click on Select Enable (top of the page )> OK


Now we need to download Ajaxplore and install it.

First ssh into OMV and go to website folder. In my case its /media/partitiction name/web

cd  /media/[partition name]/web
tar xvzf

Now move all the files from ajaxplorer-core-4.2.3 folder to web. [Explanation: By doing this you just need to type ip:port number, don’t need to remember folder name for ajaxplorer]

mv -v ./pydio-core-5.0.4/* /media/[partition name]/web/

Now check if its running or not. Goto browser and type

It will ask you to enter login detail. Default user name / password is admin. After login in we need to change password.

Top Right corner click to admin and change password

Document root > click on Admin > Change password 
– [ End of  Installation – AjaXplorer in OMV ] –
– [ Start of Extra for AjaXplorer ] –

Till now you can access your server and create a folder but have no access to any other folder. Generally Ajaxplorer creates all files and folder in

/media/[partition name]/[website folder]/data/files

To access other folder in your system you need to make sure your user has right to that folder. Go to

Document root > click on Access Right Management > Share folders > [your folder] > privileges > check user name > OK

Now in AjaXplorer

Top right corner > user name > Settings

Click on Workspaces and new workspaces then choose Access Drive : File System (Standard)

Again, give a Label, enter the path to your folder and change File Creation Mask to 1777.

User name > Setting > Workspaces > New Workspaces>  Select Access Driver as File System (Standard) > Give a label> Enter Path > change permission > OK

There are other settings like enable recycle bin or not, its totally up to you. (see image 1.3)

Image 1.3 – AjaXplorer

There are many other useful feature in AjaXplorer like accessing samba share in other local network drive (eg. Mybook Live (you need smbclient for this apt-get install smbclient). Similarly, many other function like multi user acesse, imap, drobpox, etc. So have fun exploring.

If you want to access AjaXplorer outside your network open the given port in your router. For this example its 8181.

NoticeSide Note: This can also be done in Debian. You just need to add repo and install ajaxplore. I think its much easer in Debian than omv as OMV has its own web UI. This installation method will cause lot of problem in OMV. I don’t recommend installing ajaxplore this way in OMV.

End of Extra for AjaXplorer

Openmediavault + Mybook Live

Start of Openmediavault + Mybook Live (1TB – Black)


Openmediavault (OMV) is a Debian based headless operating system (more info) while Mybook Live (review)is a network attached storage device. I have been using both for a while now and I did ran into few problems with Mybook Live but it was all because of me (experimenting lot of things in it). The interesting fact about Mybook Live is it runs a strip down version of Debian lenny and I thought I would play around with it and tried to upgrade it to Debian squeeze but I fall really badly so had to restore everything manually (had to open it physically – that voids manufacture warranty ).

Anyway long story short don’t play around with Mybook Live Debian cause its a customised Debian and things might not work as it suppose to. But if you have too, 😀 then you can go to They have lot of tricks / hacks there.

Back to topic, When you first attach Mybook Live to network it will assign itself as the first IP address that you have in your Ip range.

For example,

My router runs in and my IP range is – 200, so Mybook Live will automatically assign itself to no matter if that ip is assign to any other device. It might not be suitable in some case. Eg, if your printer use that IP then they will be constant war between printer & MyBook Live for that IP. 

The work around for this is to assign Static IP for Mybook Live later in its settings. The good things about Mybook Live is it has its own web management system where you can change it easily.

Image 1.1 – MyBook Live

When you first type IP for Mybook Live, it will give you this web interface (see image 1.1). Its very simple and easy to use interface.

Settings >>Network>>Static >> Assign Ip
MybookLive - Static Ip
Image 1.2 – MyBook Live – Static IP Settings

Now next step that we need to do is create a user and share folder. By default Mybook has an admin as user and Public as a share folder with can be access by anyone in network (Mac/Windows/Linux).

We can add users and give a password in user section and create share folder in share section. For this demonstration I be using “admin” as user with an assign password and create a share folder call “mybook”

MybookLive - Share Folder
Image 1.3 – MyBook Live – New Share Folder

Next thing we need to do is setup this share folder to automatically mount in OMV. 

First ssh into OMV and install cifs-utils, we will be using this to mount share folder.

apt-get install cifs-utils

Then create a mount point. In my case I will create a folder called mybooklive in /media folder

mkdir /media/mybooklive

Now before we mount share drive we will create a folder where we can safely keep password file.

mkdir /etc/smbpw
chmod 700 /etc/smbpw

Then create a file called cifspw and enter user name and password of share folder

nano /etc/smbpw/cifspw
chmod 600 /etc/smbpw/cifspw

Now we need to add this share folder to /etc/fstab where system will automatically load drives and share folder when it reboots

nano /etc/fstab

Then add this line at the button, Don’t forget to change your Mybook Live IP

// cifs exec,credentials=/etc/smbpw/cifspw 0 2
mount -a

Now it should mount mybook share folder in /media/mybooklive 🙂

info UPDATE [Quick & Dirty]: if you are using *nix OS, its better to use NFS than smb. I find NFS lot faster than Samba as NFS is native  to *nix OS than Samba.

-[Server Configuration (mybooklive)]-

ssh root@
echo “/DataVolume/shares/mybook *(rw,no_root_squash,sync,no_subtree_check,insecure)” >>/etc/exports
chown nobody:nogroup /DataVolume/shares/mybook
/etc/init.d/nfs-kernel-server restart

-[ Client (OMV) ]-

echo “ /media/mybooklive nfs rw,sync,hard,intr 0 0” >> /etc/fstab
nano /etc/rc.local

Now add mount -a before exit 0 and save

mount -a

Reboot system or run mount -a in terminal

End of Openmediavault + Mybook Live

Openmediavault + Deluge 1.3.11

[UPDATE to Deluge 1.3.11] Installation – Deluge 1.3.6

Openmediavault is a Debian based lightweight OS with web management control system. For more information go here. While deluge  is just another torrent client but has the most beautiful web interface (see image 1.1) out there for torrent client (may be just be. :)).

For this installation I will be using root user to run deluge but you can use any other user.

Image 1.1 – Deluge 1.3.10 Web Interface

For Deluge  1.3.11, there is no direct way to install it in OS (e.g repo or deb). So we need to compile it from package and install it.

Lets first install application dependent package

apt-get install python python-twisted python-twisted-web python-openssl python-simplejson python-setuptools intltool python-xdg python-chardet geoip-database python-libtorrent python-notify python-pygame python-glade2 librsvg2-common xdg-utils python-mako

Now we need to download deluge tar package.

Now unpack the package

tar xvzf /root/deluge-1.3.11.tar.gz
cd deluge-1.3.11

After this we need to download libtorrent

# update url to this >> LT_URL=
cd libtorrent/include
cd ..
./configure --enable-python-binding
make install

clean python environment

cd /root/deluge-1.3.11
python clean

Now build the deluge package and install it.

python build
python install

After installation we need to do few thing to make deluge up and running.

1. Setup daemon

2. Setup Web Interface

For daemon, create file with name deluge-daemon in /etc/init.d/deluge-daemon

nano /etc/init.d/deluge-daemon

Now copy the following text into it.(For some reason copying didn’t work for me in fresh install so Download File from if it didn’t work for you too)

# Provides: deluge-daemon
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Daemonized version of deluge and webui.
# Description: Starts the deluge daemon with the user specified in
# /etc/default/deluge-daemon.
# Author: Adolfo R. Brandes
# Modified: Sami OlmariPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC=”Deluge Daemon”
DAEMON1_ARGS=”-d -l /var/log/deluged.log -L warning”
DAEMON2_ARGS=”-p 8112 -l /var/log/deluge-web.log -L warning”
SCRIPTNAME=/etc/init.d/$PKGNAME# Exit if the package is not installed
[ -x “$DAEMON1” -a -x “$DAEMON2” ] || exit 0# Read configuration variable file if it is present
[ -r /etc/default/$PKGNAME ] && . /etc/default/$PKGNAME# Load the VERBOSE setting and other rcS variables
[ -f /etc/default/rcS ] && . /etc/default/rcS# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

if [ -z “$RUN_AT_STARTUP” -o “$RUN_AT_STARTUP” != “YES” ]
log_warning_msg “Not starting $PKGNAME, edit /etc/default/$PKGNAME to start it.”
exit 0

if [ -z “$DELUGED_USER” ]
log_warning_msg “Not starting $PKGNAME, DELUGED_USER not set in /etc/default/$PKGNAME.”
exit 0

# Function that starts the daemon/service
# Return
# 0 if daemon has been started
# 1 if daemon was already running
# 2 if daemon could not be started
start-stop-daemon –start –background –quiet –pidfile $PIDFILE1 –exec $DAEMON1 \
–chuid $DELUGED_USER –user $DELUGED_USER –test > /dev/null
start-stop-daemon –start –background –quiet –pidfile $PIDFILE2 –exec $DAEMON2 \
–chuid $DELUGED_USER –user $DELUGED_USER –test > /dev/null
[ “$RETVAL1” = “0” -a “$RETVAL2” = “0” ] || return 1

start-stop-daemon –start –background –quiet –pidfile $PIDFILE1 –make-pidfile –exec $DAEMON1 \
sleep 2
start-stop-daemon –start –background –quiet –pidfile $PIDFILE2 –make-pidfile –exec $DAEMON2 \
[ “$RETVAL1” = “0” -a “$RETVAL2” = “0” ] || return 2

# Function that stops the daemon/service
# Return
# 0 if daemon has been stopped
# 1 if daemon was already stopped
# 2 if daemon could not be stopped
# other if a failure occurred

start-stop-daemon –stop –quiet –retry=TERM/30/KILL/5 –user $DELUGED_USER –pidfile $PIDFILE2
start-stop-daemon –stop –quiet –retry=TERM/30/KILL/5 –user $DELUGED_USER –pidfile $PIDFILE1
[ “$RETVAL1” = “2” -o “$RETVAL2” = “2” ] && return 2


[ “$RETVAL1” = “0” -a “$RETVAL2” = “0” ] && return 0 || return 1

case “$1” in
[ “$VERBOSE” != no ] && log_daemon_msg “Starting $DESC” “$NAME1”
case “$?” in
0|1) [ “$VERBOSE” != no ] && log_end_msg 0 ;;
2) [ “$VERBOSE” != no ] && log_end_msg 1 ;;
[ “$VERBOSE” != no ] && log_daemon_msg “Stopping $DESC” “$NAME1”
case “$?” in
0|1) [ “$VERBOSE” != no ] && log_end_msg 0 ;;
2) [ “$VERBOSE” != no ] && log_end_msg 1 ;;
log_daemon_msg “Restarting $DESC” “$NAME1”
case “$?” in
case “$?” in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;; # Old process is still running
*) log_end_msg 1 ;; # Failed to start
# Failed to stop
log_end_msg 1
echo “Usage: $SCRIPTNAME {start|stop|restart|force-reload}” >&2
exit 3


Now change permission of deluge-daemon file.

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

To run deluge at startup, we need add deluge daemon at startup list.

update-rc.d deluge-daemon defaults

Now we need add user in deluge configuration file.

nano /etc/default/deluge-daemon

# Configuration for /etc/init.d/deluge-daemon

# The init.d script will only run if this variable non-empty.

# Should we run at startup?

and at line 4,  change “” to root

To start daemon

invoke-rc.d deluge-daemon start

Goto your browser and enter

[your server id]:8112

 It will ask for password. The default password is deluge

1. Click on connection manager
2. Click on connect

Image 1.1 – Deluge 1.3.6 Web Interface

Its best to change default password to something else. Go to Preference next to connect manager -> interface -> and change password

Image 1.2 – Deluge 1.3.6 Web Interface
End of  Deluge 1.3.6 installation
Start of Optional Section for deluge

If you are like me who have Plex Media Server installed then you might want to configure your deluge for plex. Plex looks into different folder to collect your media file. And you might want deluge to move you download files to relevant folders. While the process that I am going to talk about is not fully automatic it will make life easy.

First thing is to auto add torrent files in deluge. For this you need to install deluge plugin “AutoAdd”. Autoadd can look into different folder for torrent and can apply setting according to those folder.

Goto here to download Autoadd plugin. It’s a egg file.

Image 2.1 – Deluge 1.3.6 Web Interface

Ahh, the only problem with Autoadd plugin is that it has not yet got web ui to configure it. If you installing deluge in Debian then you can use GUI interface to configure, if you have not got GUI then (install lite weight desktop lxde + VNC :)), OR may be you can use terminal to configure Autoadd manually. * (Its possible to edit configure to setup Autoadd but I have never try this way – its purely experimental)

All the deluge configuration files are in /root/.config/deluge,

Editing autoadd.conf file.

nano /root/.config/deluge/autoadd.conf

“file”: 1,
“format”: 1
“watchdirs”: {
“1”: {
“max_download_speed”: 0.0,
“move_completed_path”: “/path/to/move/your/downloaded/files“,
“remove_at_ratio_toggle”: false,
“label_toggle”: false,
“max_upload_slots”: 0,
“download_location_toggle”: false,
“append_extension_toggle”: true,
“stop_at_ratio_toggle”: false,
“move_completed_toggle”: true,
“max_connections”: 0,
“max_upload_speed_toggle”: true,
“auto_managed_toggle”: true,
“max_connections_toggle”: false,
“download_location”: “/root”,
“label”: “downloading-give a label here “,
“max_upload_speed”: 80.0,
“max_download_speed_toggle”: false,
“stop_ratio_toggle”: false,
“auto_managed”: true,
“abspath”: “/path/to/download/folder/of/torrent/file“,
“add_paused_toggle”: false,
“stop_at_ratio”: false,
“move_completed”: true,
“path”: “/path/to/download/folder/of/torrent/file“,
“append_extension”: “.added”,
“add_paused”: true,
“queue_to_top_toggle”: false,
“queue_to_top”: true,
“enabled”: true,
“remove_at_ratio”: true,
“stop_ratio”: 0.0,
“max_upload_slots_toggle”: false
“next_id”: 3

In GUI, it look like this,

Image 3.1 – Autoadd option – GUI

[ Explained ]

/path/to/move/your/downloaded/files -> TV

“append_extension”: “.added”, -> Append extension after adding [.added]

“move_completed”: true,
“path”: “/path/to/download/folder/of/torrent/file”, -> Set move completed location [English]

“max_upload_speed”: 80.0, -> max upload speed [80.0]

Next thing we need to make sure its enable in plugin section. Go to Preferences>>Plugins>>check AutoAdd >> Apply>> Close

There are other useful plugin like label and blocklist. While label is similar to autoadd its usually use to label the torrent that you are downloading and can have extra option similar to autoadd. Fortunately label has web UI to configure.

Go to plugin section to enable it and you might need to restart the daemon too.

Lable - Deluge
Image 4.1 – Deluge 1.3.6 – Label

You can have lots of labels for different purpose 🙂 . For more information about deluge please check reference link at the button of this page.

Now in Plex

Image 5.1 – Plex Web Manager

Comment and suggest are always welcome.. 🙂

End of Optional Section for deluge

Openmediavault + Remote Access

OpenMediaVault (OMV) + Remote Access

Openmediavault (OMV) is a headless Debian based server. It has very functional and beautiful web interface for server management (see image 1.1). The web interface by default can only be accesses within local network but there is a work around to access this interface outside of local network too.

Image 1.1 – OpenMediaVault (OVM) Web Interface

As OVM default web interface runs in 80 port, the easiest way to access remotely is by opening TCP port 80 in your router. Only downside of this is you have to have static public ip. If you are in UK and have a virgin media as ISP then you are in luck as for some reason they have static ip. I found this true to BT too. I am not sure in other country. To find your public ip go to here. It says external ip in their website.

Now all you need to do is open TCP port 80 in your router. Please refer to your router manual as I can’t possible explain How To’s for every router out there. The basic principle is you need to portforward 80 to your local server IP.

NoticeNote: For security reason you can change OMV port 80 to something else like 8080 but before you change it check if that port is used by other service in your server or not.

Connect to your server by SSH client then run this command in terminal to check that

netstat -lnptu

After you have open the port in router, goto browser type (without square bracket, port number by default will be 80 but if you have change it then you have to put your port accordingly. like example, if have not change the port then just type

[http://Your Public ip]:[port number]

There are other option to access web interface too but its bit long. Like installing VPN service. If you want to go ahead with this service then follow these steps.

For VPN, try OpenVPN-as its really easy to setup. Only downside is, it allows only 2 users at a time for free license. For more user you need to buy license.

First download deb files, run these command,

For x86

OR For x64

Even if it say Ubuntu in its file name it will work in OMV.  Now we need to install deb file.

NoticeNote: If you have not got wget command then first run apt-get install wget.

For x86

dpkg -i openvpn-as-1.8.4-Ubuntu10.i386.deb

OR For x64

dpkg -i openvpn-as-1.8.4-Ubuntu10.amd_64.deb

For installation, it will create a user called openvpn. To access Openvpn web interface we need to use this username and password.

To create new password. Run

passwd openvpn

Then enter your new password for that account. Now to access Openvpn web interface you need your server ip and user name / password.

Now goto to your browser and type

[your server ip]:443/admin

It will get  you warning, its normal. just ignore it and enter username openvpn and your password.

Finally, you have to now open port in your router.

[Open port TCP 443 and UDP 1194]

On client computer, you need to download openvpn client application. When you try to access

[public ip:443]

It will ask you to download and install appropriate client setup file. Download and install it. And you can use that application to  access your server.

The advantage of Openvpn is that you can now not only have access to your OVM web interface but whole network.

For more information go here

End of OpenMediaVault (OMV) + Remote Access