Page 1 of 1

QNAP – How to install Aria2 as a better download manager

QNAP – How to install Aria2 as a better download manager
   13

For those using a QNAP and that have looked a little further than just storing files on it, both pyLoad and Download Station should sound familiar. And they work … most of the time. Since it’s “most of the time”, I started looking for an alternative and found one in Aria2, which so far it has proven to be rock solid and faster!

Now Aria2 is actually just a command line utility which supports HTTP/HTTPS, FTP, SFTP, BitTorrent and Metalink. There is no webinterface, so we will add WebUI-Aria2 as the webinterface. Both are free, but strangely enough nobody made a “one package does all” QPKG for this.

Unfortunately, I have no idea (or time) how to create a QPKG so I’ll describe, step by step, how I installed it on my QNAP.
Note: This should work for ARM (untested) and INTEL based QNAP devices. This article was based on QTS 4.1.4 build 910.




QNAPWare to get Aria2 on a QNAP

As usual, we need to go get us some files to install Aria2 and after that the WebUI-Aria2 “applications”.
For installing Aria2, we will use and install “QNAPWare” as well.

QNAPWare looks like a promising successor of the, already for years, dormant OptWare.

Let’s start with that, QNAPWare, as we will need it to install Aria2.
Keep in mind that QNAPWare can be seen as a OptWare replacement, but in the end is not quite that [yet]. So don’t just randomly thtow OptWare of your QNAP! You can leave, and probably should, OptWare installed, they can both live on the same system.

If you’re interested, there is this huge list (1700+) of packages available through QNAPWare.

The recommended way to get QNAPWare:

QNAPWare (at the moment) can be found only be found QNAP Forum post or the QNAP Community webpage. In the (near?) future, you might find it in the “App Center” of your QNAP as well, but this is not the case yet at the time of this writing.

You could of course download the version from Tweaking4All, but keep in mind that it might be a horribly outdated version, and … Make sure you pick the right one. Since my QNAP is an x86 based model, I have not been able to test the ARM version.

Download - Qnapware (Intel) 

Filename:  Qnapware-0.90-x86.qpkg
Platform:  Undefined
Version:  0.90
File size:  28.2 kB
Date:  2015-05-01
 Download Now  Send me a cup of Coffee    

Download - Qnapware (Arm) 

Filename:  Qnapware-0.90-arm-x19.qpkg
Platform:  Undefined
Version:  0.90
File size:  28.2 kB
Date:  2015-05-01
 Download Now  Send me a cup of Coffee    

For now we need to manually install QNAPWare through the “App Center“.
Go to the web interface of your QNAP and openApp Center“.

Click the “Install Manually” button.

QNAP App Center - Install Manually

QNAP App Center – Install Manually

A file dialog will open, where you click the “Browse…” button, and select the download QNAPWare QPKG (in case this is a ZIP file, unzip it first, you need the “.qpkg” file). Click “Open“, click “Install“, click “OK“, wait a few seconds for the QNAP to install the file, click “OK” and finally click “Close“.

That’s all there is to it to install QNAPWare, it should appear under “My Apps” now … and you’ll notice that it’s “ON” but that it’s lacking a web interface (there is no “Open” button). Hopefully they will add that in the future, because for now we will have to go into the QNAP through SSH.

QNAP - OptWare and QNAPWare side by side

QNAP – OptWare and QNAPWare side by side

 To be able to access your QNAP through SSH, you will need to make sure SSH is enabled on your QNAP (see the SSH article for more details).

Installing Aria2, the command line download tool, on your QNAP

The next step is to install Aria2. For this, like I just said, we need to use SSH to get into our QNAP.

Before we install Aria2 though, we should give QNAPWare an update, by using the “opkg” statement. This is pretty common practice with similar other Linux Package Managers – update the manager before installing anything.

The application “opkg” works similar to “ipkg”, which you might, or might not, be familiar with from OptWare. So be aware,… it’s “opkg” … with an “o”.


opkg update

Which should return something like this:


Downloading http://qnapware.zyxmon.org/binaries-x86/Packages.gz.
Updated list of available packages in /Apps/opt/var/opkg-lists/packages.

If you had SSH open while installing QNAPWare … 

I ran into this myself, I had SSH open while I was installing QNAPWare and guess what … “opkg update” did not work … my QNAP could not find “opkg”.
To remedy this: close your SSH connect and reconnect SSH to your QNAP, now it will work.

The next step is to install Aria2 (you can find it in this list (x86/Intel) or this list (ARM)):


opkg install aria2

