Setup Seedbox on a dedicated server Rutorrent, Autodl-irssi, ZNC, Ubuntu

Written by R088

First connect to your new box as root using the login info provided by your provider:

Code:
ssh root@<serverip>

Use your preferred terminal emulator on a Mac or other unix based machine or Putty if you’re on Windows.

Create a non-root user account:

Code:
adduser <username>

Enter a password when prompted and answer the questions when prompted.

Add your user to the sudoers file

Code:
visudo

Add the following line

 

<username> ALL=(ALL:ALL) ALL

Exit saving changes by pressing Crtl+x then typing Y and pressing return.

Secure ssh logins:

Code:
nano /etc/ssh/sshd_config

Change the following lines:

 

Port <portnumber>
PermitRootLogin no
X11Forwarding no

Add the following:

 

UseDNS no
AllowUsers <username>

Exit saving changes like before.

Restart the ssh daemon:

Code:
service ssh restart

Disconnect and reconnect as the new user

Code:
exit
ssh -p <portnumber> <username>@<serverip>

Ensure system is fully up to date

Code:
sudo apt-get update
sudo apt-get dist-upgrade

Install apache & php plus dependencies:

Code:
sudo apt-get install apache2 apache2-utils autoconf build-essential ca-certificates comerr-dev curl cfv dtach htop irssi libapache2-mod-php5 libcloog-ppl-dev libcppunit-dev libcurl3 libncurses5-dev libterm-readline-gnu-perl libsigc++-2.0-dev libperl-dev libtool libxml2-dev ncurses-base ncurses-term ntp patch pkg-config php5 php5-cli php5-dev php5-fpm php5-curl php5-geoip php5-mcrypt php5-xmlrpc pkg-config python-scgi screen subversion texinfo unrar unzip zlib1g-dev

Install apache webserver modules:

Code:
sudo a2enmod auth_digest
sudo a2enmod reqtimeout

Configure Apache:

Code:
sudo nano /etc/apache2/apache2.conf

Edit the line:

 

Timeout 30

Then scroll to the end and add:

 

ServerSignature Off
ServerTokens Prod

Exit saving changes then restart apache:

Code:
sudo service apache2 restart

Edit the info.php file:

Code:
sudo nano /var/www/html/info.php

Add the line:

 

<?php phpinfo(); ?>

Exit saving changes.

Navigate to serverip/info.php to verify that both apache and php are working then delete the info.php file:

Code:
sudo rm /var/www/html/info.php

Enable ssl and restart apache:

Code:
sudo a2enmod ssl
sudo service apache2 restart

Create directory for certificates:

Code:
sudo mkdir /etc/apache2/ssl

Create the key and the certificate:

Code:
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt

The only answer that matters in the questions that follow is the common name which should be the server name or public ip of the server.

Open the default ssl site configuration file:

Code:
sudo nano /etc/apache2/sites-available/default-ssl.conf

Add the line:

 

ServerName <servername>

Edit the following:

 

SSLCertificateFile /etc/apache2/ssl/apache.crt
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

Below the line beginning ‘DocumentRoot add the following:

 

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

Below the ErrorLog line add:

 

LogLevel warn

Below the CustomLog line add:

 

<Location /rutorrent>
AuthType Digest
AuthName “rutorrent”
AuthDigestDomain /var/www/html/rutorrent/ http://<serverip>/rutorrent

AuthDigestProvider file
AuthUserFile /etc/apache2/htpasswd
Require valid-user
SetEnv R_ENV “/var/www/html/rutorrent”
</Location>

Exit saving changes, enable the new site and restart apache:

Code:
sudo a2ensite default-ssl.conf
sudo service apache2 restart

Check it’s worked by browsing to https://<servernameorip> and ignore the warning about the untrusted certificate.

Configure rutorrent login

Code:
sudo htdigest -c /etc/apache2/htpasswd rutorrent <username>

Enter password twice when prompted

Configure apache access:

Code:
sudo nano /etc/apache2/sites-available/000-default.conf

Below the line beginning ‘DocumentRoot add the following:

 

<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/html>
Options FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>

Below the ErrorLog line add:

 

LogLevel warn

Below the CustomLog line add:

 

<Location /rutorrent>
AuthType Digest
AuthName “rutorrent”
AuthDigestDomain /var/www/html/rutorrent/ http://<serverip>/rutorrent

