Articles - Logiciel & scripts

aria2c + webui-aria2

  |   3272  |   Poster commentaire  |  Logiciel & scripts
Cela faisait un petit moment que je cherchais une solution pour lancer des téléchargements chez moi depuis l'extérieur (depuis VPN) sur mon Linux qui me sert de NAS. J'ai trouvé ce qu'il me fallait : aria2c (utilitaire en ligne de commande comme curl et wget) mais surtout son complément : webgui-aria2. J'ai trouvé un billet tutoriel facile à suivre. Évidemment c'est du Linux (Ubuntu 14.04 LTS) donc rien ne se passe comme prévu. :lol

Code BASH :
 
apt-get install aria2
 


La version installée semble être la 1.18.1

Code BASH :
 
root@cerise:~# whereis aria2c
aria2c: /usr/bin/aria2c /usr/bin/X11/aria2c /usr/share/man/man1/aria2c.1.gz
root@cerise:~# aria2c -v
aria2 version 1.18.1
Copyright (C) 2006, 2013 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.
 


Sauf que cela ne fonctionne pas :

Code BASH :
 
root@cerise:~# aria2c --enable-rpc --rpc-listen-all --rpc-secret=w4ZDYU/8rmvqPvP3xs068gUPO3+FXfBZ1xPnlZG6me --daemon
aria2c : option non reconnue « --rpc-secret=w4ZDYU/8rmvqPvP3xs068gUPO3+FXfBZ1xPnlZG6meE7 »
Usage: aria2c [OPTIONS] [URI | MAGNET | TORRENT_FILE | METALINK_FILE]...
See 'aria2c -h'.


Comme indiqué dans les commentaires, il faut une version plus récente. Sur le site, la version est la 1.28.0. Il va falloir la récupérer et la compiler à la main... Une fois extrait :

Code BASH :
 
root@cerise:~/aria2-1.28.0# ll
total 1880
drwxr-xr-x 11 root root   4096 nov.   7 04:42 ./
drwx------ 23 root root   4096 nov.   7 04:41 ../
-rw-r--r--  1 root root  95341 oct.  16 10:35 ABOUT-NLS
-rw-r--r--  1 root root  44864 oct.  16 10:35 aclocal.m4
-rw-r--r--  1 root root   2162 oct.  16 10:34 android-config
-rw-r--r--  1 root root   1686 oct.  16 10:34 android-make
-rw-r--r--  1 root root    928 oct.  16 10:34 AUTHORS
-rw-r--r--  1 root root   5224 oct.  16 10:35 ChangeLog
-rw-r--r--  1 root root   7333 oct.  16 10:35 compile
-rw-r--r--  1 root root  43764 oct.  16 10:35 config.guess
-rw-r--r--  1 root root  21083 oct.  16 10:35 config.h.in
-rw-r--r--  1 root root  18442 oct.  16 10:35 config.rpath
-rw-r--r--  1 root root  36159 oct.  16 10:35 config.sub
-rw-r--r--  1 root root 906870 oct.  16 10:35 configure
-rw-r--r--  1 root root  39179 oct.  16 10:34 configure.ac
-rw-r--r--  1 root root  18002 oct.  16 10:34 COPYING
-rw-r--r--  1 root root  23566 oct.  16 10:35 depcomp
drwxr-xr-x  3 root root   4096 nov.   7 04:41 deps/
drwxr-xr-x  5 root root   4096 nov.   7 04:41 doc/
-rw-r--r--  1 root root   3395 oct.  16 10:34 Dockerfile.mingw
-rw-r--r--  1 root root   3328 oct.  16 10:34 Dockerfile.raspberrypi
drwxr-xr-x  2 root root   4096 nov.   7 04:41 examples/
-rw-r--r--  1 root root  15752 oct.  16 10:35 INSTALL
-rw-r--r--  1 root root  15155 oct.  16 10:35 install-sh
drwxr-xr-x  2 root root   4096 nov.   7 04:41 lib/
-rw-r--r--  1 root root   6968 oct.  16 10:34 LICENSE.OpenSSL
-rw-r--r--  1 root root 324412 oct.  16 10:35 ltmain.sh
drwxr-xr-x  2 root root   4096 nov.   7 04:41 m4/
-rw-r--r--  1 root root   1331 oct.  16 10:34 Makefile.am
-rw-r--r--  1 root root  32033 oct.  16 10:36 Makefile.in
-rw-r--r--  1 root root    761 oct.  16 10:34 makerelease
-rw-r--r--  1 root root  14047 oct.  16 10:34 makerelease-osx.mk
-rw-r--r--  1 root root   2091 oct.  16 10:34 mingw-build-memo
-rw-r--r--  1 root root   2914 oct.  16 10:34 mingw-config
-rw-r--r--  1 root root   2073 oct.  16 10:34 mingw-release
-rw-r--r--  1 root root   6872 oct.  16 10:35 missing
-rw-r--r--  1 root root   1226 oct.  16 10:34 NEWS
drwxr-xr-x  3 root root   4096 nov.   7 04:41 osx-package/
drwxr-xr-x  2 root root   4096 nov.   7 04:41 po/
-rw-r--r--  1 root root     15 oct.  16 10:34 README
-rw-r--r--  1 root root  38517 oct.  16 10:36 README.html
-rw-r--r--  1 root root  22794 oct.  16 10:34 README.rst
-rw-r--r--  1 root root   1663 oct.  16 10:34 script-helper
drwxr-xr-x  4 root root  36864 nov.   7 04:42 src/
drwxr-xr-x  2 root root  16384 nov.   7 04:42 test/
-rw-r--r--  1 root root   4640 oct.  16 10:35 test-driver
 