which will install Aria2 and additionally needed packages (the so called “dependencies”) and will result in something like this:


Installing aria2 (1.18.7-1a) to root...
Downloading http://qnapware.zyxmon.org/binaries-x86/aria2_1.18.7-1a_qnapx86.ipk.
Installing zlib (1.2.8-1) to root...
Downloading http://qnapware.zyxmon.org/binaries-x86/zlib_1.2.8-1_qnapx86.ipk.
Installing libxml2 (2.9.2-3) to root...
Downloading http://qnapware.zyxmon.org/binaries-x86/libxml2_2.9.2-3_qnapx86.ipk.
Installing libopenssl (1.0.2d-1) to root...
Downloading http://qnapware.zyxmon.org/binaries-x86/libopenssl_1.0.2d-1_qnapx86.ipk.
Configuring zlib.
Configuring libxml2.
Configuring libopenssl.
Configuring aria2.

Aria2 is now installed, you can test it by typing “ aria2c -v ” in your SSH shell:


aria2c -v

aria2 version 1.18.7
Copyright (C) 2006, 2014 Tatsuhiro Tsujikawa

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

** Configuration **
Enabled Features: BitTorrent, GZip, HTTPS, Message Digest, Metalink, XML-RPC
Hash Algorithms: sha-1, sha-224, sha-256, sha-384, sha-512, md5
Libraries: zlib/1.2.8 libxml2/2.9.2 OpenSSL/1.0.2d
Compiler: gcc 4.8.3
  built by   i486-pc-linux-gnu
  targetting i686-openwrt-linux-gnu
  on         Aug  1 2015 14:27:55
System: Linux 3.4.6 #1 SMP Thu Sep 10 05:35:09 CST 2015 x86_64

Report bugs to https://github.com/tatsuhiro-t/aria2/issues
Visit http://aria2.sourceforge.net/

 

Aria2 workss, so let’s make a destination where Aria2 can dump it’s downloads, for example a directory in the “Download” share of your QNAP.


1
2
cd /share/Download/
mkdir Aria2

The actual location will be something like “/share/MD0_DATA/Download“, but the “MDO_DATA” can be different on your QNAP, so that’s why I used the linked version.

Now if we want to start Aria2, manually, and keep it in the background we would need to do something like this:


aria2c --enable-rpc=true --rpc-listen-all=true --rpc-allow-origin-all --dir=/share/Download/Aria2 --file-allocation=none -s 5 -j 3 -x 5 -c -D

 That is one single line!

Some explanation on what this does (see also the Aria2 Manual, or type “ aria2c -h ” in your SSH shell):

Aria2 Starting Parameters
 Parameter Purpose
 –enable-rpc=true Enable JSON-RPC/XML-RPC server
 –rpc-listen-all=true Listen incoming JSON-RPC/XML-RPC requests on all network interfaces.
 –rpc-allow-origin-all Add Access-Control-Allow-Origin header field with value * to the RPC response.
 –dir=/share/Download/Aria2 Here we set the destination directory for our downloads (the dir we just made).
 –file-allocation=none Specifies if file space is allocated or not.
It seems the best choice to set this to “none” on a QNAP.
 -s 5 This means that we want Aria2 to split a download in 5 segments.
Meaning: 5 download “streams” in parallel.
 -j 3 Here we say that we can have only 3 concurrent downloads at a time.
So that means 15 “streams” in parallel if we spilt files in 5 segments.
 -x 5 Aria2 should not have more than 5 connections to the same server.
 -c We allow resuming a download incase it got stopped in between.
 -D Make Aria2 run as a Daemon.

Note that I’m no expert on the RPC part, I copied what was suggested elsewhere.
Any better recommendation are most welcome, please post them in the Comments below.

Note : Most of these settings can be modified/done in the web-interface as well.

To (brutally) stop the Aria2 daemon, you can use – I could not find a “cleaner” method:


killall aria2c

Make Aria2 Automatically Startup at QNAP boot

QNAP offers several methods to make something start automatically at boot.
I prefer the .QPKG method described in the QNAP Wiki. Feel free to use any method you like, or maybe even just start it manually when needed.

These are the steps I took, in SSH:


nano /etc/config/qpkg.conf

At the end of this file add something like the code below. The paths used will be created once we have edited this.


1
2
3
4
5
6
7
8
[Aria2]
Name = Aria2
Version = 0.9
Author = zyxmon
Date = 2015-01-02
Shell = /share/MD0_DATA/.qpkg/Aria2/autorun.sh
Install_Path = /share/MD0_DATA/.qpkg/Aria2
Enable = TRUE

