#!/bin/bash
#
# chkconfig: 345 7 93
# description: Eos system stage 1 init script (runs after POST, as early as
# possible in the boot sequbefore ProcMgr). Is responsible for setting up all
# of the low level setup that must be done before agents are started, etc.
# Includes running the rc.aros script for local personalization.

# XXX_LWR: figure out the exact numbers at which this script runs
#          (currently 7 and 93). This makes Eos stage 1 init run before
#          anything else in our boot sequence, allowing everything to be
#          patchable through rc.aros.

# This script is written as a bash script, calling /usr/bin/EosInitStage --stage 1
# to do all of the real work, so that we can use the existing code to
# print 'OK'/'FAIL' at bootup time.

. /etc/rc.d/init.d/functions

start() {
    echo -n $"Starting EOS initialization stage 1: "
    # Redirect stdin to prevent EosInitStage from dropping into the debugger on failure
    if /usr/bin/EosInitStage --stage 1 </dev/null >>/var/log/EosInitStage 2>&1; then
        success
        echo
    else
        # If EosInitStage fails, the system is pretty much hosed
        failure
        echo
        echo $"   (errors in /var/log/EosInitStage; log in as 'root' to troubleshoot)"
        exit 1
    fi
}

# Once we figure out what it means to "stop" Eos, add support to do
# that here.
case "$1" in
start)
    start
    ;;
stop)
   ;;
*)
    echo $"Usage: $0 {start}"
    exit 1
esac