C'est parti pour la phase configuration :

Code BASH :
 
root@cerise:~/aria2-1.28.0# ./configure
-su: ./configure: Permission non accordée
root@cerise:~/aria2-1.28.0# chmod a+x configure
root@cerise:~/aria2-1.28.0# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
...
 


La phase compilation

Code BASH :
root@cerise:~/aria2-1.28.0# make
make  all-recursive
make[1]: entrant dans le répertoire « /root/aria2-1.28.0 »
Making all in po
make[2]: entrant dans le répertoire « /root/aria2-1.28.0/po »
make[2]: quittant le répertoire « /root/aria2-1.28.0/po »
Making all in lib
make[2]: entrant dans le répertoire « /root/aria2-1.28.0/lib »
make[2]: Rien à faire pour « all ».
make[2]: quittant le répertoire « /root/aria2-1.28.0/lib »
Making all in deps
make[2]: entrant dans le répertoire « /root/aria2-1.28.0/deps »
Making all in wslay
make[3]: entrant dans le répertoire « /root/aria2-1.28.0/deps/wslay »
make  all-recursive
make[4]: entrant dans le répertoire « /root/aria2-1.28.0/deps/wslay »
Making all in lib
make[5]: entrant dans le répertoire « /root/aria2-1.28.0/deps/wslay/lib »
Making all in includes
make[6]: entrant dans le répertoire « /root/aria2-1.28.0/deps/wslay/lib/includes »
make[6]: Rien à faire pour « all ».
make[6]: quittant le répertoire « /root/aria2-1.28.0/deps/wslay/lib/includes »
make[6]: entrant dans le répertoire « /root/aria2-1.28.0/deps/wslay/lib »
............
  CXX      MetalinkResource.lo
  CXX      metalink_helper.lo
  CXX      PollEventPoll.lo
  CXXLD    libaria2.la
  CXX      main.o
  CXXLD    aria2c
