LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   how do /rc.d scripts get executed? (https://www.linuxquestions.org/questions/slackware-14/how-do-rc-d-scripts-get-executed-759484/)

mfoley 10-03-2009 06:24 PM

how do /rc.d scripts get executed?
 
I used to know this, but half an hour of searching has not refreshed my memory.

For slackware, startup files are in /etc/rc.d. Going to runlevel M (multiuser) causes /etc/rc.d/rc.M to get executed. It runs a bunch of /etc/rc.d scripts then finally runs rc.local at the end.

Lots of things get started that are neither in rc.M or rc.local, such as rc.tomcat and rc.firewall, yet if I make them executable they get run. How?

If something fails to run in /etc/rc.d, where is the failure logged?

rg3 10-03-2009 06:39 PM

I don't know about rc.tomcat, but rc.firewall is run from rc.inet1, which is itself run from rc.M. Failures in startup scripts that make text be outputted to the console can generally be seen on screen. I think most of them are not recorded in any file unless you modify the scripts to output text to a file instead or in addition to the screen.

Edit: in addition, you could take a look at bootlogd and run it after mounting the root partition, modifying the init scripts.

Woodsman 10-03-2009 08:50 PM

Follow the bread crumbs starting with /etc/inittab. From that file follow each listed rc.d file . As you noticed, some init scripts are called from other scripts that are called from the main scripts listed in inittab. There is no magic, just patience with browsing through each script. Knee bone is connected to thigh bone . . . .

mfoley 10-04-2009 12:43 AM

Thanks! After "following breadcrumbs" it turns out there is no magic after all. rc.tomcat DOES NOT get automatically executed. Everything that gets run either gets run from rc.M, and additional think I want get run in rc.local ... if I put them in there. I thought there was something somewhere that when through the executable scripts in /etc/rc.d and ran them. I believe what I was thinking of was the "for profile_script in /etc/profile.d/*.sh" line in /etc/profile. /etc/rc.d doesn't work that way.

Mystery clear up! Thanks.

rob.rice 10-04-2009 09:48 AM

bash it self runs /etc/profile when started as a login shell

Woodsman 10-04-2009 10:32 AM

Quote:

rc.tomcat DOES NOT get automatically executed. Everything that gets run either gets run from rc.M, and additional think I want get run in rc.local ... if I put them in there.
That is the basic idea. Any packages you add beyond the stock distribution that need a startup script generally are placed in rc.local. The general template looks like this:

if [ -x /etc/rc.d/rc.tomcat ]; then
/etc/rc.d/rc.tomcat start
fi

Quote:

I thought there was something somewhere that when through the executable scripts in /etc/rc.d and ran them.
If I recall correctly, the Zenwalk people do something like. You could look at their rc.d scripts and copy the general idea to your Slackware scripts.

GazL 10-04-2009 11:10 AM

Quote:

Originally Posted by mfoley (Post 3706811)
I thought there was something somewhere that when through the executable scripts in /etc/rc.d and ran them.

You're probably thinking of the sysv style init, which slackware supports but doesn't use for subsystem startup. Have a look at /etc/rc.d/rc.sysvinit if you're interested (or google sysvinit).


All times are GMT -5. The time now is 09:36 AM.