First of all: This is no help request. I want to share my init script with you.
For this to work, you need a working amule installation and Xvfb (Described in the tutorial). aMule and amuleweb must be already in a runnable status.
I am using Debian's stile of init scripts.
Two files: /etc/init.d/amule and /etc/default/amule; The first is the init script, which should work without any change (Maybe you have to change the amule path because I compiled my own version and installed it to /usr/local). The second file containes variable declarations which are site dependent, to be specific, it contains the passwords. Maybe there is a more secure configuration, but I am not an amule crack. And it is sufficient for my site (Where I am the only user).
Let's start with /etc/default/amule:
# The password to connect to the web client with your browser
WEB_PASSWORD=
# The amule connection password
CONNECTION_PASSWORD=
# The user to run Xvfb, amule and amuleweb, here the user name is
# amule
USER=amule
# XVFB server settings, taken from the amule wiki - Don't change
X_OPTIONS="-screen 0 640x480x16"
DISPLAY_NUMBER=":1"
##
Now /etc/init.d/amule
#! /bin/sh
XVFB_DAEMON=/usr/bin/X11/Xvfb
AMULE_BINARY=/usr/local/bin/amule
AMULE_WEB_CLIENT=/usr/local/bin/amuleweb
DESC="amule on Xvfb"
NAME=amule
# read configuration options
if [ -f "/etc/default/$NAME" -a ! -d "/etc/default/$NAME" ] ; then
. /etc/default/$NAME
fi
USER_UID=`/usr/bin/id -u $USER`
if [ ! -f $XVFB_DAEMON ] ; then
echo Cannot find $XVFB_DAEMON
echo Exiting...
exit 1
fi
if [ ! -f $AMULE_BINARY ] ; then
echo Cannot find $AMULE_BINARY
echo Exiting...
exit 1
fi
if [ ! -f $AMULE_WEB_CLIENT ] ; then
echo Cannot find $AMULE_WEB_CLIENT
echo Exiting...
exit 1
fi
case "$1" in
start)
echo -n "Starting $DESC: "
# start here...
/bin/su - $USER -c "$XVFB_DAEMON $DISPLAY_NUMBER $X_OPTIONS &"
/bin/su - $USER -c "DISPLAY=:1 $AMULE_BINARY &"
sleep 3
/bin/su - $USER -c "$AMULE_WEB_CLIENT -q -pw \"$CONNECTION_PASSWORD\" -apw $WEB_PASSWORD &"
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
/usr/bin/pkill -9 -x -u $USER_UID "(amuleweb)"
/usr/bin/pkill -x -u $USER_UID "(amule)"
/usr/bin/pkill -x -u $USER_UID "(Xvfb)"
echo "$NAME."
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
Comments / Further enhancements / hints are appreciated.