AuthDigestProvider file
AuthUserFile /etc/apache2/htpasswd
Require valid-user
SetEnv R_ENV “/var/www/html/rutorrent”
</Location>

Exit saving changes then check it’s worked by browsing to http://<servernameorip>.

Create and move into the source directory:

Code:
mkdir ~/source
cd ~/source

Get libcurl and rtorrent packages (these are the latest versions as of now, you may want to change for the latest ones if installing in the future):

Configure and make the packages (each of these takes some time so go make a coffee or whatever):

Code:
cd curl-7.39.0/;./configure;make;sudo make install


cd ../xmlrpc;./configure --prefix=/usr --enable-libxml2-backend --disable-libwww-client --disable-wininet-client --disable-abyss-server --disable-cgi-server;make;sudo make install


cd ../libtorrent-0.13.4;./autogen.sh;./configure --prefix=/usr;make -j2;sudo make install


cd ../rtorrent-0.9.4;./autogen.sh;./configure --prefix=/usr --with-xmlrpc-c;make -j2;sudo make install;sudo ldconfig

Edit the rtorrent configuration file:

Code:
sudo nano ~/.rtorrent.rc

Paste the following and replace all instances of <username>:

 

## Downloads Settings
# maximum number of simultaneous uploads per torrent
# throttle.max_uploads.set = 30
max_uploads = 12

# maximum and minimum number of peers to connect to per torrent
# throttle.min_peers.normal.set = 40
# throttle.max_peers.normal.set = 100
min_peers = 40
max_peers = 144

# same as above but for seeding completed torrents (-1 = same as downloading)
# throttle.min_peers.seed.set = 25
# throttle.max_peers.seed.set = 60
min_peers_seed = -1
max_peers_seed = -1

# tracker_numwant = -1
trackers.numwant.set = -1

# check hash for finished torrents. might be useful until the bug is
# fixed that causes lack of diskspace not to be properly reported
# pieces.hash.on_completion.set = yes
check_hash = yes

# default directory to save the downloaded torrents
# directory.default.set = /home/<username>/downloads
directory = /home/<username>/downloads

# default session directory. make sure you don't run multiple instances
# of rtorrent using the same session directory
# perhaps using a relative path?
# session.path.set = /home/<username>/downloads/.session
session = /home/<username>/downloads/.session

# Connection Settings
#
# port range to use for listening
# network.port_range.set = 55950-56000
port_range = 55950-56000

# start opening ports at a random position within the port range
# network.port_random.set = yes
port_random = yes

# global upload and download rate in KiB. “0” for unlimited
# throttle.global_up.max_rate.set_kb = 0
# throttle.global_down.max_rate.set_kb = 0
upload_rate = 0
download_rate = 0

# max mapped memory
# nb does not refer to physical memory
# max_memory_usage = 3500M
pieces.memory.max.set = 15000M

# max number of files to keep open simultaneously
# max_open_files = 192
network.max_open_files.set = 192

# max_open_http = 32
network.http.max_open.set = 32

# BitTorrent Settings
#
# enable DHT support for trackerless torrents or when all trackers are down
# may be set to “disable” (completely disable DHT), “off” (do not start DHT),
# “auto” (start and stop DHT as needed), or “on” (start DHT immediately)
# the default is “off”. for DHT to work, a session directory must be defined
#
# dht.mode.set = disable
dht = disable

# UDP port to use for DHT.
#
# dht_port = 6881
# dht.port.set = 6881

# enable peer exchange (for torrents not marked private)
# protocol.pex.set = no
peer_exchange = no

# the IP address reported to the tracker
# network.local_address.set = rakshasa.no
# network.local_address.set = 127.0.0.1
# ip = rakshasa.no
# ip = 127.0.0.1

# schedule syntax: id,start,interval,command
# call cmd every interval seconds, starting from start. an interval of zero calls the task once
# while a start of zero calls it immediately. start and interval may optionally use a time format
# dd:hh:mm:ss e.g. to start a task every day at 18:00, use 18:00:00,24:00:00.
# commands: stop_untied =, close_untied =, remove_untied =
# stop, close or remove the torrents that are tied to filenames that have been deleted

