#!/bin/bash
#
# by: Brian Butler (20100902)
#     George Hacker (20101201) Implemented RH124 boot unit criterion test.
#

# Setup the fifth boot trouble shooting lab
# this script is to be installed and run on serverX.example.com
# output is logged to syslog

# Set environment and declare global variables
. /usr/local/lib/labtool.shlib
trap on_exit EXIT
LOG_FACILITY=local0
LOG_PRIORITY=info
LOG_TAG=bootbreak6
DEBUG=false
ERROR_MESSAGE="Error running script. Contact your instructor if you continue to see this message."
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
userInput="no"
set -o pipefail

# Check to make sure we are running as root
check_root

# Check to make sure we are running on the correct host
check_host "server"

# Confirm new kernel is installed
if [ $( rpm -q kernel | wc -l ) -gt 1 ] ; then
    echo "Updated kernel installed PASS"
else
    echo "Updated kernel installed FAIL"
    fail=1
fi
echo ""

# Confirm original kernel is the default
if [ "$(uname -r)" = 2.6.32-71.el6.x86_64 ] ; then
    echo "Original kernel is default PASS"
else
    echo "Original kernel is default FAIL"
    fail=1
fi
echo ""

# selinux=1 argument has been passed at boot time
if grep 'selinux=1' /proc/cmdline >& /dev/null ; then
    echo "selinux=1 passed as kernel argument PASS"
else
    echo "selinux=1 passed as kernel argument FAIL"
    fail=1
fi
echo ""

# Runlevel 3 is the default in /etc/inittab
if grep '^id:3:initdefault:' /etc/inittab >& /dev/null ; then
    echo "Runlevel 3 is default PASS"
else
    echo "Runlevel 3 is default FAIL"
fi
echo ""

if [ "$fail" = 1 ] ; then
    echo "Please check your configuration and try again."	    
fi

echo 'done!'

exit 0
