UbuntuThis forum is for the discussion of Ubuntu Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi! I'm using Kubuntu 7.10, and I was trying to run MLDonkey (manually compiled) as a daemon. In order to do that I took the init.d script from an Ubuntu package, and put it in /etc/init.d. I also copied /etc/default/mldonkey-server with some options, which are read by the init.d script.
which was the way the posinst script of the package registered the init.d script.
The script is quite simple and it works correctly running it with sudo:
Code:
sudo /etc/init.d/mldonkey-server start
it also works when I manually stop it, and even when the systems shutdown I'm certain the script is called. However, it seems that the system doesn't call the script at startup, since the mlnet daemon doesn't show up in ps -ef.
Maybe the script IS being called, but execution of mlnet is failing for some reason, which would be strange because I can run the script manually... in what log can I check if the script is correctly run? It prints "Starting MLDonkey: mlnet.", so I may be able to find it.
System startup links for /etc/init.d/mldonkey-server already exist.
Then rebooted, and the result was the same. What else could be going wrong? Is there any log to check? How does init.d work, the sole fact that the script is there and has the following text on it (I guess this is what's done by update-rc.d) is what should make it work?
Code:
### BEGIN INIT INFO
# Provides: mldonkey-server
# Required-Start: $network
# Required-Stop: $network
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Server for the mldonkey peer-to-peer downloader.
# Description: Server for the mldonkey peer-to-peer downloader.
### END INIT INFO
Or are the names of the scripts that must be called somewhere else?
My runlevel is 2. Not sure what's this yet but I'll get into it.
Here is the piece of the script you were looking for, I think:
Code:
case "$1" in
start|force-start)
echo -n "Starting $DESC: $NAME"
if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then
echo " configuration file prevent $NAME to be started (use force-start)."
exit 0
fi
if [ -z "$MLDONKEY_DIR" ] || [ ! -d "$MLDONKEY_DIR" ]; then
if [ -z "$MLDONKEY_DIR" ]; then
MLDONKEY_DIR="(unset)"
fi
echo " $MLDONKEY_DIR is not a valid directory."
exit 1
fi
if [ ! -f "$MLDONKEY_DIR/downloads.ini" ]; then
echo " $MLDONKEY_DIR/downloads.ini is not a valid file."
exit 1
fi
USER=`/usr/bin/stat --format="%U" "$MLDONKEY_DIR/downloads.ini"`
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --user $USER"
start-stop-daemon --start $WRAPPER_OPTIONS \
--pidfile $PIDFILE --background --exec $EXEC \
-- -pid $PIDDIR > $LOGFILE 2>&1
echo "."
;;
According to the definition of $LOGFILE, that log is in /var/log/mldonkey/mlnet.log. However that file is empty, and the program is currently logging in ~/.mldonkey/mlnet.log. Is that because only the start-stop-daemon outputs are redirected to the $LOGFILE or because the program later assigns a different file to log into?
The problem is solved but I still had this doubts Thanks!
Sorry, not working again... I don't think I did anything. Restarted 3 times in a row and the executable mlnet is not running. However, I'm not certain that the script is not being run.
What I know is that /var/log/mldonkey/mlnet.log is not even being created. The logfile to which the program switchs to doesn't get created either.
The symlinks are still there...
Here's the whole script, just in case:
Code:
#!/bin/sh
#
# Original file :
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.9.1 08-Apr-2002 miquels@cistron.nl
#
#
# This file has been rewritten by Sylvain Le Gall <gildor@debian.org>
# and Samuel Mimram <smimram@debian.org> for the mldonkey package.
#
### BEGIN INIT INFO
# Provides: mldonkey-server
# Required-Start: $network
# Required-Stop: $network
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Server for the mldonkey peer-to-peer downloader.
# Description: Server for the mldonkey peer-to-peer downloader.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=mlnet
EXEC=/usr/local/bin/$NAME
DESC="MLDonkey"
CONFIG=/etc/default/mldonkey-server
PIDDIR=/var/run/mldonkey
PIDFILE=$PIDDIR/$NAME.pid
LOGFILE=/var/log/mldonkey/$NAME.log
test -x $WRAPPER || exit 0
test -e $CONFIG || exit 0
set -e
. $CONFIG
# /var/run might be on tempfs, see #354701.
if [ ! -d /var/run/mldonkey ]; then
mkdir -m 755 /var/run/mldonkey
fi
if [ -n "$MLDONKEY_USER" ] && [ -n "$MLDONKEY_GROUP" ]; then
chown $MLDONKEY_USER:$MLDONKEY_GROUP /var/run/mldonkey
fi
WRAPPER_OPTIONS=""
# Set configuration value, from CONFIG
if [ -n "$MLDONKEY_USER" ] && [ -n "$MLDONKEY_GROUP" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chuid $MLDONKEY_USER:$MLDONKEY_GROUP"
fi
if [ -n "$MLDONKEY_DIR" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chdir $MLDONKEY_DIR"
fi
if [ -n "$MLDONKEY_GROUP" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --group $MLDONKEY_GROUP"
fi
if [ -n "$MLDONKEY_UMASK" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --umask $MLDONKEY_UMASK"
fi
if [ -n "$MLDONKEY_NICENESS" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --nicelevel $MLDONKEY_NICENESS"
fi
case "$1" in
start|force-start)
echo -n "Starting $DESC: $NAME"
if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then
echo " configuration file prevent $NAME to be started (use force-start)."
exit 0
fi
if [ -z "$MLDONKEY_DIR" ] || [ ! -d "$MLDONKEY_DIR" ]; then
if [ -z "$MLDONKEY_DIR" ]; then
MLDONKEY_DIR="(unset)"
fi
echo " $MLDONKEY_DIR is not a valid directory."
exit 1
fi
if [ ! -f "$MLDONKEY_DIR/downloads.ini" ]; then
echo " $MLDONKEY_DIR/downloads.ini is not a valid file."
exit 1
fi
USER=`/usr/bin/stat --format="%U" "$MLDONKEY_DIR/downloads.ini"`
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --user $USER"
start-stop-daemon --start $WRAPPER_OPTIONS \
--pidfile $PIDFILE --background --exec $EXEC \
-- -pid $PIDDIR > $LOGFILE 2>&1
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
start-stop-daemon --stop --oknodo --pidfile $PIDFILE
echo "."
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|force-start}" >&2
exit 1
;;
esac
exit 0
Here I modified some things. First the mldonkey working dir. Then the user and group the process will be run under. They recommend (at least is the default option) to create a new 'mldonkey' user/group and run it under those. However if I did that I couldn't use the working directory I wanted. I could move it to /var/lib/mldonkey, but the incoming, temp and share have to be in the home partition, because it's where the free space is. So I could create a folder with mldonkey permisions inside my /home/neoakiraz home directory. But it's kind of messy. Maybe I could create a home folder for mldonkey, but I really didn't see the point (or I didn't understood the need) of creating another user, since mine is the only real account. I also modified the niceness, because I noticed how sometimes the process it's about 5-7% of my CPU, so I lowered it's priority.
I hope I explained my self well Thanks for your help... and patience!
When running daemon processes, it is considered safer to have a user & group that is only used for that daemon.
This helps you to protect your system in the event that the daemon process has a security flaw, as the daemon is run as a user that has no access to anything else (whether it's system files or your own personal data).
This is one of the things that helps keep UNIX / Linux secure.
I'm glad that the daemon seems to be working normally now, the only other suggestion I considered was to create a seperate logfile to ensure that the script is reaching set points during system startup.
It is also possible that the daemon is starting during boot, but then terminating at some point.
If you are still experiencing problems, you might want to take a look at your system logs.
When running daemon processes, it is considered safer to have a user & group that is only used for that daemon.
Great to know that. So I'll try creating the user and group again. And then I guess I could use /var/log/mldonkey as the program working directory. But as the free space is on the /home partition, I'm note sure what to do about the incoming, shared and temp directories. Should I create a home folder for mldonkey (/home/mldonkey) and the three directories there?
And in that case, will I be able, using my user, to move the downloaded files from /home/mldonkey (owned by mldonkey) to my home directory? Does the owner of those files get changed to my user...? Is that what MLDONKEY_UMASK is about?
Quote:
It is also possible that the daemon is starting during boot, but then terminating at some point.
I wanted to check that, but what I haven't been able to find is where the output of the script (when it is called at startup) gets logged. I tried something like:
Code:
cat /var/log/* | grep MLDonkey
or just grep Starting (trying to find any other daemons) and nothing shows up. Any idea about this?
But as the free space is on the /home partition, I'm note sure what to do about the incoming, shared and temp directories. Should I create a home folder for mldonkey (/home/mldonkey) and the three directories there?
By all means, create a home directory for mldonkey and use this if this is where you have space available.
Quote:
Originally Posted by neoAKiRAz
And in that case, will I be able, using my user, to move the downloaded files from /home/mldonkey (owned by mldonkey) to my home directory? Does the owner of those files get changed to my user...? Is that what MLDONKEY_UMASK is about?
You are correct, but you could set a umask of 0002 and add yourself to the mldonkey group.
To check if the script is starting at boot-up, I would suggest makeing a few changes to the startup script (additional logging)
Code:
#!/bin/sh
#
# Original file :
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux
# by Ian Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.9.1 08-Apr-2002 miquels@cistron.nl
#
#
# This file has been rewritten by Sylvain Le Gall <gildor@debian.org>
# and Samuel Mimram <smimram@debian.org> for the mldonkey package.
#
### BEGIN INIT INFO
# Provides: mldonkey-server
# Required-Start: $network
# Required-Stop: $network
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Server for the mldonkey peer-to-peer downloader.
# Description: Server for the mldonkey peer-to-peer downloader.
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=mlnet
EXEC=/usr/local/bin/$NAME
DESC="MLDonkey"
CONFIG=/etc/default/mldonkey-server
PIDDIR=/var/run/mldonkey
PIDFILE=$PIDDIR/$NAME.pid
LOGFILE=/var/log/mldonkey/$NAME.log
STARTLOG=/tmp/$NAME_startup.logecho "`date` - Running $DESC $1" >> $STARTLOG
test -x $WRAPPER || exit 0
test -e $CONFIG || exit 0
set -e
. $CONFIG
# /var/run might be on tempfs, see #354701.
if [ ! -d /var/run/mldonkey ]; then
mkdir -m 755 /var/run/mldonkey
fi
if [ -n "$MLDONKEY_USER" ] && [ -n "$MLDONKEY_GROUP" ]; then
chown $MLDONKEY_USER:$MLDONKEY_GROUP /var/run/mldonkey
fi
WRAPPER_OPTIONS=""
# Set configuration value, from CONFIG
if [ -n "$MLDONKEY_USER" ] && [ -n "$MLDONKEY_GROUP" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chuid $MLDONKEY_USER:$MLDONKEY_GROUP"
fi
if [ -n "$MLDONKEY_DIR" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --chdir $MLDONKEY_DIR"
fi
if [ -n "$MLDONKEY_GROUP" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --group $MLDONKEY_GROUP"
fi
if [ -n "$MLDONKEY_UMASK" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --umask $MLDONKEY_UMASK"
fi
if [ -n "$MLDONKEY_NICENESS" ]; then
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --nicelevel $MLDONKEY_NICENESS"
fi
case "$1" in
start|force-start)
echo -n "Starting $DESC: $NAME"
echo -n "Starting $DESC: $NAME" >> $STARTLOG
if [ "x$LAUNCH_AT_STARTUP" != "xtrue" ] && [ "x$1" = "xstart" ]; then
echo " configuration file prevent $NAME to be started (use force-start)."
exit 0
fi
if [ -z "$MLDONKEY_DIR" ] || [ ! -d "$MLDONKEY_DIR" ]; then
if [ -z "$MLDONKEY_DIR" ]; then
MLDONKEY_DIR="(unset)"
fi
echo " $MLDONKEY_DIR is not a valid directory."
exit 1
fi
if [ ! -f "$MLDONKEY_DIR/downloads.ini" ]; then
echo " $MLDONKEY_DIR/downloads.ini is not a valid file."
exit 1
fi
USER=`/usr/bin/stat --format="%U" "$MLDONKEY_DIR/downloads.ini"`
WRAPPER_OPTIONS="$WRAPPER_OPTIONS --user $USER"
start-stop-daemon --start $WRAPPER_OPTIONS \
--pidfile $PIDFILE --background --exec $EXEC \
-- -pid $PIDDIR > $LOGFILE 2>&1
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
echo -n "Stopping $DESC: $NAME" >> $STARTLOG
start-stop-daemon --stop --oknodo --pidfile $PIDFILE
echo "."
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload|force-start}" >&2
exit 1
;;
esac
echo "Checking for mlnet process:" >> $STARTLOGps -ef|grep ml[n]et >> $STARTLOG
exit 0
Thanks a lot! I now run mlnet as the mldonkey user, found out about umask, groups and some more about permissions...
And also found the reason why the mlnet daemon would "sometimes" run and other times not. It seems that my webcam fried, so it caused some "usb operations" such as lsusb to hang for a pretty long time. In my case, one of the init.d scripts prior to mldonkey-server called logitech_applet, which configures my Logitech mouse. This program hanged for a while and that caused the rest of the scripts to delay their execution.
The only thing I noticed was that when I move files from /home/mldonkey to my home directory, as my user, the owner remains as mldonkey. Is this the expected behavior?
Yes, could use chown. But I thought there was an automatic way to do it... if there's not I guess the files are supposed to stay like that
Thanks a lot for all your help!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.