[H-GEN] Samba on SuSE 8.1

ben.carlyle at invensys.com ben.carlyle at invensys.com
Fri May 9 03:32:27 EDT 2003


[ Humbug *General* list - semi-serious discussions about Humbug and     ]
[ Unix-related topics. Posts from non-subscribed addresses will vanish. ]

G'day,





Jason Parker-Burlingham <jasonp at uq.net.au>
Sent by: Majordomo <majordom at caliburn.humbug.org.au>
08/05/03 08:43
Please respond to general

 
        To:     general at lists.humbug.org.au
        cc: 
        Subject:        Re: [H-GEN] Samba on SuSE 8.1

Alex Delaforce <alextdel at bigpond.net.au> writes:

> > Question - how does the file S20samba get run at boot time? Is
> > everything in rc.5 run as linux reaches run level 5?

> It's run by a process started by init.  On my Debian system it is
> "/etc/init.d/rc".  On your system it'll be a bit different, look in
> /etc/inittab.

It can be interesting to read the rc scripts used by init to execute the 
set of programs in /etc/rc?.d. Under solaris each runlevel has an 
individual script, and just for another quirk doesn't always run the 
symlinks with {start}|{stop} arguments. In some of my dealings with 
configs and installations I came across a symlink called S20foxcontrol.sh 
named by another developer. The strange thing is that it was being called, 
but not with the "start" argument. It turned out that the ".sh" extension 
caused solaris to source the script instead of running it (which also 
caused none of the other scripts to run when this script failed because it 
had no parameters). Unlike ksh and bash the old bourne shell which this 
was written in doesn't allow parameters to be passed into a "sourced" 
script and therefore none were provided.

The code snippet from solaris 8's /etc/rc3 is
        if [ -s $f ]; then
                case $f in
                        *.sh)   .        $f ;;
                        *)      /sbin/sh $f start ;;
                esac
        fi

You can see that it sources files with a ".sh" extension, but runs 
/sbin/sh (the bourne shell) to run anything else. My debian box makes a 
similar distinction, but uses only the single script /etc/init.d/rc and 
doesn't do any sourcing. Instead the debian version treats files ending in 
".sh" as scripts to be run by the sh program while anything else is 
executed directly. Here's that code snippet:

startup() {
  case "$1" in
        *.sh)
                $debug sh "$@"
                ;;
        *)
                $debug "$@"
                ;;
  esac
}

Note that it uses a simple programmers trick to print what it's doing 
instead of running it when the variable debug is set to "echo". But how 
does init know to run these scripts? Here's the snippet from my debian 
/etc/inittab file:

l0:0:wait:/etc/init.d/rc 0
l1:1:wait:/etc/init.d/rc 1
l2:2:wait:/etc/init.d/rc 2
l3:3:wait:/etc/init.d/rc 3
l4:4:wait:/etc/init.d/rc 4
l5:5:wait:/etc/init.d/rc 5
l6:6:wait:/etc/init.d/rc 6

Each of these lines roughly translates to "When you reach runlevel x, run 
/etc/init.d/rc with the parameter x. Wait until it finishes executing 
before you do anything else.".

So how does init get run? It's the only program under unix that is started 
by the kernel with no extra-kernel code to get it going[1]. When the 
kernel boots it'll run init, and init will usually read /etc/inittab and 
work out what to do with it's self and the rest of the system from there. 
It's for this reason that you'll aways see that init has process id 1, and 
0 as it's parent process id. It's the only process you'll find on a 
running unix system with on valid PPID, since anything else that dies in 
the system is automatically inherited by init.

Anyway, that's enough system startup fun for one message ;)

Benjamin



--
* This is list (humbug) general handled by majordomo at lists.humbug.org.au .
* Postings to this list are only accepted from subscribed addresses of
* lists 'general' or 'general-post'.  See http://www.humbug.org.au/



More information about the General mailing list