aMule Forum
English => aMule Help => Topic started by: prilmeie on January 28, 2005, 03:51:37 PM
-
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.
-
very nice thank you :))
should work for the poeple with daemon aswell if they change the script a little
suggestion is aswell to stop amule with amulecmd, dont know if this would be nicer then just a kill
amulecmd -f -c shutdown
stefanero
-
what is Xvfb? what if I don't have one?
-
Xvfb is a little x-server, which can be startet without login in
this is just needed when you run amule-gui version since it needs an x-server for the gui.
if you want to try amule-daemon you can simple leave this section out.
-
thanks stefanero!
-
Hi I got some problems:
- It seems to be not working, because i can't open the amule control webpage;
- I ran the script in console, it asked for passwords every time after a "su". I guess it is the reason why it didn't start when booting;
- I added "export LD_LIBRARY_PATH=/usr/local/wxWidgets-cvsu/lib:$LD_LIBRARY_PATH"before the line "case '$1' in" but it said some file not found.
-
Dependent on your Distribution (and the run level) you must include it in your rc.d. On Debian this is done with the update-rc.d command. Otherwise it isn't started at boot time.
Next, you must start the script as root. On boot time this is done automatically. There are some errors in the init script, I will post a corrected version:
#! /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=$DISPLAY_NUMBER $AMULE_BINARY &"
sleep 3
/bin/su - $USER -c "/usr/bin/nohup $AMULE_WEB_CLIENT -q -pw \"$CONNECTION_PASSWORD\" -apw $WEB_PASSWORD > /dev/null 2>&1 &"
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)"
/bin/rm -f /tmp/.X1-lock
echo "$NAME."
;;
restart|force-reload)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1
;;
esac
exit 0
-
I tried update-rc.d. It seems no such command in FC2. :--(
-
check if you have the special dirs
/etc/rc
rc rc0.d/ rc1.d/ rc2.d/ rc3.d/ rc4.d/ rc5.d/ rc6.d/
those dirs contain the init scripts for the actuall runlevels.
so just take your file and place it in there, and it should be fine.
but you can always test teh script if it works with running it "by hand" just make it executebla and start it up.
stefanero
-
I saw some files like "K12mysqld“, ”K40smartd", etc. so I thought they were created by some routine.
-
don't I put something in init.d?
-
I ran system-config-services in FC2, and there was a function called "add new service" in the "ation" menu. I add the service "amule", the name of which must be the same as the script file's name, and it says "warning! service amule does not support chkconfig". I don't know how to use this system-config-services.
-
well yes they where, but for your hand made script there is no runtime...
just put it in there...and you'll see it works...
stefanero
-
hi,
first of all I want to say THANX for posting this "How To". It is the only one I found that seemed to solve my problem. But it doesn't work completely for me, cause I've got the problem that amuleweb doesn't start at all. The script simply halts after amule has been started. I've changed the "sleep 3" to "sleep 1" with no effect. Since I've already opened a thread in the german forum, you may want to read it.
Guckst du hier: 8)
http://forum.amule.org/thread.php?sid=&postid=31181#post31181
-
init script wäre noch eine möglichkeit...da kannst es auch so einstellen das es gleich beim booten hochfährt...einfach mal init script oder autostart script suchen, hat es so 3-4 posts schon im forum ;)
hier mal einer: http://forum.amule.org/thread.php?threadid=5834
stefanero
-
Originally posted by stefanero
hier mal einer: http://forum.amule.org/thread.php?threadid=5834
stefanero
:D Nas ist ja mal was. Wenn der Thread mit mal nicht bekannt vorkommt. Klar, is ja auch mein eigener :P
Aber trotzdem danke dass du dich der Sache nochmal annimmst! Habs übrigens mittlerweile auch nicht rausgefunden warum er beim Systemstart nicht startet. Aber das macht auch nichts, ist zur Zeit eh nicht oft an und der Vorteil ist, dass ich so auch nicht automatisch den 12KB Upload hab. Hatte ganz vergessen dass man gar nciht verbunden sein muss zum uploaden...
cu
-
ENGLISH FORUM
-
/me hides :]
-
Yeah, you better hide, moderator that doesn't follow the rules :P
-
Here's what I did using amuled for a Ubuntu.
1 - created an 'amule' user, and configured amule (as that user) to accept external connections (using tcp, that was the only way I was successfull), put the password, configure anything else as amuled will use that configuration.
2- put the following script executable (with "chmod 777 amuled") as /etc/init.d/amuled
This script runs amuled under user 'amule'!
#!/bin/sh
#
PATH=/bin:/usr/bin:/usr/local/bin/:/sbin/:/usr/sbin/
DAEMON=/usr/bin/amuled
USER=amule
case "$1" in
start)
echo -n "Starting aMule : amuled"
export HOME=/home/amule/
start-stop-daemon --chuid $USER --user $USER --start --exec $DAEMON --background
export HOME=/root/
echo "."
;;
stop)
echo -n "Stopping aMule : amuled"
start-stop-daemon --stop --chuid $USER --user $USER --exec $DAEMON
echo "."
;;
reload)
echo "Not implemented."
;;
force-reload|restart)
sh $0 stop
sh $0 start
;;
*)
echo "Usage: /etc/init.d/amuled-server {start|stop|restart|force-reload|reload}"
exit 1
;;
esac
exit 0
3 - linked it to /etc/rc2.d/S80amuled (with "ln -s /etc/init.d/amuled /etc/rc2.d/S80amuled" )
4 - amuled starts automatically now. If I ever need to restart I do "sudo /etc/init.d/amuled restart", sudo "/etc/init.d/amuled" will return all possible actions.
It's amazing!!! I love amuled!!
-
For Mandrake/Mandriva, put the script in /etc/init.d. Then use chkconfig or mcc (System/services) to run the service in the desired boot options.
This xwill create the k**amuled alias in the /etc/rc.* directory and run them in the corresponding option.
-
For chkconfig, just be sure that you have something like this at the begining of your script :
# chkconfig: 345 99 01
Where 345 are the runlevel where you want your script to be ran
99 is the position at startup and 01 at shutdown