#!/usr/bin/sh
#
# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# ident	"@(#)postinstall	1.1	06/03/06 SMI"
#

# Detect and repair any UUID duplicates.
index=$BASEDIR/etc/zones/index
if [ -f $index ]; then
	if nawk -F: '
		/^\#/ || NF != 4 { print $0; next; }
		{
			if (flags[$4])
				sub(/:[-0-9a-z]*$/,":");
			print $0;
			flags[$4]=1;
		}
	' < $index > ${index}.pkg.$$; then
		if cmp -s $index ${index}.pkg.$$; then
			rm -f ${index}.pkg.$$
		else
			chown root:sys ${index}.pkg.$$
			chmod 644 ${index}.pkg.$$
			mv ${index}.pkg.$$ $index
		fi
	else
		rm -f ${index}.pkg.$$
	fi
fi

exit 0
