Time for a little Slackware startup script fun.

First, a good source of background info is at:

http://en.wikipedia.org/wiki/Slackware#Startup_scripts

Patrick Volkerding choose to go with the BSD style init scripts for simplicity. 
 Basically, each runlevel is given a particular script.  That script can call 
any other scripts you want it to.  If you wish to remove something from one 
runlevel but not another, edit the script for that runlevel, you want to not 
start a service, but keep the option to start it later, make the script that 
the runlevels call non-executable.

To paraphrase the wikipedia entry; BSD style advocates say that init scripts 
are better because with this system it is much easier to find, read, edit, and 
maintain the scripts, SysV advocates say that long, complicated startup scripts 
are scary, and symlinks to short, complicated scripts are your friends.  :)

As for Slackware, the first important file is /etc/inittab, part of which is 
here:

# These are the default runlevels in Slackware:
#   0 = halt
#   1 = single user mode
#   2 = unused (but configured the same as runlevel 3)
#   3 = multiuser mode (default Slackware runlevel)
#   4 = X11 with KDM/GDM/XDM (session managers)
#   5 = unused (but configured the same as runlevel 3)
#   6 = reboot

# Default runlevel. (Do not set to 0 or 6)
id:3:initdefault:

# System initialization (runs when system boots).
si:S:sysinit:/etc/rc.d/rc.S

# Script to run when going single user (runlevel 1).
su:1S:wait:/etc/rc.d/rc.K

# Script to run when going multi user.
rc:2345:wait:/etc/rc.d/rc.M

# What to do at the "Three Finger Salute".
ca::ctrlaltdel:/sbin/shutdown -t5 -rf now

# Runlevel 0 halts the system.
l0:0:wait:/etc/rc.d/rc.0

# Runlevel 6 reboots the system.
l6:6:wait:/etc/rc.d/rc.6


>From this entry, you see that rc.S always runs, before any other script.  
>After that, if the machine is going into runlevel 1, usually for emergency 
>repairs, then rc.K runs after rc.S.  If the machine is going into multi-user, 
>or "regular," mode, then rc.M runs.

When you look at the rc.x files, you will see that many time they call other 
scripts.  Now rc.K (single user) often directly calls programs.  This is 
handled with something that looks like this:

  # Try to turn off quota:
  if fgrep quota /etc/fstab 1> /dev/null 2> /dev/null ; then
    if [ -x /sbin/quotaoff ]; then
      echo "Turning off filesystem quotas."
      /sbin/quotaoff -a
    fi
  fi

This is a bash script that first runs an if statement to see if quotas are 
currently on, and if so, it will then run an if statement to see if 
/sbin/quotaoff is executable, and if that is, then it will turn off quotas.  
This came from the rc.K script, and what it is doing is turning of file system 
quotas so you can do any kind of work without getting errors about it.

Another example, from rc.M, is:

   # Start Web server:
   if [ -x /etc/rc.d/rc.httpd ]; then
     . /etc/rc.d/rc.httpd start
   fi

This if statement looks to see if the script /etc/rc.d/rc.httpd is executable, 
and runs it if it is.  If you want to keep httpd from starting at boot, you can 
either comment out this line, or you can chmod a-x the rc.httpd file.

So, to Matt's delimma, how to find out what services are starting with the 
machine.  The quickie, and will get 75% to 95%, depending on how flaky your Sys 
Admin has been, is to see which files in /etc/rc.d/. directory are executable, 
and that would be it.  This only controls the services that have to be running, 
other services, such as finger, auth, ntp..., can be called on-the-fly by 
inetd, so you can also look at the /etc/inetd.conf file for any un-commented 
lines.

Now, the last 25% to 5%, will require poking through these files for specific 
commands:

/etc/rc.S (your Sys Admin just might put stuff there to start all of the time)
/etc/rc.M (multi-user mode, another place to put direct service calls)
/etc/rc.local (this one is called as the last item from rc.M, so stuff can be 
there)
/etc/rc.3 (if there is one, look through it)

If the Slackware machine also has /etc/rc.d/rcx.d directories, and/or 
/etc/rc.d/init.d, don't worry, that is just there for SysV compatibility, but 
on Slackware, SysV is usually handled by an rc.x file (rc.4, or rc.6).

Well, I hope that helps,

Chris LeBlanc
Intechgra Systems Engineer

_______________________________________________
EUGLUG mailing list
[email protected]
http://www.euglug.org/mailman/listinfo/euglug

Reply via email to