make[3]: quittant le répertoire « /root/aria2-1.28.0/src »
make[2]: quittant le répertoire « /root/aria2-1.28.0/src »
Making all in doc
make[2]: entrant dans le répertoire « /root/aria2-1.28.0/doc »
Making all in manual-src
make[3]: entrant dans le répertoire « /root/aria2-1.28.0/doc/manual-src »
Making all in en
make[4]: entrant dans le répertoire « /root/aria2-1.28.0/doc/manual-src/en »
make[4]: Rien à faire pour « all ».
make[4]: quittant le répertoire « /root/aria2-1.28.0/doc/manual-src/en »
Making all in ru
make[4]: entrant dans le répertoire « /root/aria2-1.28.0/doc/manual-src/ru »
make[4]: Rien à faire pour « all ».
make[4]: quittant le répertoire « /root/aria2-1.28.0/doc/manual-src/ru »
Making all in pt
make[4]: entrant dans le répertoire « /root/aria2-1.28.0/doc/manual-src/pt »
make[4]: Rien à faire pour « all ».
make[4]: quittant le répertoire « /root/aria2-1.28.0/doc/manual-src/pt »
make[4]: entrant dans le répertoire « /root/aria2-1.28.0/doc/manual-src »
make[4]: Rien à faire pour « all-am ».
make[4]: quittant le répertoire « /root/aria2-1.28.0/doc/manual-src »
make[3]: quittant le répertoire « /root/aria2-1.28.0/doc/manual-src »
make[3]: entrant dans le répertoire « /root/aria2-1.28.0/doc »
make[3]: Rien à faire pour « all-am ».
make[3]: quittant le répertoire « /root/aria2-1.28.0/doc »
make[2]: quittant le répertoire « /root/aria2-1.28.0/doc »
Making all in test
make[2]: entrant dans le répertoire « /root/aria2-1.28.0/test »
make[2]: Rien à faire pour « all ».
make[2]: quittant le répertoire « /root/aria2-1.28.0/test »
make[2]: entrant dans le répertoire « /root/aria2-1.28.0 »
make[2]: quittant le répertoire « /root/aria2-1.28.0 »
make[1]: quittant le répertoire « /root/aria2-1.28.0 »
 


La phase installation :

Code BASH :
root@cerise:~/aria2-1.28.0# make install
Making install in po
make[1]: entrant dans le répertoire « /root/aria2-1.28.0/po »
installing en@quot.gmo as /usr/local/share/locale/en@quot/LC_MESSAGES/aria2.mo
installing en@boldquot.gmo as /usr/local/share/locale/en@boldquot/LC_MESSAGES/aria2.mo
installing ar.gmo as /usr/local/share/locale/ar/LC_MESSAGES/aria2.mo
installing bg.gmo as /usr/local/share/locale/bg/LC_MESSAGES/aria2.mo
installing bn.gmo as /usr/local/share/locale/bn/LC_MESSAGES/aria2.mo
installing ca.gmo as /usr/local/share/locale/ca/LC_MESSAGES/aria2.mo
installing da.gmo as /usr/local/share/locale/da/LC_MESSAGES/aria2.mo
...
make[2]: quittant le répertoire « /root/aria2-1.28.0/doc »
make[1]: quittant le répertoire « /root/aria2-1.28.0/doc »
Making install in test
make[1]: entrant dans le répertoire « /root/aria2-1.28.0/test »
make[2]: entrant dans le répertoire « /root/aria2-1.28.0/test »
make[2]: Rien à faire pour « install-exec-am ».
make[2]: Rien à faire pour « install-data-am ».
make[2]: quittant le répertoire « /root/aria2-1.28.0/test »
make[1]: quittant le répertoire « /root/aria2-1.28.0/test »
make[1]: entrant dans le répertoire « /root/aria2-1.28.0 »
make[2]: entrant dans le répertoire « /root/aria2-1.28.0 »
make[2]: Rien à faire pour « install-exec-am ».
 /bin/mkdir -p '/usr/local/share/doc/aria2'
 /usr/bin/install -c -m 644 README README.rst README.html '/usr/local/share/doc/aria2'
make[2]: quittant le répertoire « /root/aria2-1.28.0 »
make[1]: quittant le répertoire « /root/aria2-1.28.0 »
 


Un petit make clean et enfin :

Code BASH :
 
root@cerise:~/aria2-1.28.0# whereis aria2c
aria2c: /usr/bin/aria2c /usr/bin/X11/aria2c /usr/local/bin/aria2c /usr/share/man/man1/aria2c.1.gz
root@cerise:~/aria2-1.28.0# cd /usr/local/bin/aria2c
-su: cd: /usr/local/bin/aria2c: N est pas un dossier
root@cerise:~/aria2-1.28.0# /usr/local/bin/aria2c -v
aria2 version 1.28.0
Copyright (C) 2006, 2016 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 **
Fonctionnalités activés: BitTorrent, GZip, HTTPS, Message Digest, Metalink, XML-RPC
Algorithmes de hashage: sha-1, sha-224, sha-256, sha-384, sha-512, md5, adler32
Bibliothèques: zlib/1.2.8 libxml2/2.9.1 GnuTLS/3.2.11 nettle GMP/5.1.3
Compilateur: gcc 4.8.4
  built by   x86_64-pc-linux-gnu
  on         Nov  7 2016 04:45:45
