debian system V init

System V init basics



Theory

Runlevels
# grep -i runlevel /etc/inittab |egrep "0|1|2|6"
# Runlevel 0 is halt.
# Runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# Runlevel 6 is reboot.


better ( /usr/share/doc/sysv-rc/README.runlevels.gz )
  
 N       System bootup (NONE).
 S       Single user mode (not to be switched to directly)
 0       halt
 1       single user mode
 2 .. 5  multi user mode
 6       reboot



... man 8 init

Runlevels 7-9 are also valid, though not really documented. This is because "traditional" Unix variants don't use them.

Runlevels S and s are the same.  Internally they are aliases for the same runlevel.





Scripts linked by links starting with a K run with the argument 'stop' in each runlevel ( except S and 2 )
before

scripts linked by links starting with S and run with the argument 'start' in all runlevels



Practice

See What Starts When
# ls /etc/rc?.d/S*


Disable a service or system initialization script
# update-rc.d -f service_name remove
example
# ls /etc/rc?.d/S* |grep bluetooth
/etc/rc2.d/S21bluetooth
/etc/rc3.d/S21bluetooth
/etc/rc4.d/S21bluetooth
/etc/rc5.d/S21bluetooth
# update-rc.d -f bluetooth remove
update-rc.d: using dependency based boot sequencing
# ls /etc/rc?.d/S* |grep bluetooth
# 


Start a service in Runlevels 2 through 5
# update-rc.d service_name defaults
example
# ls /etc/init.d/bluetooth 
/etc/init.d/bluetooth
# ls /etc/rc?.d/S* |grep bluetooth
# update-rc.d bluetooth defaults
update-rc.d: using dependency based boot sequencing
# ls /etc/rc?.d/S* |grep bluetooth
/etc/rc2.d/S21bluetooth
/etc/rc3.d/S21bluetooth
/etc/rc4.d/S21bluetooth
/etc/rc5.d/S21bluetooth
#


To create an init.d script look at /etc/init.d/skeleton for an example.
You may want to create a ghetto init.d script that does not speak to innserv with comments.




References:
man update-rc.d
/etc/inittab
man 8 init
man 5 inittab
man telinit
man 8 insserv
/usr/share/doc/sysv-rc/README.runlevels.gz



system V init - debian