Vector Linux Init (experimental)
================================

This is a new proposed VL Init procedures. 
It combines the best from Slackware's ortodox init scripts 
and sys-v init system.

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

The default run level is 2, but can be changed by using VASM vbootset.

The general initialisation procedure 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 singleuser 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. It 
   initializes essentials hardware, network, firewall, and network file systems.
   They are there for two reasons. Firstly, they should not be reinitialized
   when the system switches run level 2/3/4/5. Secondly, to keep them simple,
   stable and fast just like what Uncle Slack said.
3. Switching run level 2/3/4/5 is performed by the usual rc.sysvinit, or
   the improved rc.vlinit. You can choose one of them. They start/stop/reload
   the services according to the run level. So you have the flexibility of
   other Linux distros.
4. The rc.local runs in the end of multiuser mode initialization.
   This is intended for admin customisation.

So what is so good about vector linux init ?
If you activate rc.vlinit instead of rc.sysvinit then:
1. Switching run level does not blatantly stop and start every service.
   Only reloads them. Reloading sends wake-up signal (HUP) to the
   daemons, but does not kill them only to start them again.
   Thus it is faster than sysvinit !
2. The run level system has been hacked. Assume that you have
   the same minimal client services for level 2/4 and the 
   complete server services for level 3/5.  When you switch run level:
   - 2 to 3 : start the servers, stay in text mode.
   - 2 to 4 : stay as client, but start the GUI.
   - 2 to 5 : start the servers and start the GUI.    
   - 3 to 5 : reload the server, start the GUI mode.
   - 5 to 3 : reload the server, stop the GUI.
   - 5 to 4 : here it is ... stop the servers, but GUI mode stays.
   Wicked !!
   
In short, this is a FAST run level switching system.
You can't find many of these feature in the leading distros :p
At least until I wrote this. ;-)

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

===============================================================


/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 cteated by vfirewall.


/etc/initab 
-----------------------
This file defines the scripts that run on each level as follows:

boot single user (1)     --> rc.S
boot multi user (2-3)    --> rc.S, rc.M, rc.init
boot multiuser GUI (4-5) --> rc.S, rc.M, rc.init, rc.X

Switching from single user to multiuser TUI
From (1) to (2/3)    --> rc.M, rc.init

Switching from single user to multiuser GUI
From (1) to (4/5)    --> rc.M, rc.init, rc.X

Switching in TUI mode.
From (2/3) to (3/2)  --> rc.init (rc.M remains)

Switching from TUI to GUI.
From (2-3) to (4-5)  --> rc.init, rc.X

Switching in GUI mode.
From (4/5) to (5/4)  --> rc.init  (rc.M and rc.X remain)

Switching BACK from GUI to TUI
From (4-5) to (2-3)  --> rc.init  (rc.X quits)

Switching BACK from multiuser to single user
From (2-5) to (1)    --> rc.init, rc.1 (rc.X and rc.M quit)

Switching BACK from multiuser to reboot/halt
From (2-5) to (0/6)  --> rc.init, rc.0 (rc.X and rc.M quit)


WRITING a service script
--------------------------------------------------
Service script is the one that actually start or stop the service
(like sshd, samba, cups, etc). The service 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

