1c9d8fd0aSAndrzej BialeckiWarsaw, 1998.07.07 2c9d8fd0aSAndrzej Bialecki 3c9d8fd0aSAndrzej BialeckiThis README shortly describes the features of "oinit" - a very simplistic 4c9d8fd0aSAndrzej Bialeckiversion of init(8) combined with a shell. 5c9d8fd0aSAndrzej Bialecki 6c9d8fd0aSAndrzej BialeckiFeatures 7c9d8fd0aSAndrzej Bialecki-------- 8c9d8fd0aSAndrzej Bialecki 9c9d8fd0aSAndrzej Bialecki* oinit is able to run system in multi- and single-user modes, 10c9d8fd0aSAndrzej Bialecki* it can be started on system with DEVFS/SLICE (i.e. empty /dev), 11c9d8fd0aSAndrzej Bialecki* provides minimalistic user interface, called "shell()", 12c9d8fd0aSAndrzej Bialecki* it can run the system startup script (/etc/rc), 13c9d8fd0aSAndrzej Bialecki* it can be compiled with -DOINIT_RC to use its own startup script 14c9d8fd0aSAndrzej Bialecki (*very* primitive, but doesn't require any real shell to run it!), 15c9d8fd0aSAndrzej Bialecki* doesn't require the whole chain of init->getty->login->shell to be run, 16c9d8fd0aSAndrzej Bialecki* it is extremely small, and is ideally suited for situations when 17c9d8fd0aSAndrzej Bialecki there is little memory. 18c9d8fd0aSAndrzej Bialecki 19c9d8fd0aSAndrzej BialeckiAs an additional bonus you receive some obvious and some hidden bugs... :-)) 20c9d8fd0aSAndrzej BialeckiThis code is at most alpha quality yet. 21c9d8fd0aSAndrzej Bialecki 22c9d8fd0aSAndrzej Bialecki 23c9d8fd0aSAndrzej BialeckiHow it works 24c9d8fd0aSAndrzej Bialecki------------ 25c9d8fd0aSAndrzej Bialecki 26c9d8fd0aSAndrzej BialeckiUnlike normal init(8), it forks itself on given number of vty's immediately 27c9d8fd0aSAndrzej Bialeckiproviding shell() interface. Currently it doesn't require (and is unable to 28c9d8fd0aSAndrzej Bialeckiperform) any authentication, but this is easy to add if needed. 29c9d8fd0aSAndrzej Bialecki 30c9d8fd0aSAndrzej BialeckiStandard version of FreeBSD kernel looks for /sbin/init first, and then 31c9d8fd0aSAndrzej Bialeckitries to execute it. If it fails, it tries to find: 32c9d8fd0aSAndrzej Bialecki /sbin/oinit 33c9d8fd0aSAndrzej Bialecki /sbin/init.bak 34c9d8fd0aSAndrzej Bialecki /stand/sysinstall 35c9d8fd0aSAndrzej Bialecki 36c9d8fd0aSAndrzej BialeckiSo it is easy to make use of it even on standard system - just put it in 37c9d8fd0aSAndrzej Bialecki/sbin/oinit and rename /sbin/init to something else, e.g. /sbin/init.bak. 38c9d8fd0aSAndrzej Bialecki 39c9d8fd0aSAndrzej Bialecki+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40c9d8fd0aSAndrzej Bialecki!!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! WARNING !!! 41c9d8fd0aSAndrzej Bialecki+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42c9d8fd0aSAndrzej BialeckiInit (or oinit) plays crucial role in the system. If you plan to do any 43c9d8fd0aSAndrzej Bialeckichanges to your system's init, make sure you have a boot floppy with working 44c9d8fd0aSAndrzej Bialeckiversion of statically compiled init(8) on it - you can very easily put your 45c9d8fd0aSAndrzej Bialeckisystem in unusable state when fiddling with it. 46c9d8fd0aSAndrzej Bialecki+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47c9d8fd0aSAndrzej Bialecki 48c9d8fd0aSAndrzej BialeckiShell() interface 49c9d8fd0aSAndrzej Bialecki----------------- 50c9d8fd0aSAndrzej Bialecki 51c9d8fd0aSAndrzej BialeckiIt allows you to issue built-in and external commands. Built-in commands 52c9d8fd0aSAndrzej Bialeckiare listed below. For each command there is short help available, with 53c9d8fd0aSAndrzej Bialeckiexample of usage. 54c9d8fd0aSAndrzej Bialecki 55c9d8fd0aSAndrzej Bialecki cd change working directory 56c9d8fd0aSAndrzej Bialecki pwd print working directory 57c9d8fd0aSAndrzej Bialecki set set environment variable (no expansion) 58c9d8fd0aSAndrzej Bialecki unset unset environment variable 59c9d8fd0aSAndrzej Bialecki env print all environment variables 60c9d8fd0aSAndrzej Bialecki echo echo arguments on stdout 61c9d8fd0aSAndrzej Bialecki exit exit from shell (oinit will start a new one after some delay) 62c9d8fd0aSAndrzej Bialecki . source-in a file with commands 63c9d8fd0aSAndrzej Bialecki ? help 64c9d8fd0aSAndrzej Bialecki 65c9d8fd0aSAndrzej BialeckiAny other command is passed to execvp(3) as it is. 66c9d8fd0aSAndrzej Bialecki 67c9d8fd0aSAndrzej BialeckiEXCEPTION: if you end the command line with a '&', the command is started 68c9d8fd0aSAndrzej Bialeckias daemon. This is NOT the same as in normal shell, where the '&' puts a 69c9d8fd0aSAndrzej Bialeckiprocess in background. Here the newly started process is totally dissociated 70c9d8fd0aSAndrzej Bialeckifrom terminal. 71c9d8fd0aSAndrzej Bialecki 72c9d8fd0aSAndrzej BialeckiPrompt tells you: 73c9d8fd0aSAndrzej Bialecki* your `pwd` 74c9d8fd0aSAndrzej Bialecki* your PID 75c9d8fd0aSAndrzej Bialecki* and that you are root ('#'). 76c9d8fd0aSAndrzej Bialecki 77c9d8fd0aSAndrzej BialeckiWARNING: this pseudo-shell doesn't do any expansion whatsoever. 78c9d8fd0aSAndrzej Bialecki 79c9d8fd0aSAndrzej BialeckiTo do list 80c9d8fd0aSAndrzej Bialecki---------- 81c9d8fd0aSAndrzej Bialecki 82c9d8fd0aSAndrzej Bialecki- oinit proper: 83c9d8fd0aSAndrzej Bialecki * fix signal handling and transitions, 84c9d8fd0aSAndrzej Bialecki * invent a one-file configuration database (combining as many files 85c9d8fd0aSAndrzej Bialecki from /etc as possible into one) able to properly handle inter- 86c9d8fd0aSAndrzej Bialecki dependencies in running various daemons, 87c9d8fd0aSAndrzej Bialecki * allow for interpreting of such database, and running various 88c9d8fd0aSAndrzej Bialecki programs ourselves (this would eventually allow to make /bin/sh 89c9d8fd0aSAndrzej Bialecki an option, not necessity), 90c9d8fd0aSAndrzej Bialecki * better hooks for incorporating other modules into oinit (see e.g. 91c9d8fd0aSAndrzej Bialecki the telnet() below), 92c9d8fd0aSAndrzej Bialecki * add optional authentication, 93c9d8fd0aSAndrzej Bialecki 94c9d8fd0aSAndrzej Bialecki- shell(): 95c9d8fd0aSAndrzej Bialecki * more built-ins: perhaps 'kill' and 'ps', 96c9d8fd0aSAndrzej Bialecki * variable expansion, 97c9d8fd0aSAndrzej Bialecki * globbing, 98c9d8fd0aSAndrzej Bialecki * conditionals, 99c9d8fd0aSAndrzej Bialecki * history? (it depends on how much memory it needs). 100c9d8fd0aSAndrzej Bialecki * programmatic hooks for easy customisation of user interface (like 101c9d8fd0aSAndrzej Bialecki hierarchy of commands and contexts), 102c9d8fd0aSAndrzej Bialecki * ... 103c9d8fd0aSAndrzej Bialecki 104c9d8fd0aSAndrzej Bialecki- implement as a routine (like shell()) a small remote login daemon telnet(), 105c9d8fd0aSAndrzej Bialecki as a built-in module to oinit. It would implement the simplest options of 106c9d8fd0aSAndrzej Bialecki normal telnet, and would itself handle authentication, passing control to 107c9d8fd0aSAndrzej Bialecki shell() on success. The authentication routine would be the same as for 108c9d8fd0aSAndrzej Bialecki checking console access. 109c9d8fd0aSAndrzej Bialecki 110c9d8fd0aSAndrzej BialeckiAnd allow me for a moment of day-dreaming: I'd like to rewrite oinit one day 111c9d8fd0aSAndrzej Bialeckito be a monolithic one-in-all application, non-forking but multithreaded... It 112c9d8fd0aSAndrzej Bialeckiwould contain all the modules, such as shell(), telnet(), ifconfig() etc... 113c9d8fd0aSAndrzej Bialeckistarted as threads, not separate processes. 114c9d8fd0aSAndrzej Bialecki 115c9d8fd0aSAndrzej BialeckiCredits 116c9d8fd0aSAndrzej Bialecki------- 117c9d8fd0aSAndrzej Bialecki 118c9d8fd0aSAndrzej BialeckiThe overall framework was taken from FreeBSD /sbin/init. 119c9d8fd0aSAndrzej Bialecki 120c9d8fd0aSAndrzej BialeckiAndrzej Bialecki 121e0b7bc57SAndrzej Bialecki<[email protected]> 122c9d8fd0aSAndrzej Bialecki 123*97d92980SPeter Wemm$FreeBSD$ 124