#!/sbin/sh
#
# @(#) $Revision: 78.1 $
#
# NOTE:    This script is not configurable!  Any changes made to this
#          scipt will be overwritten when you upgrade to the next
#          release of HP-UX.
#
# WARNING: Changing this script in any way may lead to a system that
#          is unbootable.  Do not modify this script.
#

#
# Confirm that the date and time are correct.
#
# Systems with battery-backed real-time clock will be correct.  Therefore,
# the default answer is yes.
#
# The question will timeout in $DATE_TIMEOUT seconds.  If the question
# is not answered within the specified timeout, the default answer will
# be returned.  To increase the timeout, change the value assigned to
# DATE_TIMEOUT (in /etc/rc.config). A DATE_TIMEOUT of 0 will skip this
# question.
#

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

rval=0
set_return() {
	x=$?
	if [ $x -ne 0 ]; then
		echo "EXIT CODE: $x"
		rval=1
	fi
}

case $1 in
start_msg)
	echo "Display date"
	;;

'start')
	if [ -f /etc/rc.config.d/set_date ] ; then
		. /etc/rc.config.d/set_date
	else
		echo "ERROR: /etc/rc.config.d/set_date defaults file MISSING"
	fi
	
	if [ -n "$DATE_TIMEOUT" -a "$DATE_TIMEOUT" != 0 ]; then
		echo "\007Is the date `date` correct? (y or n, default: y) \c"
		reply=`line -t $DATE_TIMEOUT`
		echo ""

		if [ "$reply" = y -o "$reply" = "" -o "$reply" = Y ]; then
			return
		elif [ -x /sbin/set_parms ]; then
			/sbin/set_parms date_time
			set_return
		fi

	else
		rval=2
	fi
	;;

*)
	echo "usage: $0 {start}"
	rval=1
	;;
esac

exit $rval
