138589SabialWarsaw, 1998.07.07
238589Sabial
338589SabialThis README shortly describes the features of "oinit" - a very simplistic
438589Sabialversion of init(8) combined with a shell.
538589Sabial
638589SabialFeatures
738589Sabial--------
838589Sabial
938589Sabial* oinit is able to run system in multi- and single-user modes,
1038589Sabial* it can be started on system with DEVFS/SLICE (i.e. empty /dev),
1138589Sabial* provides minimalistic user interface, called "shell()",
1238589Sabial* it can run the system startup script (/etc/rc),
1338589Sabial* it can be compiled with -DOINIT_RC to use its own startup script
1438589Sabial  (*very* primitive, but doesn't require any real shell to run it!),
1538589Sabial* doesn't require the whole chain of init->getty->login->shell to be run,
1638589Sabial* it is extremely small, and is ideally suited for situations when
1738589Sabial  there is little memory.
1838589Sabial
1938589SabialAs an additional bonus you receive some obvious and some hidden bugs... :-))
2038589SabialThis code is at most alpha quality yet.
2138589Sabial
2238589Sabial
2338589SabialHow it works
2438589Sabial------------
2538589Sabial
2638589SabialUnlike normal init(8), it forks itself on given number of vty's immediately
2738589Sabialproviding shell() interface. Currently it doesn't require (and is unable to
2838589Sabialperform) any authentication, but this is easy to add if needed.
2938589Sabial
3038589SabialStandard version of FreeBSD kernel looks for /sbin/init first, and then
3138589Sabialtries to execute it. If it fails, it tries to find:
3238589Sabial	/sbin/oinit
3338589Sabial	/sbin/init.bak
3438589Sabial	/stand/sysinstall
3538589Sabial
3638589SabialSo it is easy to make use of it even on standard system - just put it in
3738589Sabial/sbin/oinit and rename /sbin/init to something else, e.g. /sbin/init.bak.
3838589Sabial
3938589Sabial+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4038589Sabial!!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!!
4138589Sabial+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4238589SabialInit (or oinit) plays crucial role in the system. If you plan to do any
4338589Sabialchanges to your system's init, make sure you have a boot floppy with working
4438589Sabialversion of statically compiled init(8) on it - you can very easily put your
4538589Sabialsystem in unusable state when fiddling with it.
4638589Sabial+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
4738589Sabial
4838589SabialShell() interface
4938589Sabial-----------------
5038589Sabial
5138589SabialIt allows you to issue built-in and external commands. Built-in commands
5238589Sabialare listed below. For each command there is short help available, with
5338589Sabialexample of usage.
5438589Sabial
5538589Sabial	cd	change working directory
5638589Sabial	pwd	print working directory
5738589Sabial	set	set environment variable (no expansion)
5838589Sabial	unset	unset environment variable
5938589Sabial	env	print all environment variables
6038589Sabial	echo	echo arguments on stdout
6138589Sabial	exit	exit from shell (oinit will start a new one after some delay)
6238589Sabial	.	source-in a file with commands
6338589Sabial	?	help
6438589Sabial
6538589SabialAny other command is passed to execvp(3) as it is.
6638589Sabial
6738589SabialEXCEPTION: if you end the command line with a '&', the command is started
6838589Sabialas daemon. This is NOT the same as in normal shell, where the '&' puts a
6938589Sabialprocess in background. Here the newly started process is totally dissociated
7038589Sabialfrom terminal.
7138589Sabial
7238589SabialPrompt tells you:
7338589Sabial* your `pwd`
7438589Sabial* your PID
7538589Sabial* and that you are root ('#').
7638589Sabial
7738589SabialWARNING: this pseudo-shell doesn't do any expansion whatsoever.
7838589Sabial
7938589SabialTo do list
8038589Sabial----------
8138589Sabial
8238589Sabial- oinit proper:
8338589Sabial	* fix signal handling and transitions,
8438589Sabial	* invent a one-file configuration database (combining as many files
8538589Sabial	  from /etc as possible into one) able to properly handle inter-
8638589Sabial	  dependencies in running various daemons,
8738589Sabial	* allow for interpreting of such database, and running various
8838589Sabial	  programs ourselves (this would eventually allow to make /bin/sh
8938589Sabial	  an option, not necessity),
9038589Sabial	* better hooks for incorporating other modules into oinit (see e.g.
9138589Sabial	  the telnet() below),
9238589Sabial	* add optional authentication,
9338589Sabial
9438589Sabial- shell():
9538589Sabial	* more built-ins: perhaps 'kill' and 'ps',
9638589Sabial	* variable expansion,
9738589Sabial	* globbing,
9838589Sabial	* conditionals,
9938589Sabial	* history? (it depends on how much memory it needs).
10038589Sabial	* programmatic hooks for easy customisation of user interface (like
10138589Sabial	  hierarchy of commands and contexts),
10238589Sabial	* ...
10338589Sabial
10438589Sabial- implement as a routine (like shell()) a small remote login daemon telnet(),
10538589Sabial  as a built-in module to oinit. It would implement the simplest options of
10638589Sabial  normal telnet, and would itself handle authentication, passing control to
10738589Sabial  shell() on success. The authentication routine would be the same as for
10838589Sabial  checking console access.
10938589Sabial
11038589SabialAnd allow me for a moment of day-dreaming: I'd like to rewrite oinit one day
11138589Sabialto be a monolithic one-in-all application, non-forking but multithreaded... It
11238589Sabialwould contain all the modules, such as shell(), telnet(), ifconfig() etc...
11338589Sabialstarted as threads, not separate processes.
11438589Sabial
11538589SabialCredits
11638589Sabial-------
11738589Sabial
11838589SabialThe overall framework was taken from FreeBSD /sbin/init.
11938589Sabial
12038589SabialAndrzej Bialecki
12140813Sabial<abial@freebsd.org>
12238589Sabial
12350479Speter$FreeBSD$
124