From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,2680c5dbf6527531 X-Google-Attributes: gidfee84,public From: Oisin McGuinness Subject: Re: rc3, init.d and starting things at bootime Date: 1999/05/07 Message-ID: <37331F14.E52D240B@sbcm.com>#1/1 X-Deja-AN: 475229942 Content-Transfer-Encoding: 7bit References: Content-Type: text/plain; charset=us-ascii X-Complaints-To: Email abuse@news2.new-york.net if this posting is inappropriate X-Trace: news2.new-york.net 926097175 17603 sysadmin [204.141.189.14] Organization: Sumitomo Bank Capital Markets Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 You can read a quick and clear description of the roles of /etc/inittab and the rc*.d directories in section 4.1 of the "System Administration" guide, which can be found at http://www.unix.digital.com/faqs/publications/base_doc/DOCUMENTATION/ I would strongly recommend against fiddling with /etc/inittab; it is too crucial for the system booting properly that you not get it wrong. But putting a bad script in the rc*.d is no big deal; it will just not start your programs right. Here is the quick scoop on what to do: 1) Master copies of the start scripts are stored in /sbin/init.d (e.g., we have one called samba, for starting you know what.) 2) If you want your script to run in multiuser network mode (3), create a link in /sbin/rc3.d to the script in /sbin/init.d. Again, for samba, we have ln -s /sbin/init.d/samba /sbin/rc3.d/S89samba 3) If you want your programs to do some cleanup, or shutdown properly when the machine changes init state (e.g., to 2, s or 0), create a link in the correct rc*.d directory, but named KxxName, where xx is a suitable number. 4) Script contents: Your script should be a /bin/sh script. When called as a "S" script, it will be given a single parameter "start"; when called as a "K" script, "stop". I *strongly* recommend reading those in /sbin/init.d supplied by Digital; take one as a model, and adapt it. Some products (samba) come with sample "system 5" startup scripts; these are also usually adaptable. 5) The number given to the links in 2) and 3) determines the order of execution; for "S" scripts higher numbered scripts are executed later; you probably don't want, e.g., samba to run before networking is up and running. 6) If there are machine dependent parameters you need, use the model of the Digital scripts, and use rcmgr calls in the start script to query /etc/rc.config. E.g., we have SAMBASSERVER="yes" export SAMBASERVER lines in our /etc/rc.config files on machines where we run samba, and the /sbin/init.d/samba script looks for this. Read the man page for rcmgr for more. This way you can keep the same startup scripts on all your machines, and emulate Digital's machine localizations. 7) I *strongly* recommend you compare the scripts used by Digital Unix with those on SunOS (kept in /etc/init.d, /etc/rc*.d) if you want to contrast engineering practices. I defy anyone to explain the Sun networking startup scripts in a seminar lasting less than a week! Note how uniform in style and how clear the Digital scripts are. 8) Major Gotcha: The program started by your startup scripts MUST handle SIGHUP; either explicitly or by ignoring it; init will send 2 SIGHUPS to the process; typically a signal to your daemon (your programs must be daemons) to read its config files. Hope this helps Oisin McGuinness Sumitomo Bank Capital Markets 277 Park Avenue New York NY 10172 USA oisin@sbcm.com Brandon Hutchison wrote: > > I realise this is a pretty naive request but could somebody give me an > overview of how I get to automatically start something eg a webserver or > a licence server at boottime. > > I've found this directory /sbin/init.d which seems to contain scripts > for starting things and then there is the other one /sbin/rc3.d which > seems to contain links to the previous one. The links are named in > systematic ways starting with Snn.... where nn is a number. > > Do the scripts need to be written in any special way.. > > The man pages on all this are pretty detailed and I sort of need an overview. > > System: DEC Alphatstation running 4.0B DU. > > Thanks for your help..