#!/bin/bash
#
#  NAME
#	gls-munge-rootpw - change the root password to a random string
#
#  USAGE
#	gls-munge-rootpw [--noreboot]
#
#  DESCRIPTION
#	This script changes the root account password to an unknown
#	string then reboots the system.  This script is used in the
#	assessment lab that teaches learners how to boot into a specific
#	run-level.
#
#	The --noreboot option prevents the system from rebooting.
#
#  CHANGELOG
#	* Mon Jul 05 2010 George Hacker <ghacker@redhat.com>
#	- Original code

PATH=/bin:/usr/bin:/sbin:/usr/sbin

echo "test$$${RANDOM}" | passwd --stdin root

touch /tmp/.gls-munge-rootpw

if [[ X"$1" = 'X--noreboot' ]]
then
	# do not reboot
	exit 0
else
	reboot
fi
