PDA

View Full Version : [HowTo]Aria2 Torrent, FTP, HTTP downloader with Webinterface



newbiefan
01-01-2012, 21:22
This howto describes howto install an excellent Linux-downloader with Torrent, FTP and HTTP capabilities and worldwide remote access.
Sometimes I missed a good downloadmanager for my router. Therefore I installed many different tools & apps in order to download different files. All of them worked fine, but they all have too much restrictions.
Then I found ARIA2 in our optware repository and some php-code called aria2web for a remote control of aria2.
There is some other code for a remote control out there, but far too complicated and too slow for a RT-N16.
A big advantage of aria2 is the very low needed cpu-resource and memory used for downloads. And it's ultrafast....
Disadvantages: You need Firefox on your Computer, with IE you have to tweak the php-code.
For IE, there are some suggestions for instance here: http://forum.synology.com/enu/viewtopic.php?f=38&t=26662

Tested with Webbrowser: Firefox, Iceweasel, Epiphany, Opera

Let's start........
Preconditions: RT-N16 or better (will run on a Wl500gP too, but slow)
Installation according Wengi's HowTo (http://wl500g.info/showthread.php?t=10307)
Installed and running lighttpd and PHP according WPTE's HowTo (http://wl500g.info/showthread.php?t=20306)
installed unzip on your router (or do a 'ipkg install unzip')
WinSCP

Aria2 is very easy to install, just adjust the line below with your download-folder as you like:

ipkg update
ipkg install aria2
mkdir -p /opt/var/log/aria2
mkdir -p /opt/etc/aria2
mkdir -p /tmp/mnt/disca_3/Downloads
touch /opt/etc/aria2/aria2.conf

vi /opt/etc/aria2/aria2.conf ###SWITCH TO INSERT MODE WITH 'i' ######
daemon=true
enable-rpc=true
rpc-listen-port=6800
rpc-listen-all=true
####### your download folder, ensure that this folder exist! ##########
dir=/tmp/mnt/disca_3/Downloads
#where is your logfile located
log=/opt/var/log/aria2/aria2.log
log-level=warn
dht-listen-port=6801
auto-save-interval=30
#seed ratio and seed time in minutes
seed-ratio=1.0
seed-time=1460
max-upload-limit=20K
event-poll=select
####end of file aria2.conf####
### Enter 'ESC' and ':wq' to store and leave vi ###


Consider, there are so many options - you can use much more when needed.
Here you can read more: http://linux.die.net/man/1/aria2c
And here you can find a Wiki: http://sourceforge.net/apps/trac/aria2/wiki

Now we start aria2 at every startup

touch /opt/etc/init.d/S85aria2
vi /opt/etc/init.d/S85aria2
###SWITCH TO INSERT MODE WITH 'i' ######
# For Olegs & Ily's FW for Asus Routers
# store this script in /opt/etc/init.d if you've installed optware

# Prgmname=/full_path/Prgmname
prgmname1="/opt/bin/aria2c"
shortname="aria2c"

#one option
options="--conf-path="

# configfile=/full_path/configfile
configfile="/opt/etc/aria2/aria2.conf"

start() {
# Code here to start the program
logger -t ARIA2C "Starting aria2c daemon "
${prgmname1} ${options}${configfile}
sleep 5
return 0
}

stop() {
# Code here to stop the program and check it's dead
if [ -n "`pidof $shortname`" ]; then
logger -t ARIA2C "Shutting down aria2c daemon "
/usr/bin/killall $shortname
sleep 5
fi
return 0
}
##########################start here##########################
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
logger -t ARIA2C "$shortname restart, executed from $(whoami)"
stop
sleep 2
start
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
sleep 1
exit
#### end of file S85aria2 ####
### Enter 'ESC' and ':wq' to store and leave vi ###

chmod 755 /opt/etc/init.d/S85aria2
reboot


Well, if there is no command 'whoami' on your router, just remove the part above 'executed from $(whoami)'
Consider, when you change something of your /opt/etc/aria2/aria2.conf file you must enter a:

/opt/etc/init.d/S85aria2 restart

If you don't want to install a webinterface for some reason, you can install a remote gui for aria on your PC.
For instance: with a Wl500gP you can save resources - no lighttpd, no php aso is necessary to run aria2.
Just move ahead with the next post. Consider, you can install a webinterface and a remote_gui, provided you do not access aria2 at the same time.
Further, you have to configure your firewall as stated below. When an older FW is used with Kernel 2.4, use as Path /tmp/mntdisc0_3 instead of disca_3

Now we install the webinterface-part: (assumed, that your webservers document root is /opt/share/www)