# watch a directory for new torrents, and stop those that have been deleted
schedule = watch_directory,5,5,load_start=/home/<username>/downloads/watch/*.torrent
schedule = untied_directory,5,5,stop_untied=

# close torrents when diskspace is low. */
schedule = low_diskspace,5,60,close_low_diskspace=100M

# stop torrents when reaching upload ratio in percent,
# when also reaching total upload in bytes, or when
# reaching final upload ratio in percent
# example: stop at ratio 2.0 with at least 200 MB uploaded, or else ratio 20.0
# schedule = ratio,60,60,stop_on_ratio=200,200M,2000

# load = file, load_verbose = file, load_start = file, load_start_verbose = file
# load and possibly start a file, or possibly multiple files by using the wild-card “*”
# this is meant for use with schedule, though ensure that the start is non-zero
# the loaded file will be tied to the filename provided.

# when the torrent finishes, it executes “mv -n <base_path> ~/Download/”
# and then sets the destination directory to “~/Download/”. (0.7.7+)
# on_finished = move_complete,”execute=mv,-u,$d.get_base_path=,/home/<username>/downloads/complete/ ;d.set_directory=/home/<username>/downloads/complete/”

# network.scgi.open_port = 127.0.0.1:5000
scgi_port = 127.0.0.1:5000

# alternative calls to bind and IP that should handle dynamic IP's
# schedule = ip_tick,0,1800,ip=rakshasa
# schedule = bind_tick,0,1800,bind=rakshasa

# encryption options, set to none (default) or any combination of the following:
# allow_incoming, try_outgoing,require,require_RC4,enable_retry,pref er_plaintext
#
# the example value allows incoming encrypted connections, starts unencrypted
# outgoing connections but retries with encryption if they fail, preferring
# plaintext to RC4 encryption after the encrypted handshake
#
# protocol.encryption.set =
#encryption = require,require_RC4,allow_incoming,try_outgoing,en able_retry
#force encryption on all connections
encryption = allow_incoming,try_outgoing,enable_retry

# Advanced Settings
#
# do not modify the following parameters unless you know what you're doing
#

# example of scheduling commands: Switch between two ip's every 5 seconds
# schedule = “ip_tick1,5,10,ip=torretta”
# schedule = “ip_tick2,10,10,ip=lampedusa”

# remove a scheduled event
# schedule_remove = “ip_tick1”

# hash read-ahead controls how many MB to request the kernel to read ahead ahead
# if the value is too low the disk may not be fully utilized,
# while if too high the kernel might not be able to keep the read pages
# in memory thus end up trashing.
# hash_read_ahead = 8
# system.hash.read_ahead.set = 8

# interval between attempts to check the hash, in milliseconds
# hash_interval = 50
# system.hash.interval.set = 50

# number of attempts to check the hash while using the mincore status, before forcing
# overworked systems might need lower values to get a decent hash checking rate
# hash_max_tries = 3
# system.hash.max_tries.set = 3

# SSL certificate name
# http_cacert =
# SSL certificate path
# http_capath =

# throttle.max_downloads.div.set =
# max_downloads_div =

# throttle.max_uploads.div.set =
# max_uploads_div =

system.file.max_size.set = -1

# preload type 0 = Off, 1 = madvise, 2 = direct paging
pieces.preload.type.set = 1
pieces.preload.min_size.set = 262144
pieces.preload.min_rate.set = 5120
network.send_buffer.size.set = 1M
network.receive_buffer.size.set = 131072

pieces.sync.always_safe.set = no
pieces.sync.timeout.set = 600
pieces.sync.timeout_safe.set = 900

# scgi_dont_route =
# network.scgi.dont_route.set =

# session.path.set =
# session.name.set =
session.use_lock.set = yes
session.on_completion.set = yes

system.file.split_size.set = -1
system.file.split_suffix.set = .part

# set whether the client should try to connect to UDP trackers
# use_udp_trackers = yes
trackers.use_udp.set = yes

# use a http proxy. [url] ;an empty string disables this setting
# http_proxy =
# network.http.proxy_address.set =

# The IP address the listening socket and outgoing connections is bound to
# network.bind_address.set = rakshasa.no
# network.bind_address.set = 127.0.0.1
# bind = rakshasa.no
# bind = 127.0.0.1

