Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
mldonkey init.d script
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
Bushmann
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2002
Posts: 137
Location: Germany

PostPosted: Fri Aug 01, 2003 12:59 am    Post subject: mldonkey init.d script Reply with quote

Hi, emerge mldonkey yesterday (it's great) and found out there are two things missing:

1.) init.d script to start it automatically after boot
2.) option to reduce/increas bandwith easily per commandline.

so what I did is look into this (and other) forums and created a first little script on my own, based on the ideas of Wilhelm,
b-o-s-s and donk

Now here it is:

/etc/init.d/mldonkey
Code:
#!/sbin/runscript

opts="start stop restart slow fast"

depend() {
   need net
}

start() {
   ebegin "Starting mldonkey"
   if [ ! -d ${MLHOME}/${MLDIR} ]
   then
      einfo "Directory ${MLHOME}/${MLDIR} not existing, trying to create..."
      su ${MLUSER} -c "mkdir ${MLHOME}/${MLDIR}"
      if [ ! -d ${MLHOME}/${MLDIR} ]
      then
         eerror "Directory ${MLHOME}/${MLDIR} could not be created!"
         return 1
      fi
      einfo "...ok!"
   fi
   cd ${MLHOME}/${MLDIR}/
   start-stop-daemon --quiet --start \
   --exec /usr/bin/mlnet -x /usr/bin/mlnet -c ${MLUSER} &>/dev/null &
   eend $?
}

stop() {
   ebegin "Stopping mldonkey"
   start-stop-daemon --stop -x /usr/bin/mlnet
   eend $?
}

restart() {
   svc_stop
   svc_start
}

slow() {
   ebegin "Reducing bandwidth to ${MLLOWDOWN}k/${MLLOWUP}k"

   wget http://localhost:${MLPORT}/submit?q=set+max_hard_download_rate+${MLLOWDOWN} -q -O - > /dev/null

   wget http://localhost:${MLPORT}/submit?q=set+max_hard_upload_rate+${MLLOWUP} -q -O - > /dev/null

   eend $?
}

fast() {
   ebegin "Increasing bandwidth to ${MLHIGHDOWN}k/${MLHIGHUP}k"

   wget http://localhost:${MLPORT}/submit?q=set+max_hard_download_rate+${MLHIGHDOWN} -q -O - > /dev/null

   wget http://localhost:${MLPORT}/submit?q=set+max_hard_upload_rate+${MLHIGHUP} -q -O - > /dev/null

   eend $?
}


the config file is
/etc/conf.d/mldonkey
Code:

# config file for mldonkey control script

# owner of mlnet process, hast to be created
MLUSER="p2p"

# home dir of owner, has to be there
MLHOME="/home/test"

# subdir if any (will be created if not existing)
MLDIR=".mldonkey"

# bandwidth control, values in kb/s
MLLOWDOWN="6"
MLLOWUP="2"
MLHIGHDOWN="30"
MLHIGHUP="10"

# port for webinterface, usually 408
MLPORT="4080"


Actually I just changed some variables and exchanged curl with wget from donkey and put it in a little script, but I think it could be useful, and something like this should be in the ebuild, what do you think?
Back to top
View user's profile Send private message
b-o-s-s
n00b
n00b


Joined: 14 Jul 2003
Posts: 36

PostPosted: Fri Aug 01, 2003 12:20 pm    Post subject: Reply with quote

Hi Bushmann,

your script looks very nice! It's just like what I wanted to do, but I was too lazy too figure it out exacty.... Thanks for noticing me, I'll try it tonight.

But one point I don't understand. You use the config file '/etc/conf.d/mldonkey'. How does this work? Is it a property of runscript to look automatically in '/etc/conf.d/' for a configfile named after the script? This really interests me.

And of course it would be very nice if a script like yours was in the ebuild. I think most people emerging mldonkey will want to start it at boot-time...
Back to top
View user's profile Send private message
Bushmann
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2002
Posts: 137
Location: Germany

PostPosted: Fri Aug 01, 2003 1:35 pm    Post subject: Reply with quote

yes that's the way it goes...
I have to admin I'm also n00b in this things, but it seems to work ;) and I have submitted an ebuild as bug request, so perhaps with some help we'll make it :)

at the moment when you emerge my ebuild, it creates a special user p2p with
homedirectory /home/p2p (could be changed though), and starting the script results in executing mldonkey with owner p2p. The files are either directly stored in /home/p2p, or if you like in another dir like /home/p2p/.mldonkey (you could perhaps also use other filesharing clients with user p2p, so that could make sense and thats the way I do it at the moment).

