El esquema de arranque y detención del sistema en Linux Debian/GNU
es del tipo "system V". Todos los scripts que ejecutan tareas
en el arranque o detención del sistema se encuentran en el directorio
/etc/init.d. Los directorios /etc/rcS.d, /etc/rc0.d, /etc/rc1.d, /etc/rc2.d
y /etc/rc6.d corresponden a cada uno de los posibles niveles o estados
de funcionamiento del sistema. Estos directorios sólo contiene enlaces
simbólicos hacia los scripts en /etc/init.d. Los nombres de estos
enlaces simbólicos son significativos: la primera letra es S o K,
luego sigue un número de 2 cifras, y finalmente el nombre de un
script en /etc/init.d. Algunos ejemplos:
K18netbase K20ppp
K20exim
S15netbase S20exim
S25nfs-server
Dentro de un directorio, los scripts K se ejecutan primero. La K
(de "kill", matar) indica que el script correspondiente en /etc/init.d
debe ejecutarse con la opción de detención, "stop".
Luego de ejecutados todos los scripts K, se ejecutan los scripts S. La
S (de "start", arrancar) indica que el script correspondiente
en /etc/init.d debe ejecutarse con la opción de arranque ("start").
El número de 2 dígitos regula el orden en que se ejecutan
los distintos scripts; el número puede estar repetido, cuando importa
la precedencia.
Los distintos niveles en que puede funcionar el sistema se definen en el
arthivo /etc/inittab.
# /etc/inittab: init(8) configuration.
# $Id: inittab,v 1.8 1998/05/10 10:37:50 miquels Exp $
# The default runlevel.
id:2:initdefault:
# Boot-time system configuration/initialization script.
# This is run first except when booting in emergency (-b) mode.
si::sysinit:/etc/init.d/rcS
# What to do in single-user mode.
~~:S:wait:/sbin/sulogin
# /etc/init.d executes the S and K scripts upon change
# of runlevel.
#
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.
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
# Normally not reached, but fallthrough in case of emergency.
z6:6:respawn:/sbin/sulogin
# What to do when CTRL-ALT-DEL is pressed.
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
# Action on special keypress (ALT-UpArrow).
kb::kbrequest:/bin/echo "Keyboard Request--edit /etc/inittab to
let this work."
# What to do when the power fails/returns.
pf::powerwait:/etc/init.d/powerfail start
pn::powerfailnow:/etc/init.d/powerfail now
po::powerokwait:/etc/init.d/powerfail stop
# /sbin/getty invocations for the runlevels.
#
# The "id" field MUST be the same as the last
# characters of the device (after "tty").
#
# Format:
# <id>:<runlevels>:<action>:<process>
1:2345:respawn:/sbin/getty 38400 tty1
2:23:respawn:/sbin/getty 38400 tty2
3:23:respawn:/sbin/getty 38400 tty3
4:23:respawn:/sbin/getty 38400 tty4
5:23:respawn:/sbin/getty 38400 tty5
6:23:respawn:/sbin/getty 38400 tty6
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
# Example how to put a getty on a modem line.
#
#T3:23:respawn:/sbin/mgetty -x0 -s 57600 ttyS3
init.d
rc0.d
rc2.d
rc4.d
rc6.d
rc1.d
rc3.d
rc5.d
rcS.d
Contenido de /etc/rcS.d:
README
S20modutils S40network
S55bootmisc.sh
S05keymaps.sh S30checkfs.sh
S45mountnfs.sh S55urandom
S10checkroot.sh S35mountall.sh
S50hwclock.sh S70nviboot
S15isapnp S40hostname.sh
Contenido de /etc/rc0.d:
K01xdm
K20gpm
K20quota S20sendsigs
K11cron
K20isdnutils K25nfs-server
S25hwclock.sh
K12kerneld K20logoutd
K30netstd_misc S30urandom
K15netstd_init K20lprng
K89atd
S40umountfs
K18netbase K20ppp
K90sysklogd S90halt
K20exim
Contenido de /etc/rc1.d:
K01xdm
K20exim K20lprng
K30netstd_misc
K11cron
K20gpm
K20ppp
K89atd
K12kerneld K20isdnutils
K20quota K90sysklogd
K15netstd_init K20logoutd
K25nfs-server S20single
K18netbase
Contenido de /etc/rc2.d:
S10sysklogd S20gpm
S20ppp
S89atd
S12kerneld S20isdnutils
S20quota S89cron
S15netstd_init S20logoutd
S25nfs-server S99rmnologin
S18netbase S20lprng
S30netstd_misc S99xdm
S20exim
Contenido de /etc/rc6.d:
K01xdm
K20gpm
K20quota S20sendsigs
K11cron
K20isdnutils K25nfs-server
S25hwclock.sh
K12kerneld K20logoutd
K30netstd_misc S30urandom
K15netstd_init K20lprng
K89atd
S40umountfs
K18netbase K20ppp
K90sysklogd S90reboot
K20exim
Scripts en /etc/init.d:
README
hwclock.sh netbase
reboot
atd
isapnp
netstd_init rmnologin
bootmisc.sh isdnutils
netstd_misc sendsigs
checkfs.sh kerneld
network single
checkroot.sh keymaps.sh
nfs-server skeleton
cron
logoutd nviboot
sysklogd
exim
lprng
ppp
umountfs
gpm
modutils quota
urandom
halt
mountall.sh rc
xdm
hostname.sh mountnfs.sh
rcS
En la distribución Debian se exige que todos los paquetes de software tengan un script rc con las opciones "start", "stop", "restart" y mensaje informativo de uso si no se dan opciones. Se provee una plantilla modelo para la creación de estos scripts, a partir de la cual el responsable de cada paquete estructura el script rc, que residirá en /etc/init.d, y con el cual se gobierna el paquete.
#! /bin/sh
#
# skeleton example file to build /etc/init.d/ scripts.
# This
file should be used to construct scripts for /etc/init.d.
#
# Written
by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified
for Debian GNU/Linux
# by Ian
Murdock <imurdock@gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.8 03-Mar-1998 miquels@cistron.nl
#
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/daemon
NAME=daemon
DESC="some daemon"
test -f $DAEMON || exit 0
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile
/var/run/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile
/var/run/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
#reload)
#
# If the daemon can reload its
config files on the fly
# for example by sending it SIGHUP,
do it here.
#
# If the daemon responds to changes
in its config file
# directly anyway, make this a
do-nothing entry.
#
# echo "Reloading $DESC configuration
files."
# start-stop-daemon --stop --signal 1 --quiet
--pidfile \
# /var/run/$NAME.pid --exec $DAEMON
#;;
restart|force-reload)
#
# If the "reload" option
is implemented, move the "force-reload"
# option to the "reload"
entry above. If not, "force-reload" is
# just the same as "restart".
#
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile
\
/var/run/$NAME.pid
--exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile
\
/var/run/$NAME.pid
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
# echo "Usage: $N {start|stop|restart|reload|force-reload}"
>&2
echo "Usage: $N {start|stop|restart|force-reload}"
>&2
exit 1
;;
esac
exit 0
No todos los scripts rc requieren las opciones "start" y "stop"; algunos realizan tareas siempre requeridas para el funcionamiento del sistema. El script rc "network" inicializa la máquina para su entrada en la red
#! /bin/sh
#
# network Establish the network
connection.
#
# Version: @(#)network 1.2
14-Nov-1996 miquels@cistron.nl
#
# Configure the loopback device.
ifconfig lo 127.0.0.1
route add -net 127.0.0.0 dev lo
# Configure the ethernet device or start SLIP/PPP below.
IPADDR="192.168.1.1"
# Your IP address.
NETMASK="255.255.255.0"
# Your netmask.
NETWORK="192.168.1.0"
# Your network address.
BROADCAST="192.168.1.255"
# Your broadcast address (blank if none).
GATEWAY=""
# Your gateway address.
/sbin/ifconfig eth0 ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST}
/sbin/route add -net ${NETWORK}
[ ! -z "$GATEWAY" ] && /sbin/route add default gw
${GATEWAY}
Sistema instalado Linux Debian/GNU 2.1. Debian Policy Manual , http://www.debian.org/doc/debian-policy/ Páginas "Como" (HOWTO), en español, en el sitio web de Debian Argentina, http://www.debian.org.ar/. Una excelente fuente de información para múltiples aspectos de instalación y configuración, desde nivel elemental hasta nivel técnico muy especializado.