/*
 * Module Name	: envbuild - build and configure the Informix Online Server 
 *
 * Usage        : envbuild [ configuration file ]
 *
 * Arguments    : configuration file - an optional configuration file rather
 *                                       than the default envbuild.cfg
 *
 * Description  : envbuild builds the Informix Online engine from a default 
 *                installation of the Informix product to a fully configured 
 *                runtime installation. 
 *
 *                envbuild performs the following sequence of serially dependent 
 *                operations:
 *
 *                The informix environment variables are used to determine where
 *                the Informix installation resides and what the server and 
 *                configuration file should be called.
 *
 *                A copy of $INFORMIXDIR/etc/onconfig.std is used as a 
 *                "boiler plate" for the configuration. 
 *              
 *                This file is named $INFORMIXDIR/etc/$ONCONFIG and is
 *                modified to default values below:
 *
 *                      BUFFERS 200
 *                      LOGFILES 3
 *                      LOGSIZE 500
 *                      LOGSMAX 256
 *                      TAPEDEV /dev/null
 *                      LTAPEDEV /dev/null
 *
 *                The above values allow the startup of a minimal Informix 
 *                installation.
 *
 *                Once the $ONCONFIG configuraton file has been changed, a 
 *                check is made to see whether an instance of this server is 
 *                running. If it is the user has the option of aborting or 
 *                continuing with the build. If the user decides to continue, 
 *                it will result in the installation being fully reinitialised 
 *                and the existing disk fragments will be overwritten.
 *
 *                The configuration file is read for the location of the 
 *                rootdbs and these parameters are then put into the 
 *                current configuration file and the engine is initialised 
 *                to single user mode.
 *
 *                Providing this is successful the remaining database spaces 
 *                are built. 
 *
 *                It is now time to make the new logical logs. This process 
 *                involves two backups of the database. This is because before 
 *                a log can be used, it the database must be backed up with a 
 *                level 0 archive. This is accomplished by issuing an ontape 
 *                -s command. For more on the pedantics of Informix, consult 
 *                the Informix Online Engine System Administration Guide, 
 *                volumes 1 and 2. The initial logs which reside in the 
 *                rootdbs database space are then dropped as they are no 
 *                longer required.
 *
 *                Once the logs are available, it is time to build the 
 *                sysmaster database which contain the system catalogues. 
 *                This is quite an onerous task for some reason and we have to 
 *                wait for it to complete before backing up Informix.
 *
 *                This frees the logs which we have just created and allows us 
 *                to force the checkpoint onto the new logs so that we can 
 *                drop the root logs.
 *
 *                Once the root logs have been dropped, our task is almost 
 *                finished all that remains now is to optimise the database 
 *                and then check out the system catalogs.
 *
 *                All done.
 *                
 *
 * Notes        : Using the "boiler plate" method rather than including a full 
 *                set of configuration defaults in the envbuild.cfg file was 
 *                chosen due to the substantial changes which were made 
 *                between 7.10UC1 and 7.10 UD1.
 *
 *                Suggested improvements would include:
 *
 *                   the ability to monitor the smi thread which builds the
 *                   sysmaster database rather than just waiting a fixed period
 *                   of time.
 *
 *                   More urgently is the ability to handle multiple databases 
 *                   in the function MoveLogs - this is not difficult to do - 
 *                   but there is not needed for release 1.0.
 *
 *                   Return values are ignored from most Functions and logging
 *                   is not exactly consistent.
 *
 *                   Ability to move the physical log from the rootdbs
 *
 * External 
 * Interfaces   : This program writes a log file (by default envbuild.log) to
 *                the current directory. If you desire an alternate location or
 *                name the set LOGFILE in your environment to point to that 
 *                location.
 *
 *                Log file Spinning
 *                -----------------
 *
 *                To ensure that the logfile $_LOGFILE does not grow too large, 
 *                it is "spun" when it reaches 500000 bytes to ${_LOGFILE}-1
 * 
 *                Environment Variables
 *                ---------------------
 *
 *                INFORMIXDIR 
 *                ONCONFIG 
 *                PATH 
 * 
 *                are taken from the environment 
 *
 *
 * Configuration
 * File
 * Layout       : The config file is a colon delimited file and looks like this
 *
 *      
    DBROOT:rootdbs:1:0:0:/blah/data/rootdbs:0:10000:/blah/rootmirror:0
    DBLOG:logspace:0:0:0:/blah/data/logspace:0:5000::
    DBSPACE:airframe:1:0:0:/blah/data/airframe:0:5000:/blah/generalmirror:0
    DBCHUNK:airframe:/inf_chunks/airframechunk2:0:5000:/blah/generalmirror:22500
    CONFIG:BUFFERS:2000
    CONFIG:CLEANERS:2
    CONFIG:LOGFILES:10

 * The file is basically split up by type of entry:
 *
 * DBROOT       : This is the definition of the root db space. The fields and
 *                their values are:
 *   
 *              1 - DBROOT - this is the type identifier and is always DBROOT
 *
 *              2 - rootdbs - this will always be rootdbs
 *   
 *              3 - mirror - 1 if the chunk is mirrored 0 otherwise
 *
 *              4 - temp - 1 if the chunk is a temporary space 0 otherwise
 *   
 *              5 - blob - 1 if this is a blob space - not implemented - always 0
 *
 *              6 - file - the device name for this chunk - system dependent
 *   
 *              7 - offset - any initial file offset used - normally 0
 *
 *              8 - size - in K of the chunk
 *
 *              9 - file - path of the mirror
 *              
 *             10 - offset - any initial offset
 *
 * DBLOG        : This is the definition of the logfile dbspace. The fields and
 *                their values are as for DBROOT
 *
 * DBCHUNK      : This is the definition of an additional chunk for a dbspace.
 *                The fields and their values are as DBROOT
 *
 * CONFIG       : This is a runtime configuration variable that will be set
 *                when Informix starts up.
 *              
 *              1 - CONFIG - this is the type identifier and is always CONFIG
 *
 *              2 - parameter - this the name of onconfig parameter which you
 *                              wish to set.
 *
 *              3 - value - the value you want it set to.
 *
 *
 * See Also     : $INFORMIXDIR/bin/oncheck which is documented in
 *                the Informix Online System Administration Manual
 *
 * Functions    : 
 *
 * Name         : envbuild - build and configure the Informix Online Server 
 * Name         : Working - Display an activity whilst Informix is starting up 
 * Name         : NotWorking - When job has finished, the activity indicator process
 * Name         : LogMesg - log a message to a file
 * Name         : OverWrite
 * Name         : SetConfigParameter - set a config parameter in the Informix onconfig file
 * Name         : SetAndCheckDevice
 * Name         : CopyOnconfigFile - set up the Informix enviroment
 * Name         : SetOnconfigFile - Setup the Informix configuration file
 * Name         : BuildRootDbspace - Build the rootdbs space 
 * Name         : IsOnlineUp - is the current engine running in ?
 * Name         : ShutDownOnline - shut down this instance of the online engine
 * Name         : CreateDbSpaces - create database spaces
 * Name         : MakeLogs - construct the Informix Logs
 * Name         : BackUpToDevNull - back the informix database
 * Name         : MoveCheckPoint - move the informix checkpoint into the new logs
 * Name         : DropRootLogs  - Drop the logs in rootdbs
 * Name         : ChangeOnlineMode - is the current engine running in ?
 */



Author: Graeme Burnett    
Draft
  Last Updated :