LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   /etc/init.d (https://www.linuxquestions.org/questions/linux-newbie-8/etc-init-d-254839/)

DrakIE 11-14-2004 05:55 PM

/etc/init.d
 
If I drop a shell script in this path (/etc/init.d) will it be run during the startup process? During the boot process all scripts in this path are run, aren't they?

I'd like to drop a quick mount smbfs script to map universal shares. Also, where can I set environmental variables for each user and set user specific scripts to run when a user logs in?

Thanks,
T$

btmiller 11-14-2004 06:06 PM

It depends on the distro -- Slackware runs all executable scripts in /etc/rc.d/init.d. Most distros use the System V startup methodology, however, and the script has to be linked from the appropriate /etc/rc.d/rcX.d directory, where X is the runlevel in question. So for instance, on Mandrake, if you look in /etc/rc.d/rc3.d/ you'll see a bunch of symlinks -- some start with S and others with K. Those starting with S, the init script that they link to is run with the "start" argument. Those starting with "K", the linked to init script is run with the "stop" argument. The easiest way to manage this, IMO, is to make your init script chkconfig compatible and use chkconfig to manage it.

An easier way to handle this is just add the commands you want done to your rc.local script, which gets run after all the other init scripts.

You can put global user configuration and such into /etc/profile.

trickykid 11-14-2004 07:36 PM

Re: /etc/init.d
 
Quote:

Originally posted by DrakIE
If I drop a shell script in this path (/etc/init.d) will it be run during the startup process? During the boot process all scripts in this path are run, aren't they?

I'd like to drop a quick mount smbfs script to map universal shares. Also, where can I set environmental variables for each user and set user specific scripts to run when a user logs in?

Thanks,
T$

You don't need to place smb mounts in your startup scripts, the most logical place to put these is in your /etc/fstab file.

And if you want users to have custom environment or logins, you can place .bash_login files and or edit their .bashrc, .bash_profile or edit the global profile in /etc

You can also place .bash_logout files in their home directories if you want anything to occur after they logout of the system.. etc.

And regarding the startup scripts.. I do believe Mandrake is just like Redhat, you'd place the script in /etc/init.d which is usually a link to /etc/rc.d/init.d and you'd run a command like:

chkconfig --levels 345 <scriptname>

That would make the scripts start in runlevels 3, 4 and 5.. etc.


All times are GMT -5. The time now is 01:55 PM.