AMule is a p2p
, open source client for the eD2k
network. Released under the GPL
license, it supports a lot of platforms and operating systems. In this tutorial we will see how to install a minimal, headless version of AMule on Raspbian “Stretch”, the latest version of the official Raspberry Pi OS. We will see how to setup the amule-daemon and adjust the firewall rules in order to control it via web interface.
In this tutorial you will learn:
- How to install and configure the amule-daemon
- How to configure and access the amule web interface
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | Raspbian |
Software | Amule-daemon |
Other | Administrative privileges to install and setup the amule-daemon and the needed firewall rules |
Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Installation
Before anything else we need to install the amule-daemon
package on the current stable version of Raspbian
(codename: “Stretch”). The package available in the distribution repositories is outdated, and doesn’t work very well: to install a more recent version of the it, we need to do some pinning
from the testing version of Raspbian.
As you know Raspbian is based on Debian, which has three main release branches, named after Toy Story characters: stable
(currently Stretch), testing
(currently Buster) and unstable
(Sid). Thanks to pinning we can install packages belonging to a specific branch of the distribution into another one. Pinning must be done carefully, and only when absolute necessary. In our case, we want to install a more recent version of the amule-daemon
package from the testing repositories into the stable version.
The first step to reach our goal, is to add the testing repositories to our software sources. We open the /etc/apt/sources.list
file, and append the following lines to it:
# Raspbian testing repositories deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
As a next step we must define our priority rules. We want packages to be installed from the stable repositories by default, and from testing only when we specify so. With our favorite text editor and administrative privileges, we open the /etc/apt/preferences
file (creating it if it doesn’t already exist), and we paste the following content in it:
Package: * Pin: release a=stable Pin-Priority: 900 Package: * Pin: release a=testing Pin-Priority: -1
With the above configuration we set a Pin-Priority
of 900
to the packages belonging to the stable repositories, and a negative priority, -1
, to the ones contained in testing. With this configuration the former software source will always be privileged, unless we explicitly require otherwise, as we will see in a moment. We synchronize our software sources by running:
$ sudo apt-get update Hit:1 http://archive.raspberrypi.org/debian stretch InRelease Hit:2 http://raspbian.raspberrypi.org/raspbian stretch InRelease Hit:3 http://raspbian.raspberrypi.org/raspbian buster InRelease Reading package lists... Done
As we said above, we must explicitly require to install the amule-daemon
package from the testing repositories. We do it by using the -t
option when running the apt-get install
command, passing the target release for the package as argument. We run:
$ sudo apt-get install amule-daemon -t testing Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: amule-common amule-utils libboost-system1.67.0 libcrypto++6 libixml10 libupnp13 Suggested packages: amule-gnome-support The following NEW packages will be installed: amule-common amule-daemon amule-utils libboost-system1.67.0 libcrypto++6 libixml10 libupnp13 0 upgraded, 7 newly installed, 0 to remove and 438 not upgraded. Need to get 0 B/3,932 kB of archives. After this operation, 14.5 MB of additional disk space will be used. Do you want to continue? [Y/n]
Once provide our confirmation, the package will be installed on our system. The amule-daemon
will be started by default, but to be used it must be configured first.
Configuring the amule-daemon
The first thing to setup is the user
the daemon should run as. We can use an already existent user on our system, or create a dedicated one just for the daemon. The most important thing, however is to avoid running the daemon as a privileged user. The file we must edit, at this point, is /etc/default/amule-daemon
. In the file we can define the AMULE_USER
and optionally the AMULE_HOME
variables. With the former we define the user the daemon should run as, with the latter, an alternative folder inside which the .aMule
directory, containing all the configuration, temporary and downloaded files, should be created. The option can be useful, for example, to keep the configuration files on a separate partition or hard disk. Here is the content of the edited file:
# Configuration for /etc/init.d/amule-daemon # The init.d script will only run if this variable non-empty. AMULED_USER="amuleuser" # You can set this variable to make the daemon use an alternative HOME. # The daemon will use $AMULED_HOME/.aMule as the directory, so if you # want to have $AMULED_HOME the real root (with an Incoming and Temp # directories), you can do `ln -s . $AMULED_HOME/.aMule`. AMULED_HOME=""
The next step consists in the generation and the configuration of the amule-daemon and the web server settings. As the user we specified in the above configuration, we run the following command:
$ amuled
The command will try to start the daemon in foreground but will fail, since we didn’t configured it appropriately yet. Don’t worry! All that matter to us, is that the command will generate the .aMule directory containing the AMule configuration files in the HOME
directory of the user. The file we must edit is .aMule/amule.conf
. It can be used to configure the application, specifying, among the others, the ports that should be used for the connection and the directories to be used for temporary and incoming files, by default set respectively to .aMule/Temp
and .aMule/Incoming
.
For the amule-daemon to work correctly, we must, first of all, change the value of AcceptExternalConnection
and set it to 1
. The line to edit is 117
:
AcceptExternalConnections=1
After that, we must choose a password for the connections. In the file we don’t put the plain password, but its md5 hash
. To obtain the hash of the password we can run the following command, where “secretpassword” should be substituted by the password you want to use:
$ echo -n secretpassword|md5sum|cut -d ' ' -f1 2034f6e32958647fdff75d265b455ebf
We must copy the generated password at line 120
of the amule.conf
file, as the value of ECPassword
:
ECPassword=2034f6e32958647fdff75d265b455ebf
Finally, we must enable the WebServer
and provide the password that will be used for the remote login. The related options can be found under the [WebServer]
section, at lines 129
and 130
of the file, respectively. To generate the password for the web server, we can use the same method we used above.
[WebServer] Enabled=1 Password=3eb181626d386a39085df1866429196f
At line 131
we can notice the PasswordLow
option. It is not mandatory, but can be useful to access the web interface with less privileges.
Configuring the firewall
Before we can access the amule-daemon using the web interface, we must modify our firewall rules to let incoming traffic through port 4711/tcp
. For the sake of this tutorial I will assume the firewalld
firewall manager is in use on the machine:
$ sudo firewall-cmd --permanent --add-port 4711/tcp
We specified the --permanent
option to make the changes persistent. Be aware that the above command will operate on the default
firewalld zone. If we want the changes to be applied on a specific zone, we must specify its name as the argument of the --zone
option. By the way, if you are not familiar with firewalld, you can read our guide about it here.
We must reload the firewall for the changes to be effective:
$ sudo firewall-cmd --reload
The rule we specified above will grant us access to the web interface. To achieve good download performance, we should remember, however, to enable also traffic through ports 4662/tcp
, 4672/udp
and 4665/udp
. The same ports should also be opened in the firewall of the router, and redirected to the IP of the machine the daemon is running on, when using NAT
. How to perform such operation is, however, out of the scope of this tutorial.
Start the daemon and access the web interface
We can now restart the amule-daemon:
$ sudo systemctl restart amule-daemon
At this point we should be able to reach the web interface successfully, specifying the IP of our machine and the port 4711 in the browser address bar. The IP of my machine is 192.168.0.39
:
We can login using the password we set before:
The web interface contains a subset of the functionalities provided by the GUI version of AMule; however, the most common tasks can be easily performed from it.
Conclusions
In this tutorial we learned how to install and run an headless version of AMule, on Raspbian “stretch”, the latest stable version of the official Raspberry Pi operating system. We saw how to install a recent version of the amule-daemon from the distribution testing repositories using pinning
, how to configure the daemon, and how setup the firewall in order to access and control AMule via the provided web interface. If you want to know more about AMule, you can visit the official project wiki page.