#!/bin/bash
#
# firstboot:         Starts the firstboot druid if it hasn't been run before
#
# chkconfig: 5 95 95
#
# description:       Firstboot is a druid style program that runs on the first time /
#                    a machine is booted after install.  It checks for the existence /
#                    of an /etc/sysconfig/firstboot file.  If it doesn't find the file, /
#                    then the firstboot program needs to run.  If it finds the file, /
#                    firstboot will not be run.
#                    If /etc/reconfigSys exists, run the reconfiguration
#		     program and remove /etc/reconfigSys when done.
#
#                    Also will run if 'reconfig' is on the kernel cmdline.
#
# Source function library.
. /etc/init.d/functions
[ -f /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LANG

FILENAME=/etc/sysconfig/firstboot

[ -z "$HOME" ] && export HOME=/

case "$1" in
 start)
        if [ ! -f /etc/X11/XF86Config ] ; then
           echo -n "X is not configured.  Running redhat-config-xfree86"
	   /usr/bin/redhat-config-xfree86
	   echo -n "X is now configured.  Starting Setup Agent"
	fi

        if grep -i reconfig /proc/cmdline >/dev/null || [ -f /etc/reconfigSys ]; then
	    echo -n "Running system reconfiguration tool"
	    /usr/sbin/firstboot --reconfig
	    rm -f /etc/reconfigSys
	    exit 0
	fi

	/usr/sbin/firstboot
	exit 0
	;;
esac

exit $RETVAL