When done adding this text, press CTRL+X, type “Y” and finally press ENTER, so the changes will be saved.

Next step is to create the directory we just entered in the qpkg.conf file:


mkdir /share/MD0_DATA/.qpkg/Aria2

And create the “autorun.sh” file:


nano /share/MD0_DATA/.qpkg/Aria2/autorun.sh

We should enter something like this (please keep in mind that I’m not a shell or qpkg expert, improvements are most welcome), which will start Aria2 as a Daemon:


1
2
3
#!/bin/sh

aria2c --enable-rpc=true --rpc-listen-all=true --rpc-allow-origin-all --dir=/share/Download/Aria2 --file-allocation=none -s 5 -j 3 -x 5 -c -D

 Make sure that second line (aria2c) is ONE LINE. Pasting this in Nano might break the line, so pay attention to that.

Press CTRL+X, type “Y” and press ENTER to save the file and close Nano.

Autorun tip …  

I have found that in some configurations the autorun fails because it cannot find “aria2c”.
In that case change “aria2” to “<span class="s1">/Apps/opt/bin/aria2c” in to autorun.sh.

Another issue you might run into, is that the “/Apps” directory does not seem to exists at startup – wait a few minutes until it re-appears.
I unfortunately do not have a proper workaround for that one … yet.

This scrip will be used to start Aria2, so it needs to be made executable:


chmod +x /share/MD0_DATA/.qpkg/Aria2/autorun.sh

You can test the script now. First kill Aria2 in case it was running as a daemon (killall aria2c ), and then run this script from the command line:


/share/MD0_DATA/.qpkg/Aria2/autorun.sh

If no errors occurred, then you can us “ps” and “grep” to check if it’s running. If you see only one line (grep aria – like the last line in the example below) then Aria2 is NOT running. Please check the script!


1
2
3
4
# ps -ax | grep aria

  831 admin      2296 S   aria2c --enable-rpc --rpc-listen-all=true --rpc-allow
  837 admin       280 S   grep aria

As of now, Aria2 will automatically start when you boot up your QNAP.

Installing WebUI-Aria2 for your QNAP

Having Aria2 is all nice and dandy, but we all like to have a slick looking web-interface for it. In daily use you’d probably not want to go through SSH and manually type all that is needed.

Tip : Technically we would not need the web-interface. The Google Chrome AddOn discussed below would do some of the basic functions just fine. The web-interface however can be practical to do some of the more advanced settings.

Recommended: So we need to go get the WebUI-Aria2 from GitHub: Go to this GitHub link and click the “Download” button on the right.

You can do all this directly in your SSH shell:


1
2
3
4
5
cd /share/Web
wget https://github.com/ziahamza/webui-aria2/archive/master.tar.gz --no-check-certificate
tar xpvf master.tar.gz
rm master.tar.gz
mv webui-aria2-master aria2

You now have a directory called “aria2” in your “/share/Web” directory.

Not recommended, but alternatively, you can get the potentially outdated file from Tweaking4All:

Download - WebUI-Aria2 

Filename:  webui-aria2-oct-1-2015.zip
Platform:  Undefined
Version:  October 1st, 2015
File size:  1.2 MB
Date:  2015-10-01
 Download Now  Send me a cup of Coffee    

Opening Aria2 WebUI for the first time

Now that Aria2 is installed and a suitable web-interface for it, time to open it for the first time.

Web Server MUST be running on your QNAP 

Just to make sure, check if the “Web Server” on your QNAP is enabled.

Go o “Control Panel” on your QNAP, select “Applications Web Server” and make sure “Enable Web Server” is check, preferably with port “80”, and click “Apply“.

Open a browser and type  http://<ip of your QNAP>/aria2/ .
For my setup this would be: http://192.168.1.100/aria2/

Note : If you did use a different port number, other than the default port 80, for example “81”, then you will need to add this to the link (port 80 does not need this):   http://<ip of your QNAP>:81/aria2/

You can now do some optional settings, under the “settings” menu option, but I’d try downloading a random file first, just to see if it works.

Aria2 WebUI on a QNAP!

Aria2 WebUI on a QNAP!

Let’s add a test download, if you’re looking for test files, just grab a Linux distro somewhere, or something else that is relatively big, or get one of the files at ThinkBroadBand (specifically for test purposes).

Click the “Add” button, and click “By URIs“, so we can paste one or more links:

Aria2 - Let's add a file

Aria2 – Let’s add a file

