Difference between revisions of "AMuleWeb"

From AMule Project FAQ
Jump to: navigation, search
(replaced sleep 20 in startup scrpt - waiting for the port is better)
(reorg, grammar & spelling)
Line 1: Line 1:
== Description ==
+
'''aMuleWeb''' is a utility that allows you to control aMule by means of a web browser from any location. The web interface offers a subset of aMule functionality, including searching for files, initializing downloads, and viewing your download queue. It also displays status information and allows you to change certain options.
  
aMuleWeb is a utility that listens for [http://www.w3.org/MarkUp HTTP] connections at port 4711 (by default, although it can be changed through '''Preferences''') and allows remote users to control [[aMule]] using just a web browser.  
+
aMule itself doesn't support [http://www.w3.org/MarkUp HTTP] connections; aMuleWeb, which does, therefore serves as an intermediary between aMule and a web browser. Once the link between aMuleWeb and a remote user is established, it connects to aMule via the [[External Connections]] interface.
  
[[aMule]] itself doesn't support listening to [http://www.w3.org/MarkUp HTTP] connections, so the external utility aMuleWeb is used. This utility listens for remote connections, and once the link between aMuleWeb and the remote user is established, it connects to the [[aMule]] main program using the [[External Connections]] mechanism.
+
By default, aMuleWeb listens for HTTP connections at port 4711, but this can be changed in [[Usage Preferences|Preferences]]'.
 +
 
 +
== Installing aMuleWeb ==
 +
 
 +
Many of not most distros have an aMule package in their repositories. If you install aMule by means of RPM, DEB, or other package management system, aMuleWeb will be included in the installation.  
 +
 
 +
This is the easiest and preferred method of installing aMule and aMuleWeb.
  
 
== Compiling aMuleWeb ==
 
== Compiling aMuleWeb ==
  
[[Compile]] [[aMule]] normally, just add ''--enable-amuleweb'' when running ''configure''.
+
If you have not installed aMule by means of a package, you will need to compile it from source.
  
== Setting up aMuleWeb with [[aMule]] ==
+
aMuleWeb is not compiled separately; it is compiled at the same time you compile aMule by using the ''--enable-amuleweb'' flag when you run ''configure''. (See the [[Main Page]] for links to pages on compiling aMule for various operating systems).
  
=== aMuleWeb with [[aMule]] 2.0.0 or later ===
+
== Configuring aMuleWeb ==
  
*For users running the monotlithic [[aMule]] application:
+
To use aMuleWeb, you first need to set several opions in aMule's Preferences notebook. On the "Remote Controls" page, you will need to:
**Go to "Preferences"->"Remote Controls" (in [[aMule]]) and...
+
***Enable "Accept External Connections".
+
***Enable "Use TCP ports instead of unix local sockets" (This option doesn't exist since version 2.1.0)
+
***Enter a password for [[External Connections]]. If you don't do this, aMuleWeb will not communicate with [[aMule]].
+
::'''NOTE:''' When you change your aMuleWeb and [[External Connections]] ports here, make sure to restart [[aMule]].
+
  
*For users running the [[aMule|aMule daemon]]:
+
* Enable "Accept External Connections".
**Shutdown [[aMule|aMuled]] if it is still running.
+
* Enter a password for External Connections.
**Run ''amuleweb -w'' to generate ''~/.aMule/remote.conf'' and edit it for these options. It previously were on ''~/.aMule/amule.conf'', but the lines are still on this file, so edit both if in doubt.
+
* Enable webserver
***''[ExternalConnect]'' <- Section header
+
***''AcceptExternalConnections=1'' <-- To enable [[aMule]] listening for [[External Connections]].
+
***''ECUseTCPPort=1'' <-- To use the [http://www.faqs.org/faqs/internet/tcp-ip/resource-list TCP] port. Very important since [http://www.unix.org Unix] sockets are disabled.
+
***''ECPassword=ca3c365274907c6fd527068788e14639'' <-- To find the MD5 string for your password, do:
+
:::''$ echo -n yourpasswordhere | md5sum | cut -d ' ' -f 1''
+
:::''ca3c365274907c6fd527068788e14639''
+
**If you get ''FATAL ERROR: Cannot find template: default'' it's because you didn't run ''make install''. If you don't want to install aMule, copy the ''src/webserver/default/'' directory into ''~/.aMule/webserver/'' (create it if needed). If you want any other template (probably ''php-default''), copy it too. Then go back to the previous step.
+
**Restart [[aMule|aMule]]
+
  
 +
You can also modifiy the default aMuleWeb port (4711) and External Connections port (4712) here as well, but if you do so, you will need to restart aMule for the changes to take effect.
  
'''NOTE:''' Every password must be md5sum,also webserver one/s. aMule embedded webserver works without remote.conf,you just need to edit ''amule.conf''. A good trick if you have somewhere an X server is to configure amule using the GUI and then copy the ''amule.conf'' configuration file where you want to run the daemon.
+
(If you are running aMuled and don't want to use aMule to configure aMuleWeb, see the instructions below)
  
Thanks to [[User:Stefanero|Stefanero]], from who I shamelessly stole a lot from his tutorial.
+
Next, you need to do is generate ''remote.conf'', the file where aMuleWeb stores its configuration information. (It can be found in the .aMule directory.) Among other things, this file contains the port number which aMule uses for External Connections as well as the password needed to access aMule.
  
'''NOTE:''' aMuleWeb uses cookies to hold session id. Make sure that cookies are enabled in your browser.
+
To create a ''remote.conf'' file, enter at the command line:
  
=== aMuleWeb with [[aMule]] pre-2.0.0 final ===
+
$ amuleweb -w
  
Please check [[Webserver-old|this page]] for archived instructions (educational purposes!).
+
aMuleWeb will read the necessary configuration information from amule.conf and generate a ''remote.conf'' file, then exit.
  
== Running aMuleWeb ==
+
Then start aMuleWeb normally:
There's 2 options for activating aMuleWeb.
+
*First, and preffered, is to enable aMuleWeb activation on aMule preferences. This option works for amuled as well. When started, aMule will attempt to execute '''amuleweb''' command, asuming it's in the search path. Upon exit, aMuleWeb will be automatically terminated.
+
*Second options is to run aMuleWeb manually, using '''''amuleweb''''' command on a terminal.
+
  
Once aMuleWeb is running, open a web browser and connect to:
+
$ amuleweb
  
''http://host:port''
+
You should now be able to open aMuleWeb in a browser by entering the URL (on the local system):
  
where ''host'' stands for your host's name (try with ''localhost'') and port stands for the aMuleWeb port ('''NOT''' the [[External Connections]] port).
+
  http://localhost:4711
  
For example: ''http://localhost:4711''
+
or, the with computer's hostname (locally or remote):
  
''Shakraw''
+
  http://hostname:4711:
 +
 
 +
If you want to run aMuleWeb on a different computer than aMule, just copy ''remote.conf'' to the .aMule directory on that computer, and change the hostname line accordingly.
 +
 
 +
'''NOTE:''' aMuleWeb uses cookies to store session information. Make sure that cookies are enabled in your browser.
 +
 
 +
== Launching aMuleWeb ==
 +
 
 +
There are two options for launching aMuleWeb.
 +
 
 +
First, and preferred, is to enable aMuleWeb activation in aMule's preferences.  When started, aMule (or aMuled) will launch amuleweb. Upon exit, aMuleWeb will be automatically terminated.
 +
 
 +
The second option is to run aMuleWeb manually by entering the "amuleweb" command in terminal.
 +
 
 +
== Configuring aMuleWeb with aMuled ==
 +
 
 +
First, if aMuled is running, shut it down.
 +
 
 +
Then run:
 +
 
 +
  $ amuleweb -w
 +
 
 +
to generate a ''remote.conf'' file. You will need to edit these options in the [ExternalConnect] section:
 +
 
 +
*''AcceptExternalConnections=1'' <-- To enable External Connections.
 +
 
 +
*''ECPassword=ca3c365274907c6fd527068788e14639'' <--  MD5 string
 +
 
 +
You can then restart amuled and amuleweb.
 +
 
 +
'''NOTE:''' Passwords must be md5sum format. To generate an MD5sum for your password, run:
 +
:''$ echo -n yourpasswordhere | md5sum | cut -d ' ' -f 1''
 +
:''ca3c365274907c6fd527068788e14639''
 +
 
 +
'''Note'''If you get ''FATAL ERROR: Cannot find template: default'' it's because you didn't run ''make install''. If you don't want to install aMule, copy the ''src/webserver/default/'' directory into ''~/.aMule/webserver/'' (create it if needed). If you want any other template (probably ''php-default''), copy it too. Then go back to the previous step.
 +
 
 +
 
 +
=== aMuleWeb with older versions of aMule ===
 +
 
 +
For instructions for using aMuleWeb with aMule pre-2.0.0 final, see [[Webserver-old|this page]] for archived material.
  
 
== Standard ports ==
 
== Standard ports ==
  
The ports can be set to anything, but this are the most used (the standard ones):
+
The ports can be set to anything, but by default aMule uses:
  
*[[External Connections]]: 4712
+
*External Connections: 4712
 
*amuleweb: 4711
 
*amuleweb: 4711
  
Make sure you do not confuse with what each of them is.
+
Make sure you do not confuse the two; in the default configuration, it looks like this:
 +
 
 +
aMule --> [4712] --> aMuleWeb --> [4711] --> web browser
  
 
== Template (skin) location ==
 
== Template (skin) location ==
  
 
aMuleWeb looks for its files in a number of places:
 
aMuleWeb looks for its files in a number of places:
 +
 
*In your home directory: ''$HOME/.aMule/webserver/''[skin name]''/''
 
*In your home directory: ''$HOME/.aMule/webserver/''[skin name]''/''
*And at it's install location, in this order (by default, ''/usr/local/share/amule/webserver'' if you compiled [[aMule]], or ''/usr/share/amule/webserver'' if you installed it from a package).
+
 
 +
*And at its install location, in this order (by default, ''/usr/local/share/amule/webserver'' if you compiled aMule, or ''/usr/share/amule/webserver'' if you installed it from a package).
  
 
Default template name is 'default'.
 
Default template name is 'default'.
  
If, '''after installing''' [[aMule]], aMuleWeb refuses to run because of not being able to load template:
+
If, ''after installing'' aMule, aMuleWeb refuses to run because of not being able to load template:
 +
 
 
*Please report this situation to us, and then
 
*Please report this situation to us, and then
*Create the directories ''webserver/default'' in the ''.aMule'' subdirectory of your home directory, and copy the contents of the ''src/webserver'' directory there from the [[aMule]] tarball (I mean to ''$HOME/.aMule/webserver/default'').
 
  
'''[[User:GonoszTopi|GonoszTopi]]'''
+
*Create the directories ''webserver/default'' in the ''.aMule'' subdirectory of your home directory, and copy the contents of the ''src/webserver'' directory there from the aMule tarball (ie, ''$HOME/.aMule/webserver/default'').
 +
 
 +
== aMuled and aMuleWeb as services  ==
  
== How to start [[aMuled|aMule Daemon]] and aMuleWeb with your computer ==
+
Although starting aMuleWeb by enabling it inaMule's preferences is the preferred method, you can also run aMuleWeb together with aMuled as as services by means of an init.d script. Here is an example:
  
The best way to start both the processes aMule Daemon and aMuleWeb with your server is to add a shell script ''/etc/init.d/amule'' like this:
+
''/etc/init.d/amule''
  
 
  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
 
  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Line 144: Line 180:
 
  update-rc.d amule defaults
 
  update-rc.d amule defaults
  
Then, for the deamons to start you just have to create a file ''/etc/default/amule'' which contains a single line:
+
Then, for the daemons to start you just have to create a file ''/etc/default/amule'' which contains a single line:
  
 
  RUNAMULE=yes
 
  RUNAMULE=yes
 
That's it!
 
  
 
== Template language and development  ==
 
== Template language and development  ==
 +
 
Simply put, aMuleWeb templates are ordinary HTML files. In order to make them "interactive", server-side language is embedded inside. This language is scaled down dialect of PHP. More detailed information can be found on [[aMuleWeb_PHP]].
 
Simply put, aMuleWeb templates are ordinary HTML files. In order to make them "interactive", server-side language is embedded inside. This language is scaled down dialect of PHP. More detailed information can be found on [[aMuleWeb_PHP]].
  

Revision as of 15:43, 17 December 2006

aMuleWeb is a utility that allows you to control aMule by means of a web browser from any location. The web interface offers a subset of aMule functionality, including searching for files, initializing downloads, and viewing your download queue. It also displays status information and allows you to change certain options.

aMule itself doesn't support HTTP connections; aMuleWeb, which does, therefore serves as an intermediary between aMule and a web browser. Once the link between aMuleWeb and a remote user is established, it connects to aMule via the External Connections interface.

By default, aMuleWeb listens for HTTP connections at port 4711, but this can be changed in Preferences'.

Installing aMuleWeb

Many of not most distros have an aMule package in their repositories. If you install aMule by means of RPM, DEB, or other package management system, aMuleWeb will be included in the installation.

This is the easiest and preferred method of installing aMule and aMuleWeb.

Compiling aMuleWeb

If you have not installed aMule by means of a package, you will need to compile it from source.

aMuleWeb is not compiled separately; it is compiled at the same time you compile aMule by using the --enable-amuleweb flag when you run configure. (See the Main Page for links to pages on compiling aMule for various operating systems).

Configuring aMuleWeb

To use aMuleWeb, you first need to set several opions in aMule's Preferences notebook. On the "Remote Controls" page, you will need to:

  • Enable "Accept External Connections".
  • Enter a password for External Connections.
  • Enable webserver

You can also modifiy the default aMuleWeb port (4711) and External Connections port (4712) here as well, but if you do so, you will need to restart aMule for the changes to take effect.

(If you are running aMuled and don't want to use aMule to configure aMuleWeb, see the instructions below)

Next, you need to do is generate remote.conf, the file where aMuleWeb stores its configuration information. (It can be found in the .aMule directory.) Among other things, this file contains the port number which aMule uses for External Connections as well as the password needed to access aMule.

To create a remote.conf file, enter at the command line:

$ amuleweb -w

aMuleWeb will read the necessary configuration information from amule.conf and generate a remote.conf file, then exit.

Then start aMuleWeb normally:

$ amuleweb

You should now be able to open aMuleWeb in a browser by entering the URL (on the local system):

 http://localhost:4711

or, the with computer's hostname (locally or remote):

 http://hostname:4711:

If you want to run aMuleWeb on a different computer than aMule, just copy remote.conf to the .aMule directory on that computer, and change the hostname line accordingly.

NOTE: aMuleWeb uses cookies to store session information. Make sure that cookies are enabled in your browser.

Launching aMuleWeb

There are two options for launching aMuleWeb.

First, and preferred, is to enable aMuleWeb activation in aMule's preferences. When started, aMule (or aMuled) will launch amuleweb. Upon exit, aMuleWeb will be automatically terminated.

The second option is to run aMuleWeb manually by entering the "amuleweb" command in terminal.

Configuring aMuleWeb with aMuled

First, if aMuled is running, shut it down.

Then run:

 $ amuleweb -w

to generate a remote.conf file. You will need to edit these options in the [ExternalConnect] section:

  • AcceptExternalConnections=1 <-- To enable External Connections.
  • ECPassword=ca3c365274907c6fd527068788e14639 <-- MD5 string

You can then restart amuled and amuleweb.

NOTE: Passwords must be md5sum format. To generate an MD5sum for your password, run:

$ echo -n yourpasswordhere | md5sum | cut -d ' ' -f 1
ca3c365274907c6fd527068788e14639

NoteIf you get FATAL ERROR: Cannot find template: default it's because you didn't run make install. If you don't want to install aMule, copy the src/webserver/default/ directory into ~/.aMule/webserver/ (create it if needed). If you want any other template (probably php-default), copy it too. Then go back to the previous step.


aMuleWeb with older versions of aMule

For instructions for using aMuleWeb with aMule pre-2.0.0 final, see this page for archived material.

Standard ports

The ports can be set to anything, but by default aMule uses:

  • External Connections: 4712
  • amuleweb: 4711

Make sure you do not confuse the two; in the default configuration, it looks like this:

aMule --> [4712] --> aMuleWeb --> [4711] --> web browser

Template (skin) location

aMuleWeb looks for its files in a number of places:

  • In your home directory: $HOME/.aMule/webserver/[skin name]/
  • And at its install location, in this order (by default, /usr/local/share/amule/webserver if you compiled aMule, or /usr/share/amule/webserver if you installed it from a package).

Default template name is 'default'.

If, after installing aMule, aMuleWeb refuses to run because of not being able to load template:

  • Please report this situation to us, and then
  • Create the directories webserver/default in the .aMule subdirectory of your home directory, and copy the contents of the src/webserver directory there from the aMule tarball (ie, $HOME/.aMule/webserver/default).

aMuled and aMuleWeb as services

Although starting aMuleWeb by enabling it inaMule's preferences is the preferred method, you can also run aMuleWeb together with aMuled as as services by means of an init.d script. Here is an example:

/etc/init.d/amule

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/amuled
WEB=/usr/bin/amuleweb
NAME=amuled
DESC=amuled
RUNAMULE=no
USER=youramuleuser

test -x $DAEMON || exit 0

# Include amule defaults if available
if [ -f /etc/default/amule ] ; then
    . /etc/default/amule
fi
if [ "$RUNAMULE" != "yes" ];then
    echo "Amule not to be started. Edit /etc/default/amule first."
    exit 1
fi

set -e

case "$1" in
  start)
    echo -n "Starting $DESC: "
       su $USER -c "$DAEMON -f"
       while ! netstat -l -n -p -t | grep -q amuled ; do sleep 1 ; done
       su $USER -c "$WEB --quiet &"
    echo "$NAME."
    ;;
  stop)
    echo -n "Stopping $DESC: "
       killall --quiet --ignore-case $WEB
       killall --quiet --ignore-case $DAEMON
    echo "$NAME."
    ;;
  restart|force-reload)
    echo -n "Restarting $DESC: "
       killall --quiet --ignore-case $WEB
       killall --quiet --ignore-case $DAEMON
    sleep 1
       su $USER -c "$DAEMON -f"
       while ! netstat -l -n -p -t | grep -q amuled ; do sleep 1 ; done
       su $USER -c "$WEB --quiet &"
    echo "$NAME."
    ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0

Then just set that script to be run at start up. On Debian this would be doen with the following command:

update-rc.d amule defaults

Then, for the daemons to start you just have to create a file /etc/default/amule which contains a single line:

RUNAMULE=yes

Template language and development

Simply put, aMuleWeb templates are ordinary HTML files. In order to make them "interactive", server-side language is embedded inside. This language is scaled down dialect of PHP. More detailed information can be found on aMuleWeb_PHP.

Where to report problems and questions?

For Problems or Questions just report on http://forum.amule.org forum or join IRC channel #amule at irc.freenode.net

Other sources of information

Read the aMuleWeb man page, which is available in English, French, German, Hungarian and Spanish.

For further information read the aMuleWeb FAQ.