# number of sockets to simultaneously keep open
# max_open_sockets = 65023
# network.max_open_sockets.set = 65023

# set the umask applied to all files created by rtorrent
system.umask.set = 022

# alternate keyboard mappings
# qwerty | azerty | qwertz | dvorak
# key_layout = dvorak
# keys.layout.set = dvorak

Exit and save changes then create the directories, setting yourself as owner:

Code:
sudo mkdir ~/downloads
sudo mkdir ~/downloads/watch
sudo mkdir ~/downloads/.session
sudo chown -R <username>:users ~/downloads

Check rtorrent starts and then quit it again:

Code:
rtorrent
ctl q

Start rtorrent at boot:

Code:
sudo nano /etc/init.d/rtorrent

Paste in the following:

 

#!/bin/bash
### BEGIN INIT INFO
# Provides: rtorrent
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop rtorrent daemon
### END INIT INFO

# /etc/init.d/rtorrent
#
# This script is an init script to run rtorrent in the background, using a screen
# Copy the script to “/etc/init.d/rtorrent”
# Make it executable by issuing “chmod +x /etc/init.d/rtorrent”
# Activate it with “sudo update-rc.d rtorrent defaults 99″ and reboot to start

## Username to run rtorrent under, make sure you have a .rtorrent.rc in the home directory of this user!
USER=”<username>

## Absolute path to the rtorrent binary.
RTORRENT=”/usr/bin/rtorrent”

## Absolute path to the screen binary.
SCREEN=”/usr/bin/screen”

## Name of the screen session, you can then “screen -r rtorrent” to get it back to the foreground and work with it on your shell.
SCREEN_NAME=”rtorrent”

## Absolute path to rtorrent's PID file.
PIDFILE=”/var/run/rtorrent.pid”

## Absolute path to rtorrent's XMLRPC socket.
SOCKET=”/var/run/rtorrent/rpc.socket”

## Check if the socket exists and if it exists delete it.
delete_socket() {
if [[ -e $SOCKET ]]; then
rm -f $SOCKET
fi
}

case “$1” in
## Start rtorrent in the background.
start)
echo “Starting rtorrent.”
delete_socket
start-stop-daemon –start –background –oknodo \
–pidfile “$PIDFILE” –make-pidfile \
–chuid $USER \
–exec $SCREEN — -DmUS $SCREEN_NAME $RTORRENT
if [[ $? -ne 0 ]]; then
echo “Error: rtorrent failed to start.”
exit 1
fi
echo “rtorrent started successfully.”
;;

## Stop rtorrent.
stop)
echo “Stopping rtorrent.”
start-stop-daemon –stop –oknodo –pidfile “$PIDFILE”
if [[ $? -ne 0 ]]; then
echo “Error: failed to stop rtorrent process.”
exit 1
fi
delete_socket
echo “rtorrent stopped successfully.”
;;

## Restart rtorrent.
restart)
“$0” stop
sleep 1
“$0” start || exit 1
;;

## Print usage information if the user gives an invalid option.
*)
echo “Usage: $0 [start|stop|restart]”
exit 1
;;

esac

Just by the by, I ran into some issues re-creating this while writing this tutorial, it turns out I had the wrong kind of ” marks around my string variables in the script, I can only assume this is down to copy/pasting from TextEdit on my Mac where I made notes. If rtorrent doesn't start at reboot then ensure your ” marks are the straight vertical line type ones and not the opposite direction curvy ones.

Exit saving changes then make the script executable and activate it:

Code:
sudo chmod +x /etc/init.d/rtorrent
sudo update-rc.d rtorrent defaults 99

Reboot to start rtorrent in a detached screen session:

Code:
sudo reboot

Reconnect and check if it's started:

Code:
ps -aux | grep rtorrent

You should get 3 lines of output that look a little like this:

Code:
<username>    4166  0.0  0.0  24204  1576 ?        Ss   18:16   0:00 /usr/bin/SCREEN -DmUS rtorrent /usr/bin/rtorrent
<username>    4187  0.1  0.2 197280  5988 pts/5    Ssl+ 18:16   0:00 /usr/bin/rtorrent
<username>    8095  0.0  0.0  12224   916 pts/1    S+   18:22   0:00 grep --color=auto rtorrent

Checkout the latest rutorrent & plugins:

