LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Starting and killing services on system cycle: (https://www.linuxquestions.org/questions/linux-newbie-8/starting-and-killing-services-on-system-cycle-207649/)

JohnLocke 07-20-2004 09:16 PM

Starting and killing services on system cycle:
 
Ok, I figured that to add a startup process (samba is what I'm working on), you can add that to the rc.local file in /etc/rc.d

Here's what I put in:

Code:

if ps -ef | grep mbd | grep -v grep ; then
    echo "smb processes already started"
else
    echo "starting smb processes..."
    /etc/rc.d/init.d/smb start
fi

I just put it down at the bottom after all the /etc/issue business (running a new install of MDK 9.2)

I figure it would be smart to have a kill script in the rc.6 directory as well ... but I don't know how to do that (or even if what I've done is "correct" even though it works ;) ). All the files in rc.6 are linked files ... plus, smb doesn't want a "kill" signal per se (and as I understand it, the rc.6 files are simply sent a term signal?). I just want a script that'll say something to the effect of:

Code:

if ps -ef | grep mbd | grep -v grep ; then
    echo "cleaning up smb processes ..."
    /etc/rc.d/init.d/smb start
else
    echo "smb processes are already shut down."
fi

am I on the right track? Where to go next?

Demonbane 07-20-2004 09:41 PM

Sorry but I don't really get what you're trying to do here, if you're trying to run smbd on startup can't you put it in the runlevels you desire?

JohnLocke 07-20-2004 09:52 PM

Erm ... I suppose I could. I guess that's part of my question. I'm not nearly 100% familiar with what the runlevels do ... do they simply send an init and term signal to the process you identify? For example, if I ln -s the smb init file to a Snn or Knn in one of the rc.X directories, I think it'll work, but is that correct to do?

Samba asks for you to run "smb xxx" where xxx is start, restart, or stop. I've heard people can just put them in the rc folders as a runlevel link, but I'd like to get in the habit of doing things correctly.

I guess in basic my question might be, /should/ you use the runlevels if the script you're starting asks for a command line input?

Demonbane 07-20-2004 10:49 PM

If you want to know more about runlevels try this guide
http://www.icon.co.za/~psheer/book/index.html
particularly on chapter 32

For a quick answer yes you should have a dedicated script for starting a service on boot for a particular runlevel, though you don't have to, this makes it easier to manage.
for example if you want to add smb to the default runlevel(5 in Mandrake I think) instead of doing the symlinks manually you can use:
Code:

/sbin/chkconfig --level 5 smb on

JohnLocke 07-20-2004 11:31 PM

Good grief that's a long one! ha! Ok, I'll start reading that and get back to you.

For now, I redid it and currently have:
Code:

smb            0:off  1:off  2:off  3:on    4:off  5:on    6:off
(I changed the levels on them, though to start after network services were up and to be killed before network services went down) and took my script out of the rc.local
as it appears this is what everyone is telling me to do.

This seems to be working just fine. I guess my current question, then, is moot, but I'm still curious;
if using the runlevel starts and kills these things just fine ... does smb or network or eth0 or whatnot accept an init signal instead of the "start" "stop" or "restart" ... or do those simply echo a term and init signal to these scripts?

Thanks for the manual to look at!

JohnLocke 07-21-2004 05:50 PM

Sorry, I'm a moron ... didn't disable smilies /or/ preview my post. Just that section again:
Code:

smb            0ff  1ff  2ff  3n    4ff  5n    6ff

JohnLocke 07-21-2004 06:49 PM

Last time ... this time without the idiocy ....
Code:

smb            0:off  1:off  2:off  3:on    4:off  5:on    6:off


All times are GMT -5. The time now is 12:04 AM.