# This script initializes the backout data for a patch package
# directory format options.
# 
#       @(#)preinstall 1.10 99/04/23 SMI
#
# Copyright (c) 1995 by Sun Microsystems, Inc.
# All rights reserved
#

SCRIPT=`echo $0 | sed 's,.*/,,'`

error() {
	echo "$SCRIPT: ERROR: $*" > /dev/console
	exit 1
}

CONFIGFILE=$PKG_INSTALL_ROOT/etc/SUNWcms/.config/configfile

CONFIGFILE=/etc/SUNWcms/.config/configfile
SAVCONFIGFILE=$PKGSAV/configfile

# Restore the old configfile - if present
[ -f $SAVCONFIGFILE ] && {
	cp -p $SAVCONFIGFILE $CONFIGFILE ||
	error "cp(1) failed for file: $SAVCONFIGFILE"
	exit 1
}

# Otherwise, create the minimal valid configfile
echo -1 > $CONFIGFILE ||
	error "Failed to create the config file: $CONFIGFILE"

# Now reconstruct the cmsd.conf to remove the no longer extant cmsdef .so
# First produce a list of the currently available .sos
CMSHOME=$PKG_INSTALL_DIR/usr/platform/SUNW,Ultra-4FT/SUNWcms
find $CMSHOME/etc/cmsdef.d | sort | sed 's,.*/,,; s,\.so,,' > /tmp/cmsd.conf ||
	exit 1

# Now move the temporary file into place
mv /tmp/cmsd.conf $CMSHOME/etc/cmsdef.d/cmsdef.conf ||
	error "mv(1) filaed for cmsd.conf"

exit 0