wget http://sourceforge.net/projects/aria2web/files/latest/download
mkdir -p /opt/share/www/aria2web
unzip Aria2Web_0.1.zip -d /opt/share/www/aria2web
rm /opt/share/www/aria2web/config.php
touch /opt/share/www/aria2web/config.php
vi /opt/share/www/aria2web/config.php ###SWITCH TO INSERT MODE WITH 'i' ######
<?php
/**
* @version $Id: config.php 8 2010-01-21 16:05:04Z soeren_nb $
* @package aria2web
* @copyright Copyright (C) 2010 soeren. All rights reserved.
* @license GNU/GPL, see LICENSE.php
* Aria2Web is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* http://sourceforge.net/projects/aria2web/
*/
defined( '_ARIA2WEB' ) or die();
// to run Aria2web in "local" mode means it's installed on the same machine as aria2, so we can start the aria2c executable through PHP
// when Aria2web is run in "web" mode, it's assumed that it's installed on a different machine and won't (be able to) start the aria2c executable
$aria2_mode = 'web';
$aria2_xmlrpc_host = 'localhost';
$aria2_xmlrpc_uripath = '/rpc';

$aria2_executable = '/opt/bin/aria2c'; // Location of the aria2c executable
$aria2_parameters = array();

// If aria2web is in local mode, it will try to start aria2c in XMl-RPC mode using the following additional parameters
$aria2_parameters['xml_rpc_listen_port'] = 6800;
$aria2_parameters['xml_rpc_username'] = '';
$aria2_parameters['xml_rpc_password'] = '';
$aria2_parameters['xml_rpc_listen_all'] = 'true';
$aria2_parameters['dir'] = '/tmp/mnt/disca_3/Downloads'; // The directory to store the downloaded file.
$aria2_parameters['log'] = '/opt/var/log/aria2/aria2.log'; // The location of the log file.
$aria2_parameters['http_user']= ''; //Set HTTP user. This affects all URLs.
$aria2_parameters['http_passwd']= '';//Set HTTP password. This affects all URLs.
$aria2_parameters['load_cookies']= ''; //Load Cookies from FILE using the Firefox3 format (SQLite3) and the Mozilla/Firefox(1.x/2.x)/Netscape format.
$aria2_parameters['user_agent']= ''; //Set user agent for HTTP(S) downloads. Default: aria2/$VERSION, $VERSION is replaced by package version.

?>

Enter 'ESC' and ':wq' to store and leave vi

Well, that's it - start your Firefox-browser and enter: http://ip.of.your.asus/aria2web
When you can see your aria2web-interface, you can configure your firewall
Now the firewall: (open the ports below)
The port numbers that aria2 uses by default are 6881-6999 and 6801 (dht) for TCP and UDP
(and port 6800 for xml_rpc for external Remote Control - when needed you should read/set a rtc-user&passwd)

Now the last step - we have to protect directory 'aria2web' of your webservers document root.

touch /opt/etc/htpassw

vi /opt/etc/htpassw ###SWITCH TO INSERT MODE WITH 'i' ######
myusername:mypassword

Enter 'ESC' and ':wq' to store and leave vi

Now only one thing remains, we have to tell lighhtpd to use a password for your aria2web directory.


vi /opt/etc/lighttpd/lighttpd.conf
and activate the "mod_auth" by removing the comment sign '#'
Further, at the end of the lighttpd.conf you have to insert this:

##################################authentification for directories####################################
auth.debug = 2
auth.backend = "plain"
auth.backend.plain.userfile = "/opt/etc/htpassw"
auth.require = (
"/aria2web/" => ("method" => "basic", "realm" => "Password protected area of aria2", "require" => "user=myusername")
)
################################################## ################################################## #####

# Configuration from other optware packages
include_shell "cat /opt/etc/lighttpd/conf.d/*.conf"
Enter 'ESC' and ':wq' to store and leave vi
Restart your webserver:

/opt/etc/init.d/S80lighttpd restart

References:
http://aria2.sourceforge.net/README.html
http://aria2.sourceforge.net/aria2c.1.html
http://sourceforge.net/apps/trac/aria2/wiki/UsageExample
https://github.com/tomhennigan/arial
http://martin-achern.de/wgetgui/aria2gui.html

Well, thats all so far - enjoy!!
Below you can find a screenshot.....
Any kind of improvements, suggestions aso. are greatly appreciated.
Newbiefan

newbiefan
01-01-2012, 23:59
Download from here: http://sourceforge.net/projects/aria2cremote/files/unstable/0.1.0/Aria2cRemoteControl-0.1.0b1-win32.exe/download

Install it and enter your hostname, port, user and password in menu 'tools' and 'option'

If necessary set a rpc-user and password in your aria2.conf file, just for security reasons.

Below you can find a screenshot.

Newbiefan

!gm
02-01-2012, 02:21
wow

thanks for that!

I'll give it a try

sass
02-01-2012, 18:55
when I enter

/opt/etc/init.d/S85aria2 restart
I get the following error:

-sh: /opt/etc/init.d/S85aria2: Permission denied

what am I doing wrong?

newbiefan
02-01-2012, 19:05
when I enter

/opt/etc/init.d/S85aria2 restart
I get the following error:

-sh: /opt/etc/init.d/S85aria2: Permission denied

what am I doing wrong?

Well, nothing is wrong. I guess you've forgotten to issue a

chmod 755 /opt/etc/init.d/S85aria2

(Look at the end of the part with vi /opt/etc/init.d/S85aria2)
In case you are not root or admin, set S85aria2 to 777

Have fun
Newbiefan

msj33
10-01-2012, 18:53
looks nice

Will it on an older wl500g deluxe?

Any torrent RSS feed support with filtering?

newbiefan
10-01-2012, 22:07
looks nice

Will it on an older wl500g deluxe?

Any torrent RSS feed support with filtering?

1.) Well, I do not own a wl500g deluxe, but I would say yes, it should work as long as you use just aria2c and win32-remote-control software. Do not install any extra webserver. Further use the aria2.conf below. In case you run into troubles, decrease the var max-concurrent-downloads to 3 (default is 5).
When you still run out of memory decrease a bit vars bt-max-peers and bt-max-open-files. I strongly suggest to read the manual of aria2.
Further do a:

mkdir -p /opt/var/run/aria2c
touch /opt/var/run/aria2c/aria2c

Consider, all vars with limits are valid for a approx. 2Mbit line (Inet-Connection). Your aria2.conf file

daemon=true
enable-rpc=true
rpc-listen-port=6800
rpc-listen-all=true
rpc-user=myuser
rpc-passwd=mypassword
dir=/tmp/mnt/disc0_3/Downloads
log=/opt/var/log/aria2/aria2.log
log-level=warn
enable-dht=true
dht-listen-port=6801
dht-file-path=/opt/var/run/aria2c/aria2c
auto-save-interval=30
max-concurrent-downloads=3
lowest-speed-limit=1K
max-overall-upload-limit=10K
max-upload-limit=5K
max-overall-download-limit=150K
max-download-limit=40K
bt-max-peers=25
bt-max-open-files=50
bt-request-peer-speed-limit=1K
seed-ratio=1.0
seed-time=1460
event-poll=select

2.)To my best knowledge aria2c is not able to handle a torrent RSS feed support with filtering. But I've to tell you that I do not know it exactly, because I do not use it. So you have to google for it.....:p - sorry.

FYI: it runs on a wl500gp without any problem, using aria2.conf above without aria2web.

Edit: I forgot to say that disca_3 (kernel 2.6.x) means disc0_3 with kernel 2.4.x

Have fun

aegisrtcw
08-04-2012, 14:24
Aria.conf


daemon=true
enable-rpc=true
rpc-listen-port=6800
rpc-listen-all=true
rpc-user=myuser
rpc-passwd=mypassword
dir=/tmp/mnt/disc0_3/Downloads
log=/opt/var/log/aria2/aria2.log
log-level=warn
enable-dht=true
dht-listen-port=6801
dht-file-path=/opt/var/run/aria2c/aria2c
auto-save-interval=30
max-concurrent-downloads=3
lowest-speed-limit=1K
max-overall-upload-limit=10K
max-upload-limit=5K
max-overall-download-limit=150K
max-download-limit=40K
bt-max-peers=25
bt-max-open-files=50
bt-request-peer-speed-limit=1K
seed-ratio=1.0
seed-time=1460
event-poll=select

And use cmd "/opt/etc/init.d/S85aria2 start or restart"


SD2012-04-08 15:30:12.135285 ERROR - [HttpListenCommand.cc:115]IPv6 RPC: failed to bind port 6800
Exception: [SocketCore.cc:305] errorCode=1 Failed to bind a socket, cause: Protocol not available
2012-04-08 15:30:12.222821 WARN - [MultiUrlRequestInfo.cc:231]Don't change system time while aria2c is running. Doing this may make aria2c hang for long time.

Thank you for your help

newbiefan
08-04-2012, 16:03
SD2012-04-08 15:30:12.135285 ERROR - [HttpListenCommand.cc:115]IPv6 RPC: failed to bind port 6800
Exception: [SocketCore.cc:305] errorCode=1 Failed to bind a socket, cause: Protocol not available
2012-04-08 15:30:12.222821 WARN - [MultiUrlRequestInfo.cc:231]Don't change system time while aria2c is running. Doing this may make aria2c hang for long time.


Well, I do not know exactly which kind of problem you have, so I just guess.

Write to aria2.conf your IPv6 address:

dht-listen-addr6=ADDR
Specify address to bind socket for IPv6 DHT. It should be a global unicast IPv6 address of the host.
( Taken from: http://aria2.sourceforge.net/aria2c.1.html )
The last line is just a warning.

HTH
Newbiefan