Multi user

From AMule Project FAQ
Revision as of 01:42, 13 December 2008 by Woutermense (Talk | contribs)

Jump to: navigation, search

Howto setup aMule for multi-user purposes

This article is made to show you how to make optimal use of your internet bandwidth by sharing aMule with multiple users. Often when an internet connection is shared between many persons bandwidth problems occur. People want to download or share files. So p2p applications are installed and the downloadfest can begin. Very soon all upload bandwidth is consumed by these applications and browsing and other useful things you can do with the internet become impossible or really annoying.

Basically, bandwidth restriction of users is a nuisance. Users are not happy because they have too little (in their opinion). A good idea would be to share the same p2p application with all the users. This not only makes it possible to control the upload bandwidth that is spent to p2p, also it can save a lot of energy because only 1 computer has to be turned on all the time to share files.

So what do we need to attain this goal? This is a short list of requirements:

  • Server to run amuled on.
  • aMuleGUI clients compiled for the OS's that different users have installed.
  • A method of handling ed2k:// links remotely.
  • Optional some method of traffic shaping.

Basic server configuration

If you already have a server, read on, else skip ahead to the server hardware example. I only have experience with the OpenSuSE 10.3 operation system so I will use this in my examples to explain things.

aMule user

Firstly it is important to always run the aMuleD in a restricted environment. So we create a user for aMule. Fire up Yast and get to the user management. User management.PNG

Give the user a name, set a password, do not tick the 'Disable User Login' option. Adding amule user.PNG

Bootscripts

Next we need initscripts to get aMule started every time we boot our server. A good example for OpenSuSE is:

#!/bin/sh

# Check for missing binaries (stale symlinks should not happen)
# Note: Special treatment of stop for LSB conformance
DAEMON=/usr/bin/amuled
DAEMON_CMD="$DAEMON -f"
DAEMON_DESC="aMule daemon"
DAEMON_NAME="amuled"
test -x $DAEMON || { echo "$DAEMON not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

WEB=/usr/bin/amuleweb
WEB_CMD="$WEB --quiet &"
WEB_DESC="aMule webserver"
test -x $WEB || { echo "$WEB not installed"; 
	if [ "$1" = "stop" ]; then exit 0;
	else exit 5; fi; }

USER=amule
DESC="aMule daemon and webserver"
NAME="amuled"

# Source LSB init functions
. /etc/rc.status

# Reset status of this service
rc_reset

case "$1" in
	start)
		echo -n "Starting $DAEMON_DESC "
		su $USER -c "$DAEMON_CMD" > /dev/null
		rc_status -v

		echo -n "Waiting for $DAEMON_DESC to finish initialization "

		while ! netstat -l -n -p -t | grep -q $NAME ; do sleep 1 ; echo 1 ; done
		rc_status -v
	
		echo -n "Starting $WEB_DESC "
		su $USER -c "$WEB_CMD" > /dev/null 2>&1
		rc_status -v
		;;
		
 	stop)
		echo -n "Shutting down $WEB_DESC "
		/sbin/killproc -TERM $WEB
		rc_status -v

		echo -n "Shutting down $DAEMON_DESC "
		/sbin/killproc -TERM $DAEMON
		rc_status -v
		;;
		
	try-restart|condrestart)
		## Do a restart only if the service was active before.
		## Note: try-restart is now part of LSB (as of 1.9).
		## RH has a similar command named condrestart.
		if test "$1" = "condrestart"; then
			echo "${attn} Use try-restart ${done}(LSB)${attn} rather than c ondrestart ${warn}(RH)${norm}"
		fi
		$0 status
		if test $? = 0; then
			$0 restart
		else
			rc_reset	# Not running is not a failure.
		fi
		# Remember status and be quiet
		rc_status
		;;
		
	restart)
		## Stop the service and regardless of whether it was
		## running or not, start it again.
		$0 stop
		$0 start

		# Remember status and be quiet
		rc_status
		;;
		
	force-reload)
		## Signal the daemon to reload its config. Most daemons
		## do this on signal 1 (SIGHUP).
		## If it does not support it, restart the service if it
		## is running.

		echo -n "Reload service $DESC "
		## if it supports it:
		
		## aMule does not support reload

		## Otherwise:
		$0 try-restart
		rc_status
		;;
		
	reload)
		## Like force-reload, but if daemon does not support
		## signaling, do nothing (!)

		# If it supports signaling:
		
		## aMule does not support reload
		
		## Otherwise if it does not support reload:
		rc_failed 3
		rc_status -v
		;;
		
	status)
		echo -n "Checking for service aMule daemon"
		## Check status with checkproc(8), if process is running
		## checkproc will return with exit status 0.

		# Return value is slightly different for the status command:
		# 0 - service up and running
		# 1 - service dead, but /var/run/  pid  file exists
		# 2 - service dead, but /var/lock/ lock file exists
		# 3 - service not running (unused)
		# 4 - service status unknown :-(
		# 5--199 reserved (5--99 LSB, 100--149 distro, 150--199 appl.)
		
		# NOTE: checkproc returns LSB compliant status values.
		/sbin/checkproc $DAEMON
		# NOTE: rc_status knows that we called this init script with
		# "status" option and adapts its messages accordingly.
		rc_status -v
		
		echo -n "Checking for service aMule webserver"
		/sbin/checkproc $WEB
		rc_status -v
		;;

	*)
		echo "Usage: $0 {start|stop|status|try-restart|restart|force-reload|r eload}"
		exit 1
		;;
	esac
rc_exit

aMule

Also, don't forget to install the aMule Daemon (and the aMule webservice).

Server hardware example

So you don't have a server yet and want to build one. Here are some things to look out for. First of all I wanted the server to be as energy efficient as possible, while still having enough performance to run aMule.

aMuleGUI clients

Remote handling of ed2k:// links

Traffic shaping

aMuleD configuration

Server configuation

Traffic shaping configuration example

The aMule web interface

Open your firewalls

If you own a domain name