#
# This program sets the bit in the control panel that forces
# new proms to use the old style hostid.  It needs to live in, and be 
# run from the same directory as a release 5 version of 'rw_eeprom' and 
# 'cp_update'.
# 
# usage: ./fix_prom
#
# HIDE

# @(#)xs_solaris/xs_solaris/FTutils/program_flash/fix_hostid.sh	1.2 Copyright Sun Microsystems.

#
# Check that the version of fix_hostid we are running is the one in
# the current directory.
#
if [ ! -f ./fix_hostid ]
then
	echo "You must run fix_hostid from the directory that contains it."
	echo "(ie you must do \"./fix_hostid\""
	exit 1
fi

if [ ! -f ./cp_update -o ! -f ./rw_eeprom ]
then
	echo "The current directory must contain \'cp_update\' and \'rw_eeprom\'"
	exit 1
fi

if ./rw_eeprom -l cp -r | ./cp_update -Z on | ./rw_eeprom -l cp -w
then
	echo "Fixed hostid."
	exit 0
else
	echo "Error while fixing hostid - probably failed to write to control panel"
	echo "(this might be because this is the secondary of a split system:"
	echo " if this is so, then try making this the primary and try again)"
	exit 1
fi

