Cleanup and simplify boot process messages

- Remove indentation of module loading and device node creation
- Clarify that we load kernel modules
- Clarify that we load Finit plugins
- Remove cls()
- Remove verbose condition for echo()
- Make banner a separate function with optional distribution banner
- Add a few neat ANSI escape sequences for cls(), clreol(), delline(), etc.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
libite: Add strtonum() from OpenBSD

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Build: Make subdir build prettier.

The ROOTDIR variable was only set in the top-level Makefile,
so when building from a subdirectory the output was slightly
garbled.  Moved ROOTDIR declaration to common.mk.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
tty: Check input arguments for invalid tty before adding.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Bugfix chomp() and set_hostname()

chomp():
        Removed first \n instead of last \n

set_hostname():
        If /etc/hostname exists we need to realloc the size of
        the current hostname variable. Also, only try to set
        the hostname if !NULL

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Refactor .conf file parser and add support for runlevel N

This commit is a refactor of how arguments to finit.conf file settings
are parsed.  Not all settings are run directly, but only need the arg
for future use.  The code should be a lot easier to understand now.

Also, added support for specifying the desired runlevel in finit.conf

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Update and clarify TODO items, e.g., add info on new "task" and "run" stanzas

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Rename USE_UDEV & MDEV to SETUP_DEVFS and USE_MESSAGE_BUS to HAVE_DBUS

USE_UDEV,MDEV   => Unique SETUP_DEVFS for embedded or distro usage.
USE_MESSAGE_BUS => HAVE_DBUS

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Improve runlevel support by adding a bootstrap phase, also adds task/run cmd

Most systems need an early bootstrap phase for one-shot tasks and
necessary one-time probing.  This phase usually runs well before any
networking is setup.  This commit adds support for that 'S' runlevel,
and also extends the number of possible total runlevels to nine.

For the one-shot tasks that run in bootstrap two new finit.conf cmds
have been added:

   - task: For one-shot tasks that can be started in parallell
   - run:  For one-shot tasks that must run in sequence

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Coding style and whitespace fixes

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Update Debian 6.0 example /etc/finit.conf and /etc/finit.d

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Rename stat_restart_counter --> restart_counter

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Refactor TTY code to honor runlevels and use I/O plugin to watch /dev

Add support for runlevels to tty command and support for reading baud
rate and TERM variable from finit.conf.

The tty-watcher thread has been converted to a standard I/O plugin.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Store RUN_LVL in UTMP and change RUNLEVEL_BOOT from 10 to 0

Standard init implementations save current and previous runlevels
in utmp, now finit does too.  Also, the initial runlevel at boot
has changed from 10 to the more obvious 0.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Build fix, if ROOTDIR was set linking failed. Use TOPDIR internally.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
tty: Use calloc() instead of malloc() to prevent uninitialized errors.

On some platforms GCC does not zero the heap. This can lead to
serious problems, e.g., tty->pid may be non-zero while never
having been started.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Simplify banner further, let distributions patch us instead.

Revert crazy BANNER macro idea from 5ba7bc1.  It is simply too difficult to
set -DBANNER='"Some distributions specific text"' in a parent Makefile
without entering Shell/Make escape hell ... instead, downstream will
have to patch the banner() function.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
tty: Clear PID to be able to respawn it.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Minor cleanup.
Delay start of TTYs to let system stabilize at boot.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>