A new window opens, where we can dump one or more URL of a file we would like to download. Simply paste them in the red box.

If you decide to add multiple links,…

  • If you want to keep multiple files “grouped”, add a space between the URLs.
  • If you want them to appear as individual files, then use a separate line for each link.

 

Click “Start” when you’re good to go.

Aria2 - Add one or more links for download

Aria2 – Add one or more links for download

In my example I used http://ipv4.download.thinkbroadband.com/512MB.zip.

Aria2 on my QNAP, downloading the test file

Aria2 on my QNAP, downloading the test file

There is plenty more to explore when it comes to Aria2 and it’s web-interface.
So far I can say that I’m very happy with the performance (on par with NZBGet speeds!)

I have yet to test Torrents (which I don’t really like to use anyway).
Please feel free to post your findings below in the comment section.

Browser Extension to make things easier …

No, personally I’m not fond of manually figuring out an URL and copy and pasting them in yet another web-interface, so I went looking for a tool that could help me, … and I found such a tool … Aria2c Integration, a Google Chrome addon.

First step is to install the addon the usual “Chrome” way, through this link.

Next step is to right click the icon in your Google Chrome toolbar and choose the option “options“.

Aria2c Integration - Options page

Aria2c Integration – Options page

In the field “JSON-RPC Path” you will have to match the IP address with the IP address of your QNAP. In my case that would be 192.168.1.100, as you can see in the image above. So replace 192.168.1.100 with the IP of your QNAP and that’s all you have to do …

The link will look something like this:  http://<QNAP IP address>:6800/jsonrpc

Now when we see a file in our browser that we would like to download, simply right click the link and choose “Download with aria2” to add the file to the Queue of Aria2, and download will start automatically.

Select "Download with Aria2"

Select “Download with Aria2”

Which we can see below where I’ve opened the popup of the “Aria2c Integration” while having the WebUI-Aria2 open, so we can see what’s happening:

Chrome Add on and WebUI at the same time

Chrome Add on and WebUI at the same time

I’m sure there are more extensions that support Aria2,… again, feel free to post suggest and ideas, tweaking idea, better settings, etc.

Tip: Auto Download … 

If you look at the “Capture” settings in the “Aria2c Integration” settings, the you’ll see that you can set the file size for when it should auto capture a link you click. I’ve set the “File Size >=” field to 10M on mine, and it works SLICK!

 

Removing Aria2 from your QNAP

If there is anything that annoys the heck out of me, then it is that when I want to try something, and it didn’t work out, but proves to be a b*tch to remove it.

If you installed Aria2 as described in this article, then removal shouldn’t be too hard:

  1. Remove the download folder (rm -f /share/Download/Aria2 ),
  2. Stop Aria2 runnings as a Daemon (killall aria2c ),
  3. Remove the web-interface (rm -rf /share/Web/aria2 ),
  4. Uninstall Aria2 (opkg remove aria2 ),
  5. Remove the Aria2 lines from /etc/config/qpkg.conf (nano /etc/config/qpkg.conf ),
  6. Remove the dummy QPKG folder (rm -f /share/MD0_DATA/.qpkg/Aria2 )

 

If you’d like, you can remove QNAPWare throught the “App Center” as well, although it will very likely be useful in the future …

Support Us ...


Your support is very much appreciated, and can be as easy as sharing a link to my website with others, or on social media.

Support can also be done by sponsoring me, and even that can be free (e.g. shop at Amazon).
Any funds received from your support will be used for web-hosting expenses, project hardware and software, coffee, etc.

Thank you very much for those that have shown support already!
It's truly amazing to see that folks like my articles and small applications.

Please note that clicking affiliate links, like the ones from Amazon, may result in a small commission for us - which we highly appreciate as well.

Comments