Système: Linux 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64
Faire part des bugs à https://github.com/2016/139/aria2/issues
Visitez https://aria2.github.io/
 


La mienne est plus grosse que la votre :

Code BASH :
root@cerise:~/aria2-1.28.0# ll /usr/bin/aria2c
-rwxr-xr-x 1 root root 2581920 déc.  16  2013 /usr/bin/aria2c*
root@cerise:~/aria2-1.28.0# ll /usr/local/bin/aria2c
-rwxr-xr-x 1 root root 76035096 nov.   7 05:05 /usr/local/bin/aria2c*


Code BASH :
root@cerise:~/aria2-1.28.0# cp /usr/bin/aria2c /usr/bin/aria2c.bak
root@cerise:~/aria2-1.28.0# cp /usr/local/bin/aria2c /usr/bin/aria2c


Maintenant cela fonctionne mieux :

Code BASH :
root@cerise:~# aria2c --enable-rpc --rpc-listen-all --rpc-secret=w4ZDYU/8rmvqPvP3xs068gUPO3+FXfBZ1xPnlZG6me --daemon
root@cerise:~# ps -ef | grep aria
root      7833     1  0 05:11 ?        00:00:00 aria2c --enable-rpc --rpc-listen-all --rpc-secret=****************************************** --daemon
root      7835 31062  0 05:11 pts/2    00:00:00 grep --color=auto aria
 


L'auteur de l'article a la bonne idée de mettre tout cela dans un fichier de config, on ne va pas s'en priver non plus :

Code BASH :
 
jonathan@cerise:~$ cat aria2.conf
dir=/docs/Téléchargements
max-concurrent-downloads=8
max-connection-per-server=3
enable-rpc=true
rpc-listen-all=true
rpc-secret=*******************************
 


On redémarre :

Code BASH :
 
root@cerise:~$pkill aria2
jonathan@cerise:~$ aria2c --conf-path=/home/jonathan/aria2.conf --daemon


Ensuite on récupère la GUI et on dézippe :

Code BASH :
 
root@cerise:~# wget https://github.com/ziahamza/webui-aria2/archive/master.zip && unzip master.zip
--2016-11-07 05:20:40--  https://github.com/ziahamza/webui-aria2/archive/master.zip
Résolution de github.com (github.com)… 192.30.253.112, 192.30.253.113
Connexion à github.com (github.com)|192.30.253.112|:443… connecté.
requête HTTP transmise, en attente de la réponse… 302 Found
Emplacement : https://codeload.github.com/ziahamza/webui-aria2/zip/master [suivant]
--2016-11-07 05:20:41--  https://codeload.github.com/ziahamza/webui-aria2/zip/master
Résolution de codeload.github.com (codeload.github.com)… 192.30.253.121, 192.30.253.120
Connexion à codeload.github.com (codeload.github.com)|192.30.253.121|:443… connecté.
requête HTTP transmise, en attente de la réponse… 200 OK
Taille : 3413099 (3,3M) [application/zip]
Enregistre : «master.zip»
100%[====================================================================================================================================================>] 3 413 099   3,03MB/s   ds 1,1s
2016-11-07 05:20:42 (3,03 MB/s) - «master.zip» enregistré [3413099/3413099]
Archive:  master.zip
6a29c1b1d0224e1daa88906e88bc2e177ca2ad76
   creating: webui-aria2-master/
 extracting: webui-aria2-master/.gitignore
  inflating: webui-aria2-master/Dockerfile
 