The cool feature I copied from the donk script is that you can easily tell mldonkey to use much or little bandwidth, so if you need your line (probably for gaming or if other ppl at your line begin to protest, as in my case ;) just do /etc/init.d/mldonkey slow

And, you can of course tell your PC to start mldonkey every time you boot with rc-update add mldonkey default

so for me at the moment that's all I need :)
Back to top
View user's profile Send private message
Wilhelm
Tux's lil' helper
Tux's lil' helper


Joined: 27 May 2003
Posts: 149

PostPosted: Fri Aug 01, 2003 2:23 pm    Post subject: Reply with quote

Haven't tested it yet but it seems to be a nice script that should work.

However as explained in my other posts mldonkey has issues that cannot be scripted away. I'm still waiting for a new update of mldonkey which makes HTML downloading work properly etc..

Anyhow hopefully the ebuild will be fixed soon
Back to top
View user's profile Send private message
Bushmann
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2002
Posts: 137
Location: Germany

PostPosted: Fri Aug 01, 2003 3:27 pm    Post subject: Reply with quote

I'm sorry I don't understand your problem, what exactly doesn't work with mldonkey/HTML? I'm testing this script at the moment and it seems to work with no problems, so what should I test/try?
Back to top
View user's profile Send private message
Wilhelm
Tux's lil' helper
Tux's lil' helper


Joined: 27 May 2003
Posts: 149

PostPosted: Sun Aug 03, 2003 7:57 pm    Post subject: Reply with quote

2 things happen with my mldonkey that suck.

1. Config get's fucked unless you do it with the HTML tool.

2. After a while the HTML tool gives me a Document doesn't contain data error in mozilla.
Back to top
View user's profile Send private message
meyerm
Veteran
Veteran


Joined: 27 Jun 2002
Posts: 1311
Location: Munich / Germany

PostPosted: Tue Aug 05, 2003 10:19 pm    Post subject: Reply with quote

Just great your scripts. :-D

Thanks
Back to top
View user's profile Send private message
Bushmann
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2002
Posts: 137
Location: Germany

PostPosted: Fri Aug 08, 2003 10:11 am    Post subject: Reply with quote

yeah, but using the html interface with wget should work, shouldn't it?
the thing with mozilla didn't appear for me, strange.
btw., there's now a new ebuild with the changes, it creates a new user p2p and installs the init.d script, starting it makes mldonkey run in /home/p2p/.mldonkey. Btw. I find it comfortable to ln -s .mldonkey/incoming.
You could check it out, but it seems to work just fine.
Back to top
View user's profile Send private message
Rosjahh
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 182
Location: Below sealevel

PostPosted: Sat Aug 09, 2003 12:17 pm    Post subject: Reply with quote

Hi, I don't know if anybody still looks here. The script looks great. But for some reason I cannot get it to work here. When I try to start mldonkey I get the following output. A "ps -a |grep ml" shows that mlnet and mldonkey are not running at all.

Code:
rosj / # /etc/init.d/mldonkey start
/sbin/runscript.sh: line 1: add_suffix: command not found
/sbin/runscript.sh: line 1: add_suffix: command not found
/sbin/runscript.sh: line 1: add_suffix: command not found
/sbin/runscript.sh: line 1: add_suffix: command not found
 * Starting mldonkey...                                                   [ ok ]
rosj / #


This is the /etc/conf.d/mldonkey i use:

Code:
# config file for mldonkey control script

# owner of mlnet process, hast to be created
MLUSER="p2p"

# home dir of owner, has to be there
MLHOME="/var/p2p"

# subdir if any (will be created if not existing)
MLDIR=".mldonkey"

# bandwidth control, values in kb/s
MLLOWDOWN="30"
MLLOWUP="5"
MLHIGHDOWN="100"
MLHIGHUP="10"

# port for webinterface, usually 4080
MLPORT="4080"


The user p2p exists and its folder does too. Permissions are just as the other init scripts and configuration files in /etc/conf.d .

I've been working with the script. But to be honest, I don't understand everything of it. Can anybody help me ?


Regards
Back to top
View user's profile Send private message
mo-ca
Guru
Guru


Joined: 17 Feb 2003
Posts: 313
Location: Near Dresden, Germany

PostPosted: Sat Aug 09, 2003 1:11 pm    Post subject: Reply with quote

hi,

you script looks really nice, but i'm having 1 big problem:

Code:

su27 init.d # ./mldonkey start
 * ERROR:  "./mldonkey" has syntax errors in it; not executing...


thats all i get (i just copied your script and changed values in the config)

any suggestions ?
_________________
Registred Linux User #239348
Back to top
View user's profile Send private message
Rosjahh
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 182
Location: Below sealevel

PostPosted: Sat Aug 09, 2003 1:20 pm    Post subject: Reply with quote

mo-ca, are you sure that you copied the entire script ? In my case, the first time I copied it, I missed the "}" at the bottom. I think it should be something like that.

Somehow, I don't get the funny errors anymore. I don't know why. Mldonkey also starts now as it should. I think that had to do with a configuration error in downloads.ini that I now resolved.
Back to top
View user's profile Send private message
kamui
n00b
n00b


Joined: 22 Jul 2003
Posts: 74
Location: SoCal, USA

PostPosted: Mon Aug 11, 2003 9:08 am    Post subject: Reply with quote

I am also have problems using this script, I have read thought it a number of times and am quite sure that I have it copyed over correctly. When I run the scripts it reads as follows:

Code:
bash-2.05b# ./mldonkey start
 * Starting mldonkey...
start-stop-daemon: need at least one of --exec, --pidfile, --user or --name
Try `start-stop-daemon --help' for more information.                      [ ok ]


I assume it is having problems with this section of code:

Code:
  cd ${MLHOME}/${MLDIR}/
  start-stop-daemon --quiet --start \
  --exec /usr/bin/mlnet -x /usr/bin/mlnet -c ${MLUSER} &>/dev/null &
  eend $?


This does not work for me and if I try to run the script again it tells me that it is still running and stop will not kill it as well so I end up zaping it out.

One thing I did notice is that the first time I ran this script it did make the .mldonkey dir in my p2p user dir. I am using mldonkey-2.5.3.ebuild. Any and all suggestions are greatly welcome! Thanks in Advance.
_________________
~kamui~
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Mon Aug 11, 2003 9:35 am    Post subject: Reply with quote

personaly I setup a mldonkey user account, and in /home/mldonkey/.mldonkey I got:

chkmldonkey:
Code:

#!/bin/bash
BASEDIR=/home/mldonkey/.mldonkey/
umask 0002

cd $BASEDIR
if test -r mldonkey.pid; then
    PID=$(cat mldonkey.pid)
    if $(kill -CHLD $PID >/dev/null 2>&1)
    then
        exit 0
    fi
fi
nice --adjustment=20 nohup ./startmldonkey &


and
startmldonkey
Code:

#!/bin/bash
umask 0002
echo $$ > mldonkey.pid
exec mldonkey


and put chkmldonkey in crontab :)
Back to top
View user's profile Send private message
kamui
n00b
n00b


Joined: 22 Jul 2003
Posts: 74
Location: SoCal, USA

PostPosted: Mon Aug 11, 2003 8:17 pm    Post subject: Reply with quote

Could you list what you added into your crontab. And also where you are keeping chkmldonkey? Sorry but I am still kinda new to this and am trying to learn by example )

Thanks much!
_________________
~kamui~
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Tue Aug 12, 2003 8:57 am    Post subject: Reply with quote

the scripts go in /home/mldonkey/.mldonkey
(the .mldonkey directory is created first time you run mldonkey, though you can just stuff the scripts there and the config files will be created in that directory when you run it).

you'll need to create the .mldonkey directory, and add the user mldonkey. (you'll also need to add the user to the cron group if you want to use crontab).

this is my crontab entry:
0-59/6 * * * * /home/mldonkey/.mldonkey/chkmldonkey &>/dev/null
Back to top
View user's profile Send private message
kamui
n00b
n00b


Joined: 22 Jul 2003
Posts: 74
Location: SoCal, USA

PostPosted: Thu Aug 14, 2003 6:33 am    Post subject: Reply with quote

Yay, it worked great neuron. This seems to be alot easier but that just my 2ct. If you can't get the other script to work this one is great!

Anyway, thanks again!
_________________
~kamui~
Back to top
View user's profile Send private message
Wilhelm
Tux's lil' helper
Tux's lil' helper


Joined: 27 May 2003
Posts: 149

PostPosted: Thu Aug 21, 2003 5:31 pm    Post subject: Reply with quote

I saw that your script isincorporated in the ebuild now of 2.5.3. At least a slightly modified version.

Anyhow i've taken some time to get it all working and it works great as far as i can tell.

The problems i had concerning the config iles being overridden was due to the fact that i needed to stop mldonkey and remover *~ after any edit.

Hopefully it won't start spitting up problems.

Good work bushman
Back to top
View user's profile Send private message
razamatan
Apprentice
Apprentice


Joined: 28 Feb 2003
Posts: 160

PostPosted: Fri Aug 22, 2003 5:00 am    Post subject: Reply with quote

i can use any user instead of p2p right??
_________________
a razamatan doth speaketh,
"Never attribute to malice, that which can be adequately explained by stupidity"
Back to top
View user's profile Send private message
Bushmann
Tux's lil' helper
Tux's lil' helper


Joined: 30 Aug 2002
Posts: 137
Location: Germany

PostPosted: Fri Aug 22, 2003 9:42 pm    Post subject: Reply with quote

yes you can!

you can also change the directory, so that the files are not hidden under .mldonkey
But I though that makes sense if someone has more than one p2p client, so you could have them all under /home/p2p.

To your syntax errors: I will see if I can find the mistake. I also submitted new version of the script, it will soon be included in the ebuild.
Back to top
View user's profile Send private message
gdc34
n00b
n00b


Joined: 29 Mar 2003
Posts: 12
Location: London, UK

PostPosted: Sun Sep 14, 2003 11:29 pm    Post subject: Reply with quote

Hi, I'm using the script bundled with the latest ebuild (2.5.3-rc1) and I get this error:

/etc/init.d/mldonkey start

* Starting mldonkey...
renice: 1001: getpriority: No such process [ !! ]

(N.B. Obviously the first time I ran it, it also gave out the creating directory etc, but then this same error came).

Any ideas? I would be really grateful for some help.
Back to top
View user's profile Send private message
gdc34
n00b
n00b


Joined: 29 Mar 2003
Posts: 12
Location: London, UK

PostPosted: Mon Sep 15, 2003 3:38 pm    Post subject: Reply with quote

Ok, I've looked into it a bit more, though I'm struggling somewhat since I don't know anything about bash scripting or how linux operates (still a noob :( ).

When I comment out the lines to do with renice (which is presumbly non essential- although helpful) like this:

Code:


#!/sbin/runscript
                                                                                                                   
opts="start stop restart slow fast"
                                                                                                                   
depend() {
        need net
}
                                                                                                                   
start() {
        ebegin "Starting mldonkey"
        if [ ! -d ${BASEDIR}/${SUBDIR} ]
        then
                einfo "Directory ${BASEDIR}/${SUBDIR} not existing, trying to create..."
                su ${MLUSER} -c "mkdir ${BASEDIR}/${SUBDIR}"
                if [ ! -d ${BASEDIR}/${DIR} ]
                then
                        eerror "Directory ${BASEDIR}/${SUBDIR} could not be created!"
                        return 1
                fi
                einfo "...ok!"
        fi
        cd ${BASEDIR}/${SUBDIR}/
        start-stop-daemon --quiet --start -c ${USER}  \
        -x /usr/bin/mlnet &>${LOG} &
        sleep 5
      # renice ${NICE} -u ${USER} >/dev/null
        eend $?
}


(N.B. I've only included the startup portion of the script (clearly) since that is what appears to be going wrong)

So when I comment out the 'renice' line:
/etc/init.d/mldonkey start
doesn't give any errors.
However I can't use the web interface, nor is it (mlnet) running when I check using:
ps -A
Furthermore, if I try and do:
/etc/init.d/mldonkey stop
I get
* Stopping mldonkey - please wait...
No /usr/bin/mlnet found running; none killed. [ ok ]

So why are these lines not working for me?
Code:
fi
        cd ${BASEDIR}/${SUBDIR}/
        start-stop-daemon --quiet --start -c ${USER}  \
        -x /usr/bin/mlnet &>${LOG} &


Since this is part of the stock scripts (which must be 'correct') I guess the problem is how I've set up my system etc.

BTW, if I just start up mldonkey by typing mlnet at the command prompt, it works fine...

Any ideas?
Back to top
View user's profile Send private message
n0n
Guru
Guru


Joined: 13 Jun 2002
Posts: 355

PostPosted: Mon Sep 15, 2003 5:42 pm    Post subject: Reply with quote

One thing which could cause problems is that if anyone's using mldonkey user authentication, the web commands won't work.

Also, it would probably make a lot more sense to use the telnet interface for sending mldonkey commands rather than burdening everything down with the web interface:
Code:
echo -e "set max_hard_download_rate=${MLLOWDOWN}\nq" | nc localhost 4000

Or some such...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum