The Dynamite: NEW Vector Linux Init
===================================

This is a new proposed VL Init procedures. 
It combines the best from Slackware's ortodox BSD-Init scripts 
and SysV-Init system found on many Linux distros.

It defines the following run levels:
0 = halt
1 = single user
2 = multiuser, teks client
3 = multiuser, teks server
4 = multiuser, GUI client
5 = multiuser, GUI server
6 = reboot
7 = autologin
8 = autologin

The default run level is 2, but can be changed by using VASM vbootset.
So what is so good about vector linux init ?

1. Compare to the BSD-Init, it allows flexible daemons
   for each run level (like SysV-Init).
2. Compare to SysV-Init, it keeps the mandatory initialisation 
   on classic script (like BSD-Init). Only secondary daemons are
   freely configured for each run level.
3. Not like the others, switching run level does not blatantly
   stops every daemons, only to starts them again. VL Init carefully
   stop the unneeded daemons, but only reloads the rest, mostly
   by sending the wake-up signal (HUP). This is faster than SysV-init !
4. A CLI utility called "service" is provided to setup the daemons
   for each run level. More user friendly configurator is provide 
   by VASM.

Then the hacking goes beyond the puritans.
The run level definition has been redefined so:

1. You can start/stop the server daemons by switching between 
   run level 2/3 without launching the X-Window. On the 
   other hand, you can start/stop the server daemons by switching
   between run level 4/5 without killing the X-Window.

2. You can launch/kill X-Window without starting the server 
   daemons by switching between run level 2/4. Likewise, you 
   can launch/kill X-Window without stopping the daemons
   by switching between run level 3/5.
   
3. Arguably, this is the most controversial one.
   You can boot to run level 7/8 and go autologin without 
   pasword ! I know it is a security treat.
   Just turn it off if you don't like it. I would not :)

In short, this is a FAST and RICH run level management system.
You can't find many of these feature in the leading distros.
At least, until I wrote this. :P

Thats enough for casual users. Read on if you are a geek.


HOW IT WORKS
============

The general initialisation procedure of VL-Init is:

1. The rc.S fires up the system initialisation. It handles various
   kernel fs like devfs (kernel 2.4.x) or udev (kernel 2.6), then 
   mounts the swap and local file systems. Next, it sets the basic 
   system just enough for single user mode. Advanced hardwares and 
   network  are not launched when you boot into single user mode. 
   Thus allowing you to avoid system lock and do maintenance.

2. The rc.M runs only once when the system goes to multiuser mode
   (run level 2/3/4/5). It initializes advances hardware, network,
   firewall, and network file systems. They are here for two reasons.
   First, to keep them simple, stable and fast just like what uncle
   Slack said. Second, they should not be reinitialized when the system
   switches run level 2/3/4/5. Restarting the network/netfs during 
   switching run level can screw-up the system, can't they ?
   
3. On each run level, a set of daemons is launched by rc.sysvinit,
   or the improved rc.vlinit (your preference). You can register
   any daemons for each run level. The init script start/stop/reload
   the daemons according to the run level. So you have the flexibility
   of what other Linux distros always tell uncle Slack to do.

4. The rc.X launches X-Windows on GUI mode run level (4/5), then
   setup GUI mode login (XDM, GDM, KDM or WDM).

5. The rc.local runs in the end of multiuser mode initialization.
   This is intended for admin customisation.

6. The rc.A launches autosetup on run level (7/8). It bypasses the 
   login procedure, and launch the X-Window as the registered user.

Here is the detail.

/etc/rc.d/rc.S
----------------------------------
This script is executed when the system is booted.
It sets up various basic hardware and system parameters.

/etc/rc.d/rc.0 and rc.6
----------------------------------
Both are the same file (symlinked).
This script is executed when the system goes to level 0 (halt) or 6 (reboot).
It kills ALL daemons, unmount file system, then reboot/halt

/etc/rc.d/rc.1
------------------------------------------------
This scritp is executed when the system goes to run level 1
(single user). It kills ALL daemons and network

/etc/rc.d/rc.M
-----------------
This script run when entering multiuser mode (run level 2-5).
It initialise the hardware, network and mount network file system.
Hardware can be set up using vhwset.
Network by using vnetmenu or vnetconf.

/etc/rc.d/rc.X
-----------------
Start the GUI login, either KDM, GDM, WDM or XDM.
It will bounce back to run level 2 or 3 if X is failed to launch. 
Can be setup by using vxdmset.

/etc/rc.d/rc.init
-----------------
Runs on each run level switching.
Calls rc.sysvinit or rc.vlinit to start/kill services.
Can be setup by using vinitset

sysvinit is the standard, while vlinit is the proposed new system.
Both sysvinit and vlinit use the same service registration.
To register a service in a run level use vsrvset.
From command line, you may use:
  service -s service_name runlevels [run_order]
  service -r service_name runlevels

/etc/rc.d/rc.sysvinit
--------------------------------------------------
Normal Sys-V init.
sysvinit switches the run levels as follows:
- Kills the service in the previous run level.
- Starts the services in the next run level.

/etc/rc.d/rc.vlinit
------------------------------------------------
This scritp is an option to sysvinit.
I mean, it is recomended over sysvinit.

vlinit uses different algorithm when switching level as follows:
- Kills the service in the previous run level that
  is NOT registered in the next level.
- Reload services that has been run in the prev run level.
- Starts the services in the next run level that is NOT
  registered in the previous level

The advantages over the OLD sysvinit
- faster switching. It does not kill a service if not necessary.
  Only reload it.
- internally, uses only start (S??) symlinks for service registration.
  The kill (K??) symlinks are still there only for sysvinit.
- more simple and sensible.

/etc/rc.d/rc.keymap, rc.fonts
-----------------------------------------------------------------
Various hardware initialisation, launched by rc.S.
The rc.keymap is created by vkmapset.

/etc/rc.d/rc.modules, rc.pcmcia, rc.hotplug, rc.alsa, rc.serial
-----------------------------------------------------------------
Various hardware initialisation, launched by rc.M.

/etc/rc.d/rc.inet1, rc.inet2 ... rc.inet9
--------------------------------------------------
Normal network script, launched by rc.M when entering multiuser mode.
These scripts are created by vnetconf and vnetset.
To disable, delete or make it unexecutable.

/etc/rc.d/init.d/rc.route
--------------------------------------------------
Setting up routing table.
Currently none. But if you make it it will be executed.

/etc/rc.d/init.d/rc.name
--------------------------------------------------
Setting up hostname, domain name and DNS server

/etc/rc.d/init.d/rc.firewall rc.paranoid
--------------------------------------------------
Simple masquerading firewall.
Use it if you don't have a better choice.
They are created by vfirewall.

WRITING A DAEMON SCRIPT
--------------------------------------------------
Daemon script is the one that actually start or stop the service
(like sshd, samba, cups, etc). The daemon scripts are located under
/etc/rc.d/init.d. They are called by :
- The rc.vlinit or rc.sysviont on run level switching
- The service program when called by user manually like this
    service sshd start
    service sshd stop

Therefore, the scripts should follow the following convention:
- Accept start, stop, restart, reload, status parameter.
  Start/stop are mandatory for sysvinit and vlinit,
  and ... ,attention please, reload is a must for vlinit.
- Write to stdout/stderror, formatted for a log file
  The rc.vlinit and rc.sysvint redirect the output/error to a log file.
  Meanwhile, the service program displays the output as is.
- Return success or failure status.

It is recomended to source /etc/rc.d/functions
then use these standard functions:
- loadproc (for starting)
- killproc (for stopping)
- reloadproc (for reloading)
- evaluate_retval (display the status)

-----------------------------------
Happy hacking
Eko M. Budi, 2004