There are 13 comments. You can read them below.
You can post your own comments by using the form below, or reply to existing comments by using the "Reply" button.

  • Oct 3, 2015 - 8:39 AM - John Comment Link

    Nice! Works as advertised! 

    Reply

    John

  • Dec 11, 2015 - 1:42 PM - Rudi Pittman Comment Link

    Firefox users seem to be out of luck when it comes to an extension to submit things to aria2.  Have you considered adding some lines to have aria2 monitor a folder for torrents?  This could possibly be accomplished via a crontab entry of some sort that ran a shell script which would check the folder, feed the torrent to aria2 if present and then move it to a “processed” folder afterward so it would not trigger again.  

    Doing that would allow any of the many apps that support “black hole” folders to use aria for the downloading of torrents such as couch potato, sickrage etc.

    Reply

    Rudi Pittman

    • Dec 11, 2015 - 2:03 PM - hans - Author: Comment Link

      Hi Rudi,

      thanks for the heads up! 

      I’m not a FireFox user … so I didn’t test that – are there no plugins for FireFox that support Aria2?
      I did see that Flashgot mentions that it supports Aria, but I have not tested this. An old forum post (2008) talks about this as well – so I’d assume this might work (link).

      Adding a blackhole isn’t a bad idea! I’m not a Torrent user, but I can see it being practical.
      One could make a script that checks a folder, and if a torrent is found, add it. (see Aria2 documentation
      Unfortunately, I’m not a Torrent expert, but there are a boat load of options for Aria2 (link).
      Maybe one or the other script writer, or the developer of Aria2 would like to help out with that.
      Note: it seems that a request has been made with the developer of Aria2 way back in 2009 (link), I’m curious if that has been picked up or not …

      Reply

      hans

  • Dec 11, 2015 - 1:54 PM - Rudi Pittman Comment Link

    You may also find this of interest since it would save downloads that error’d out or were interrupted by the system running aria rebooting or shutting down then restarts them when aria2 comes  back up.

    alias myaria2='touch /path/to/download/folder/session.txt && aria2c --enable-rpc --rpc-listen-all --save-session=/path/to/download/folder/session.txt --input-file=/path/to/download/folder/session.txt -x16 -s16 -k1M --dir=/path/to/download/folder'
    Reply

    Rudi Pittman

    • Dec 11, 2015 - 2:05 PM - hans - Author: Comment Link

      Oh! That sounds interesting! Thanks for the tip!

      I’m currently traveling, so I won’t be able to test this until I get home (mid Januari).
      But I most certainly will …! 

      Reply

      hans

      • Dec 11, 2015 - 6:10 PM - Rudi Pittman Comment Link

        Modified autorun.sh [2nd line is all 1 really long line]:

        #!/bin/sh
        touch /share/Download/Aria2/session.txt && aria2c --enable-rpc=true --rpc-listen-all=true --rpc-allow-origin-all --save-session=/share/Download/Aria2/session.txt --input-file=/share/Download/Aria2/session.txt --dir=/share/Download/Aria2 --file-allocation=none -s 5 -j 3 -x 5 -c -D

        Reply

        Rudi Pittman

      • Dec 12, 2015 - 9:34 AM - hans - Author: Comment Link

        Awesome! Thanks Rudi! 

        Reply

        hans

  • Dec 12, 2015 - 12:38 AM - Rudi Pittman Comment Link

    The following location can be saved in a bookmarklet which will open the aria2 webui in a new browser tab/window.  In firefox right click the bookmark bar and pick “New Bookmark” then give it a name such as “Aria2 WebUI” and paste the following into the location line.   Make sure you alter the ip address to the one YOUR nas is on.

    javascript:void(window.open(‘http://192.168.3.119/aria2/’));

    Reply

    Rudi Pittman

    • Dec 12, 2015 - 9:40 AM - hans - Author: Comment Link

      Oh that’s actually a good one … I always right click the bookmark in the “bookmarks bar” of Chrome.
      I should try your trick! Saves me juggling the mouse buttons on my laptop .

      Reply

      hans

      • Dec 12, 2015 - 6:35 PM - Rudi Pittman Comment Link

        I finally decided just to make it a normal bookmark but check the “Open in sidebar” option in bookmark properties.  In firefox this makes it open in a resizable panel on the left of whatever page I’m on.  The aria2 webui actually resizes itself just fine based on the panel size and the add, manage, etc options are all readily available which makes a quick cut and paste pretty painless.   Turns out I don’t need an extension after all!   Examples: https://imgur.com/a/okrMY

        Ok I’ll quit “mail bombing” your comment box now. ;)

        Reply

        Rudi Pittman

      • Dec 13, 2015 - 9:43 AM - hans - Author: Comment Link

        Hi Rudi!

        Don’t consider it mail bombing haha – this is excellent info for those using FireFox!

        Thank you so much for taking the time to post this info! 

        Reply

        hans

  • Aug 22, 2018 - 10:42 AM - Vittorio Comment Link

    Hi

    thanks for the tutorial. Cannot find help for the flag

    -–rpc-allow-origin-all
    Reply

    Vittorio



Your Comment …

Do not post large files here (like source codes, log files or config files). Please use the Forum for that purpose.

Please share:
*
*
Notify me about new comments (email).
       You can also use your RSS reader to track comments.


Tweaking4All uses the free Gravatar service for Avatar display.