aMule Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're back! (IN POG FORM)

Pages: [1] 2

Author Topic: Amule remote connection init script  (Read 9265 times)

prilmeie

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
Amule remote connection init script
« 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:
Code: [Select]
# 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

Code: [Select]
#! /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.
Logged
I have a problem with alcohol - two hands, one mouth

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Amule remote connection init script
« Reply #1 on: January 28, 2005, 04:25:36 PM »

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
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

sah

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • http://sah-lee.51.net
Re: Amule remote connection init script
« Reply #2 on: January 31, 2005, 09:00:14 AM »

what is Xvfb? what if I don't have one?
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Amule remote connection init script
« Reply #3 on: January 31, 2005, 09:07:43 AM »

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.
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

sah

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • http://sah-lee.51.net
Re: Amule remote connection init script
« Reply #4 on: January 31, 2005, 09:31:11 AM »

thanks stefanero!
Logged

sah

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • http://sah-lee.51.net
Re: Amule remote connection init script
« Reply #5 on: February 01, 2005, 05:10:05 AM »

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.
Logged

prilmeie

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
Re: Amule remote connection init script
« Reply #6 on: February 01, 2005, 07:48:19 AM »

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:
Code: [Select]
#! /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
Logged
I have a problem with alcohol - two hands, one mouth

sah

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • http://sah-lee.51.net
Re: Amule remote connection init script
« Reply #7 on: February 01, 2005, 08:34:57 AM »

I tried update-rc.d. It seems no such command in FC2. :--(
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Amule remote connection init script
« Reply #8 on: February 01, 2005, 08:46:26 AM »

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
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

sah

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • http://sah-lee.51.net
Re: Amule remote connection init script
« Reply #9 on: February 01, 2005, 09:40:39 AM »

I saw some files like "K12mysqld“, ”K40smartd", etc. so I thought they were created by some routine.
Logged

sah

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • http://sah-lee.51.net
Re: Amule remote connection init script
« Reply #10 on: February 01, 2005, 09:42:15 AM »

don't I put something in init.d?
Logged

sah

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 21
    • http://sah-lee.51.net
Re: Amule remote connection init script
« Reply #11 on: February 01, 2005, 10:02:53 AM »

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.
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Amule remote connection init script
« Reply #12 on: February 01, 2005, 11:14:59 AM »

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
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."

MiniMe

  • Approved Newbie
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
amuleweb doesn't start
« Reply #13 on: April 17, 2005, 11:59:58 PM »

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
Logged

stefanero

  • Some Support
  • Developer
  • Hero Member
  • *****
  • Karma: 8
  • Offline Offline
  • Posts: 4235
Re: Amule remote connection init script
« Reply #14 on: June 06, 2005, 03:25:13 PM »

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
Logged
In its default setup, Windows XP on the Internet amounts to a car
parked in a bad part of town, with the doors unlocked, the key in
the ignition and a Post-It note on the dashboard saying, "Please
don't steal this."
Pages: [1] 2