Code:
cd /var/www/html/
sudo wget https://bintray.com/artifact/download/novik65/generic/rutorrent-3.6.tar.gz
sudo tar xzvf rutorrent-3.6.tar.gz
sudo rm -r rutorrent/plugins/
sudo wget https://bintray.com/artifact/download/novik65/generic/plugins-3.6.tar.gz
sudo tar xzvf plugins-3.6.tar.gz
sudo mv plugins rutorrent
sudo rm plugins-3.6.tar.gz rutorrent-3.6.tar.gz

Transfer ownership of rutorrent files to web server:

Code:
sudo chown -R www-data:www-data rutorrent
sudo chmod -R 755 rutorrent

Remove existing rutorrent configuration file and create a new blank one:

Code:
sudo rm rutorrent/conf/config.php
sudo nano rutorrent/conf/config.php

Paste in the following:

 

<?php
// configuration parameters

// for snoopy client
@define(‘HTTP_USER_AGENT', ‘Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9) Gecko/2008052906 Firefox/3.0', true);
@define(‘HTTP_TIME_OUT', 30, true); // in seconds
@define(‘HTTP_USE_GZIP', true, true);
$httpIP = null; // IP string. Or null for any.

@define(‘RPC_TIME_OUT', 5, true); // in seconds

@define(‘LOG_RPC_CALLS', false, true);
@define(‘LOG_RPC_FAULTS', true, true);

// for php
@define(‘PHP_USE_GZIP', false, true);
@define(‘PHP_GZIP_LEVEL', 2, true);

$do_diagnostic = true;
$log_file = ‘/tmp/rutorrent_errors.log'; // path to log file (comment or leave blank to disable logging)

$saveUploadedTorrents = true; // Save uploaded torrents to profile/torrents directory or not
$overwriteUploadedTorrents = false; // Overwrite existing uploaded torrents in profile/torrents directory or make unique name

$topDirectory = ‘/home'; // Upper available directory. Absolute path with trail slash.
$forbidUserSettings = false;

$scgi_port = 5000;
$scgi_host = “127.0.0.1”;

// For web->rtorrent link through unix domain socket
// (scgi_local in rtorrent conf file), change variables
// above to something like this:
//
//$scgi_port = 0;
//$scgi_host = “unix:///tmp/rtorrent.sock”;

$XMLRPCMountPoint = “/RPC2”; // DO NOT DELETE THIS LINE!!! DO NOT COMMENT THIS LINE!!!

$pathToExternals = array(
“php” => ‘/usr/bin/php', // Something like /usr/bin/php. If empty, will be found in PATH.
“curl” => ‘/usr/bin/curl', // Something like /usr/bin/curl. If empty, will be found in PATH.
“gzip” => ‘/bin/gzip', // Something like /usr/bin/gzip. If empty, will be found in PATH.
“id” => ‘/usr/bin/id', // Something like /usr/bin/id. If empty, will be found in PATH.
“stat” => ‘/usr/bin/stat', // Something like /usr/bin/stat. If empty, will be found in PATH.
);

$localhosts = array( // list of local interfaces
“127.0.0.1”,
“localhost”,
);

$profilePath = ‘../share'; // Path to user profiles
$profileMask = 0777; // Mask for files and directory creation in user profiles.
// Both Webserver and rtorrent users must have read-write access to it.
// For example, if Webserver and rtorrent users are in the same group then the value may be 0770.

?>

Exit saving changes then create and edit the plugins configuration file:

Code:
cd rutorrent/plugins/
sudo mkdir conf
sudo nano conf/plugins.ini

Paste in the following:

 

;; Plugins' permissions.
;; If flag is not found in plugin section, corresponding flag from “default” section is used.
;; If flag is not found in “default” section, it is assumed to be “yes”.
;;
;; For setting individual plugin permissions you must write something like that:
;;
;; [ratio]
;; enabled = yes ;; also may be “user-defined”, in this case user can control plugin's state from UI
;; canChangeToolbar = yes
;; canChangeMenu = yes
;; canChangeOptions = no
;; canChangeTabs = yes
;; canChangeColumns = yes
;; canChangeStatusBar = yes
;; canChangeCategory = yes
;; canBeShutdowned = yes

[default]
enabled = user-defined
canChangeToolbar = yes
canChangeMenu = yes
canChangeOptions = yes
canChangeTabs = yes
canChangeColumns = yes
canChangeStatusBar = yes
canChangeCategory = yes
canBeShutdowned = yes

;; Default

[_getdir]
enabled = yes
[cpuload]
enabled = user-defined
[create]
enabled = user-defined
[datadir]
enabled = yes
[diskspace]
enabled = user-defined
[erasedata]
enabled = user-defined
[show_peers_like_wtorrent]
enabled = user-defined
[theme]
enabled = yes
[tracklabels]
enabled = user-defined
[trafic]
enabled = user-defined

;; Enabled

[autotools]
enabled = user-defined
[cookies]
enabled = user-defined
[data]
enabled = user-defined
[edit]
enabled = user-defined
[extratio]
enabled = user-defined
[extsearch]
enabled = user-defined
[filedrop]
enabled = user-defined
[filemanager]
enabled = user-defined
[geoip]
enabled = user-defined
[httprpc]
enabled = yes
canBeShutdowned = no
[pausewebui]
enabled = yes
[ratio]
enabled = user-defined
[ratiocolor]
enabled = user-defined
[rss]
enabled = user-defined
[_task]
enabled = yes
[throttle]
enabled = user-defined
[titlebar]
enabled = user-defined
[unpack]
enabled = user-defined

;; Disabled

[chat]
enabled = no
[chunks]
enabled = no
[feeds]
enabled = no
[fileshare]
enabled = no
[fileupload]
enabled = no
[history]
enabled = no
[instantsearch]
enabled = no
[ipad]
enabled = no
[logoff]
enabled = no
[loginmgr]
enabled = no
[mediainfo]
enabled = yes
[mediastream]
enabled = yes
[check_port]
enabled = no
[retrackers]
enabled = no
[rpc]
enabled = no
[rssurlrewrite]
enabled = no
[rutracker_check]
enabled = no
[scheduler]
enabled = no
[screenshots]
enabled = yes
[seedingtime]
enabled = yes
[source]
enabled = no

Exit saving changes.

Install mediainfo:

Code:
sudo apt-get install mediainfo

Add necessary repository and install ffmpeg for screenshots:

Code:
sudo add-apt-repository ppa:jon-severinsson/ffmpeg
sudo apt-get update
sudo apt-get install ffmpeg

Navigate to https://<servernameorip>/rutorrent to check it’s worked.

Install required perl modules for autodl-irssi:

Code:
sudo apt-get -y install libarchive-zip-perl libnet-ssleay-perl libhtml-parser-perl libxml-libxml-perl libjson-perl libjson-xs-perl libxml-libxslt-perl libjson-rpc-perl

Install autodl-irssi-community:

Code:
mkdir -p ~/.irssi/scripts/autorun
cd ~/.irssi/scripts
wget -O autodl-irssi.zip http://update.autodl-community.com/autodl-irssi-community.zip
unzip -o autodl-irssi.zip
rm autodl-irssi.zip
cp autodl-irssi.pl autorun/
mkdir -p ~/.autodl
touch ~/.autodl/autodl.cfg

Edit the php configuration file:

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

Add the following lines:

 

extension=sockets.so
extension=json.so
extension=xml.so

Exit saving changes and restart apache:

Code:
sudo service apache2 restart

Navigate to the rutorrent plugins directory:

Code:
cd /var/www/html/rutorrent/plugins/

Install git:

Code:
sudo apt-get install git

Clone and install autodl-rutorrent:

Code:
sudo git clone https://github.com/autodl-community/autodl-rutorrent.git autodl-irssi
sudo cp autodl-irssi/_conf.php autodl-irssi/conf.php

Transfer ownership of autdl-irssi to the web server:

Code:
sudo chown -R www-data:www-data autodl-irssi

Edit the autodl-rutorrent configuration file and set the port and password fields to whatever you want:

Code:
sudo nano autodl-irssi/conf.php

Exit saving changes and edit the autodl configuration file:

Code:
cd ~/.autodl
sudo nano autodl.cfg

Paste in the following:

 

[options]
gui-server-port = <sameport>
gui-server-password = <samepassword>

Ensure you enter the same port and password as you just put in conf.php and exit saving changes.

Start irssi manually the first time:

Code:
screen -d -m irssi

Set it to start at boot in the future:

Code:
sudo nano /etc/init.d/irssi

Paste in the following:

 

#!/bin/bash
### BEGIN INIT INFO
# Provides: irssi
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start/stop irssi daemon
### END INIT INFO

## Username to run irssi under
USER=”<username>

## Absolute path to the rtorrent binary.
IRSSI=”/usr/bin/irssi”

## Absolute path to the screen binary.
SCREEN=”/usr/bin/screen”

## Name of the screen session, you can then “screen -r irssi” to get it back
## to the forground and work with it on your shell.
SCREEN_NAME=”irssi”

## Absolute path to irssi's PID file.
PIDFILE=”/var/run/irssi.pid”

case “$1” in
## Start irssi in the background.
start)
echo “Starting irssi.”
start-stop-daemon –start –background –oknodo \
–pidfile “$PIDFILE” –make-pidfile \
–chuid $USER \
–exec $SCREEN — -DmUS $SCREEN_NAME $IRSSI
if [[ $? -ne 0 ]]; then
echo “Error: irssi failed to start.”
exit 1
fi
echo “irssi started successfully.”
;;

## Stop irssi.
stop)
echo “Stopping irssi.”
start-stop-daemon –stop –oknodo –pidfile “$PIDFILE”
if [[ $? -ne 0 ]]; then
echo “Error: failed to stop irssi process.”
exit 1
fi
delete_socket
echo “irssi stopped successfully.”
;;

## Restart irssi.
restart)
“$0” stop
sleep 1
“$0” start || exit 1
;;

## Print usage information if the user gives an invalid option.
*)
echo “Usage: $0 [start|stop|restart]”
exit 1
;;

esac

Exit saving changes and make it executable, then activate it:

Code:
sudo chmod +x /etc/init.d/irssi
sudo update-rc.d irssi defaults 99

Reboot to start irssi in a detached screen session:

Code:
sudo reboot

Check it's started:

Code:
ps -aux | grep irssi

You should get 3 lines of output that look like this:

Code:
<username>    4114  0.0  0.0  24204  1580 ?        Ss   18:49   0:00 /usr/bin/SCREEN -DmUS irssi /usr/bin/irssi
<username>    4135  4.5  1.5 130888 31300 pts/1    Ss+  18:49   0:01 /usr/bin/irssi
<username>    4299  0.0  0.0  12224   912 pts/0    S+   18:49   0:00 grep --color=auto irssi

If it doesn't start then look into the ” mark issue I outlined after the init.d script for rtorrent.

Time for the read-only sftp users, first add the group:

Code:
sudo groupadd sftp

Add user with their home directory as /home/<username> (even though /home/<username> doesn't exist yet):

Code:
sudo useradd -d /home/<username>/ <username>

Repeat for additional users as necessary.

Adjust the password for the new user(s):

Code:
sudo passwd <username>

Modify the new user(s) groups to be sftp:

Code:
sudo usermod -g sftp <username>

Block SSH access from the new user(s):

Code:
sudo usermod -s /bin/false <username>

Make the user(s) home directory and have root own it:

Code:
cd /home
sudo mkdir <username>
sudo chown root:root <username>

Create a pseudo-downloads folder:

Code:
cd <username>
sudo mkdir <username>_downloads

Edit the ssh configuration file:

Code:
sudo nano /etc/ssh/sshd_config

Comment out the line:

 

Subsystem sftp /usr/lib/openssh/sftp-server

It should now look like:

 

#Subsystem sftp /usr/lib/openssh/sftp-server

Add the new users alongside the one you created earlier and are logged in as on the AllowUsers line:

 

AllowUsers <existing-username> <sftp-only-username(s)>

Add the following lines below AllowUsers:

 

Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
X11Forwarding no
AllowTCPForwarding no

Exit saving changes and restart the ssh service:

Code:
sudo service ssh restart

Edit the fstab:

Code:
sudo nano /etc/fstab

Add the following line once for each sftp user:

 

/home/<existing-username>/ /home/<sftpuser>/<sftpuser>_downloads auto bind,gid=46,defaults 0 0

Exit saving changes.

Finally, go back to your own home directory and install the latest version of Plex Media Server (find this by going to the download page, choosing either plex pass or public downloads [depending if you have a plex pass of course], clicking Computer under Plex Media Server, choosing Linux, right clicking on the right Ubuntu version for your architecture and choosing copy link address [or whatever your browser's equivalent is] ready to paste in after wget-c in the next step):

Code:
cd ~/
wget -c http://downloads.plexapp.com/plex-media-server/0.9.9.12.504-3e7f93c/plexmediaserver_0.9.9.12.504-3e7f93c_amd64.deb
sudo dpkg -i plexmediaserver_0.9.9.12.504-3e7f93c_amd64.deb

Ignore the error message, install missing dependencies and remove the deb file:

Code:
sudo apt-get install -f
rm plexmediaserver_0.9.9.12.504-3e7f93c_amd64.deb

Initial configuration must be done from the localhost so you have to exit your existing SSH session and create an SSH tunnel to fool the server into thinking you're sitting in front of it:

Code:
exit
ssh -L 32400:localhost:32400 <serverip> -l <username> -p <sshport>

Open your browser to 127.0.0.1:32400/web and sign in to MyPlex in the ‘Connect’ section of the ‘Server’ page then close the SSH tunnel:

Code:
exit

Navigate to <serverip>:32400/web and connect your server on the same page you were just in.

Reconnect to a normal SSH session then install the desktop environment and vnc server

Code:
sudo apt-get install xubuntu-desktop xfce4 vnc4server

That'll take a while so go make coffee or whatever.

Start the server manually to create some files

Code:
vncserver

Enter a password of your choosing twice when requested.

Kill the server and empty then edit the xstartup file

Code:
vncserver -kill :1
> ~/.vnc/xstartup
nano ~/.vnc/xstartup

Paste in the following:

 

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &

Exit saving changes then create the startup script

Code:
sudo nano /etc/init.d/vncserver

Paste in the following:

 

#!/bin/bash
### BEGIN INIT INFO
# Provides: tightvncserver
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: vnc server
### END INIT INFO

unset VNCSERVERARGS
VNCSERVERS=””
[ -f /etc/vncserver/vncservers.conf ] && . /etc/vncserver/vncservers.conf
prog=$”VNC server”
start() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $”Starting $prog: “
ulimit -S -c 0 >/dev/null 2>&1
RETVAL=0
for display in ${VNCSERVERS}
do
export USER=”${display##*:}”
if test -z “${REQ_USER}” -o “${REQ_USER}” == ${USER} ; then
echo -n “${display} “
unset BASH_ENV ENV
DISP=”${display%%:*}”
export VNCUSERARGS=”${VNCSERVERARGS[${DISP}]}”
su ${USER} -c “cd ~${USER} && [ -f .vnc/passwd ] && vncserver :${DISP} ${VNCUSERARGS}”
fi
done
}
stop() {
. /lib/lsb/init-functions
REQ_USER=$2
echo -n $”Shutting down VNCServer: “
for display in ${VNCSERVERS}
do
export USER=”${display##*:}”
if test -z “${REQ_USER}” -o “${REQ_USER}” == ${USER} ; then
echo -n “${display} “
unset BASH_ENV ENV
export USER=”${display##*:}”
su ${USER} -c “vncserver -kill :${display%%:*}” >/dev/null 2>&1
fi
done
echo -e “\n”
echo “VNCServer Stopped”
}
case “$1” in
start)
start $@
;;
stop)
stop $@
;;
restart|reload)
stop $@
sleep 3
start $@
;;
condrestart)
if [ -f /var/lock/subsys/vncserver ]; then
stop $@
sleep 3
start $@
fi
;;
status)
status Xvnc
;;
*)
echo $”Usage: $0 {start|stop|restart|condrestart|status}”
exit 1
esac

Exit saving changes then make it executable

Code:
sudo chmod +x /etc/init.d/vncserver

Create the server configuration file

Code:
sudo mkdir -p /etc/vncserver
sudo nano /etc/vncserver/vncservers.conf

Paste in the following, providing your username and setting the resolution to whatever you want:

 

VNCSERVERS=”1:<username>
VNCSERVERARGS[1]=”-geometry 1280×720″

Make it start at boot

Code:
sudo update-rc.d vncserver defaults 99

Reboot server and hope for the best!

Code:
sudo reboot
0/5 (0 Reviews)

Promoting Torrent privacy since 2012

Company