Adding a script to /etc/init.d
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.
After that, I did: Code:
sudo update-rc.d -f mldonkey-server start 98 2 3 4 5 . stop 20 0 1 6 . The script is quite simple and it works correctly running it with sudo: Code:
sudo /etc/init.d/mldonkey-server start 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. Is there anything else I'm missing? Thanks a lot! |
remove the -f from the command:
Code:
sudo update-rc.d mldonkey-server start 98 2 3 4 5 . stop 20 0 1 6 . Code:
OPTIONS |
You're right, I hadn't read the man page thoroughly. However, now I did
Code:
sudo update-rc.d mldonkey-server start 98 2 3 4 5 . stop 20 0 1 6 . Code:
System startup links for /etc/init.d/mldonkey-server already exist. Code:
### BEGIN INIT INFO Thanks! |
You should have the following symlinks:
/etc/rc0.d/K20mldonkey-server /etc/rc1.d/K20mldonkey-server /etc/rc2.d/S98mldonkey-server /etc/rc3.d/S98mldonkey-server /etc/rc4.d/S98mldonkey-server /etc/rc5.d/S98mldonkey-server /etc/rc6.d/K20mldonkey-server all should be pointing to /etc/init.d/mldonkey-server I have a couple of questions to help your investigation Type: runlevel at a command prompt. What runlevel are you at? What is run by the start function in the script? Does the script contain any log files? |
I know this doesn't happen in Linux, but I restarted a second time this morning and it was working :S I don't know what might have happened...
The links are there: Code:
neoakiraz@fcksys:/etc$ ls -l rc* | grep mldonkey Here is the piece of the script you were looking for, I think: Code:
case "$1" in 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 |
runlevel 2 is fine, so long as one of the startup symlinks was in rc2.d:
Code:
ls -l /etc/rc2.d/S98mldonkey-server Code:
sudo /etc/init.d/mldonkey-server start Does the mlnet process start? Code:
ps -ef|grep mlnet CONFIG=/etc/default/mldonkey-server Is LAUNCH_AT_STARTUP=true |
I rebooted one more time, and this time it worked... I don't know what's with it. The outputs are:
Code:
neoakiraz@fcksys:~$ sudo /etc/init.d/mldonkey-server start Code:
neoakiraz@fcksys:~$ ps -ef | grep mlnet Code:
MLDONKEY_DIR=/home/neoakiraz/.mldonkey I hope I explained my self well :rolleyes: Thanks for your help... and patience! Greetz |
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. |
Quote:
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:
Code:
cat /var/log/* | grep MLDonkey |
Quote:
Quote:
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 |
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? Thanks a lot! :) |
As you are moving the files the permissions will stay the same, however you can use chown to reset them if you wish:
Code:
chown neoakiraz:neoakiraz myfile Code:
chown -R neoakiraz:neoakiraz mydir |
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! |
All times are GMT -5. The time now is 10:08 PM. |