#!/bin/bash
#
# by: Brian Butler (20100902)
#
# Setup the first 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=bootbreak
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"

# Prompt the user before we make any changes to the system
cat <<EOL

*** NOTICE ***
This script will restart vserver to setup the excercise.
EOL
confirm
echo
echo -n "Setting up, one moment please... "

# Break the /etc/fstab and reboot
sed -i.bak 's/UUID/UID/' /etc/fstab &> /dev/null || exit

echo 'done!'
if [[ X"$1" != 'X--noreboot' ]]
then
	shutdown -r now
fi

exit 0