Code BASH :
root@cerise:~# cd webui-aria2-master/
root@cerise:~/webui-aria2-master# ll
total 132
drwxr-xr-x  8 root root  4096 oct.  11 15:58 ./
drwx------ 24 root root  4096 nov.   7 05:20 ../
-rw-r--r--  1 root root  2524 oct.  11 15:58 configuration.js
drwxr-xr-x  2 root root  4096 oct.  11 15:58 css/
-rw-r--r--  1 root root  1437 oct.  11 15:58 directurl.md
-rw-r--r--  1 root root   268 oct.  11 15:58 docker-compose.yml
-rw-r--r--  1 root root  1381 oct.  11 15:58 Dockerfile
-rw-r--r--  1 root root  5430 oct.  11 15:58 favicon.ico
drwxr-xr-x  4 root root  4096 oct.  11 15:58 flags/
drwxr-xr-x  2 root root  4096 oct.  11 15:58 fonts/
-rw-r--r--  1 root root    21 oct.  11 15:58 .gitignore
drwxr-xr-x  2 root root  4096 oct.  11 15:58 img/
-rwxr-xr-x  1 root root 53314 oct.  11 15:58 index.html*
drwxr-xr-x  8 root root  4096 oct.  11 15:58 js/
-rw-r--r--  1 root root  1060 oct.  11 15:58 LICENSE
-rw-r--r--  1 root root  2909 oct.  11 15:58 README.md
drwxr-xr-x  2 root root  4096 oct.  11 15:58 screenshots/
-rw-r--r--  1 root root  4549 oct.  11 15:58 webui-aria2.spec
 


On déplace cela ailleurs :

Code BASH :
 
root@cerise:~# mv webui-aria2-master/ webui-aria2
root@cerise:~# cp -r webui-aria2 /usr/share/
 


Modification du configuration.js (essentiellement peupler la variable token) :

Code TEXT :
 
  1 angular
  2 .module('webui.services.configuration',  [])
  3 .constant('$name', 'Aria2 WebUI')  // name used across the entire UI
  4 .constant('$titlePattern', 'active: {active} - waiting: {waiting} - stopped: {stopped} — {name}')
  5 .constant('$pageSize', 11)         // number of downloads shown before pagination kicks in
  6 .constant('$authconf', {           // default authentication configuration, never fill it in case the webui is hosted in public IP as it can be compromised
  7   host: location.protocol.startsWith('http') ? location.hostname : 'localhost',
  8   path: '/jsonrpc',
  9   port: 6800,
 10   encrypt: false,
 11   auth: {                          // either add the token field or the user and pass field, not both.
 12   token: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
 13   /*-----------------------------*/
 14   // user: '*YOUR_USERNAME*',
 15   // pass: '*YOUR_SECRET_PASS*'
 16   },
 17   directURL: ''                   // If supplied, links will be created to enable direct download from the aria2 server, requires appropriate webserver to b    e configured
 18 })
 19 .constant('$enable', {
 


On fait une petite config Apache :

Code BASH :
 
root@cerise:/etc/apache2/sites-available# cat 002-aria2.conf
<IfModule alias_module>
    Alias /webui-aria2 /usr/share/webui-aria2
    <Directory "/usr/share/webui-aria2">
        AllowOverride None
        Options None
        Order deny,allow
        Allow from 192.168.0.0/24 localhost 127.0.0.1
        Deny from all
    </Directory>
</IfModule>
root@cerise:/etc/apache2/sites-available#  ll ../sites-enabled/
total 12
drwxr-xr-x 2 root root 4096 nov.   7 05:35 ./
drwxr-xr-x 9 root root 4096 août  27 13:22 ../
lrwxrwxrwx 1 root root   33 nov.   7 05:35 002-aria2.conf -> ../sites-available/002-aria2.conf
 


On ouvre le port 6800 dans le pare-feu (vous pouvez mettre une règle plus stricte :) :

Code BASH :
ufw allow 6800


On relance apache :

Code BASH :
service apache2 restart


Hop ça marche :



Testons une ISO Fedora :



Aie, erreur d'écriture dans le dossier.



Bizarre car le process aria2c tourne avec mon user "jonathan", après vérification, le "Téléchargements" appartient à root. LOL



Il suffit de cliquer sur une petite icône pour relancer le téléchargement et là ça va mieux :




Pendant le téléchargement un petit fichier suffixé .aria2 temporaire est créé, visiblement c'est du binaire.



Voilà, tout marche bien. A bientôt.