l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
July 21: Defensive computing: Information security for individuals
Next Installfest:
TBD
Latest News:
Jul. 4: July, August and September: Security, Photography and Programming for Kids
Page last updated:
2001 Dec 30 17:06

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] boot up commands in debian?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] boot up commands in debian?



On Thu, 28 Jun 2001, Foo Lim wrote:
> What's the debian way of executing boot-up commands that don't necessarily
> need a 'service' script (ie gpm start|stop|etc.)?  I'm thinking more in
> terms of an hdparm command that needs to be executed once.  In RH 6.2,
> it's in rc.local, but I couldn't find one in debian 2.2r3.  RH 6.2
> actually makes a S99local symlink to rc.local in rc3.d, so I was thinking
> of doing that but putting it in rcS.d .  I've read the debian-policy
> documentation, but maybe I was skimming too fast.

Over-all, I do similar to what you describe. Make a new script for a new
service, and create the sym links to it from the appropriate /etc/rc?.d. I
frequently make a custom name for each additional script (even an hdparam
command if it is needed.) Using one script to take care of all of my
additions is not very modular, and can lead to support problems later.

- ( More for those that want to understand the Q and A. I will often do
this when responding to e-mail messages if time permits it. It can
sometimes help a lurking reader or two to grasp something not previously
understood. This is by no means a suggestion of my thoughts on the
original poster's abilities!  :)

(Including background for people that might not otherweise know the
discussion.)

Most Debian systems by default (and I think RedHat seem to be going this
way too) seem to use the "/etc/init.d" as a storage location for
startup/shutdown scripts. Each often accepts an arguement such as start
and stop while some accept arguements like restart, rehash, flush or other
special service specific aids in addition to the start and stop
arguements. (For example, my qmail script accepts start and stop as well
as the qmail specific addition for flushing the mail que for redelivery
and flushing the whole que by using special process signals, and even a
restart - all handeled by the qmail script accepting english-like
arguements like "start", "stop", "redoque", "redooallque", "flushallque",
"restart". Only stop and start are really used by the startup and shutdown
procedure, but I find it easier to remember to call my script than to
remember what qmail process needs what signal to perform what exact
thing.)

Depending upon run-level, these scripts are started and stopped based on a
parsing of a name of a symbolic link located in another special directory.

Each runlevel describes a state or direction for the machine: reboot,
shutdown, halt, single-user mode, etc.

Depending on what the machine is doing, different /etc/rc?.d are examined
and parsed. The contents of each directory determines what scripts shall
be sent arguement to start services and which will be asked to die. These
are what control mopst of the starting and stopping of many services on
your Debian box.

/etc/rcX.d (where "X" is a number 0-6 or "S" or the special "boot")

Sym Links that start with a "S" followed by a number are "S"tarted while
those that start with a "K" are "K"illed (asked to "quit" really, and
possibly killed (sigterm) if program control does not respond to proper
signal to exit.)

(Being case sensitive, one way some have disabled service from certain
run-levels is to change the "S" to a "s" on the service name desired for
being disabled in the runlevel for the directory it was altered.)

The number that follows (double-digit decimal) determine order of run. 01
is run before 10 which is run before 50 which is before 99. With two of
same value, I think it parses on alphabetic name next where S50samplea
would start beflore S50sampleb.

You may create your own scripts in /etc/init.d to use the same skeleton as
the other scripts you will find there. In your own custome script, you may
create your own branching conditions on how to act based on the
control/arguement (start/stop/etc). Then you can create sym links with 
# ln -s /etc/init.d/script /etc/rc?.d/[S||K][0-9][0-9]name
or after a cd to the appropriate rc?.d instead:
# ln -s ../init.d/scriptname [S||K][0-9][0-9]name
eg:
# cd /etc/rc5.d
(to be dealt with when system enters runlevel 5)
# ln -s ../init.d/myscript S01myscript
meaning when the system moves to runlevel 5, 

You can then create entries in the appropriate start and stop runlevels
(reboot, shutdown, singleuser mode etc) to properly either start up your
script or shut it down.)

I used the above system for adding my own services at startup. It is great
for long term support and makes it easy for people that may come in after
me; they will be able to start and stop my services just like most
others. WHen I need hdparam, then my service name added in /etc/init.d/ is
hdparam or hdparamsetup .

It is also useful for adding replacement services compiled in
/usr/local/src and stored in /usr/local/[s]bin as tests before I really
decide to no longer use the packaged copies.

If however, you wish to take the easy way out, and dont mind the problems
that may be created when you need to track down the new commands you want
to have run each time you start up your machine or shut it down, you can
try to add it to another script that would seem like a logical choice
(like the system startup script for setting serial ports (?).)

(I do not suggest going this route, but I know others have chosen this
path before.)

Readmes should exist on your system for it. Check /etc/init.d/README for
starters. (I know you mentioned having read the document this referenced,
this is background for other readers.)

Thanks,
-ME

-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GCS/CM$/IT$/LS$/S/O$ !d--(++) !s !a+++(-----) C++$(++++) U++++$(+$) P+$>+++ 
L+++$(++) E W+++$(+) N+ o K w+$>++>+++ O-@ M+$ V-$>- !PS !PE Y+ !PGP
t@-(++) 5+@ X@ R- tv- b++ DI+++ D+ G--@ e+>++>++++ h(++)>+ r*>? z?
------END GEEK CODE BLOCK------
decode: http://www.ebb.org/ungeek/ about: http://www.geekcode.com/geek.html
     Systems Department Operating Systems Analyst for the SSU Library


LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
Sunset Systems
Who graciously hosts our website & mailing lists!