#!/bin/sh
#
#ident	"@(#)smcpreconfig.sh	1.4	02/08/20 SMI"
#
# Copyright (c) 2001 by Sun Microsystems, Inc.
# All rights reserved.
#

# ******************************** NOTE ***************************************
# * Due to changes in the registration API in S9, this script no longer needs *
# * needs to be run and in fact will cause problems during upgrade from S8!   *
# * It now simply returns 0 but has left in place in case it is needed again  *
# * in the future. See bug 4704611 for further information.                   *
# *****************************************************************************

# SMC server pre-configuration script, which is executed when the server
# starts up but before any of the registrations take place.  Ideally,
# this is most useful when the server starts the 1st time after installation,
# to handle any upgrade issues, for example.  So in the face of multiple
# server restarts, it needs to be smart about not destroying the configuration 
# that was setup on the initial server start.



# This block will purge Solaris 8 SMC localization pkgs that are installed
# on a machine as a result of a fresh install of build 40 or greater.
#
# (This will actually find all Solaris 8 SMC pkgs, not just L10n, but in 
# reality they won't exist since they would have been upgraded by the time
# this script is run).

# echo "Searching for Solaris 8 Solaris Management Console localization pkgs..."

# Find all instances of .mcreg files that have "smcconf" in them
#
# cd /usr/sadm/lib/smc/prereg
# mcregs=""
# for i in `find . -name "*.mcreg"`
# do
#    grepout=`grep smcconf ${i}`
#    if [ -n "${grepout}" ]; then
	
#        mcregs="${mcregs} `basename ${i}`"
#    fi
# done

# Find the pkgs that own these .mcreg files
#
# pkgs=""
# for i in ${mcregs}
# do
#     pkgs="${pkgs} `grep ${i} /var/sadm/install/contents | awk '{print $10}'`"
# done

# if [ "${pkgs}" = "" ]; then
#    echo "No old localizations found."
# else
#    echo "Found pkgs: ${pkgs};  will now remove them."
# fi


# Silently purge those pkgs

# ADMIN=/tmp/admin.$$

# cat << \ADMIN_EOF > ${ADMIN}
# mail=
# instance=unique
# partial=nocheck
# runlevel=nocheck
# idepend=nocheck
# rdepend=nocheck
# space=ask
# setuid=nocheck
# conflict=nocheck
# action=nocheck
# basedir=default
# ADMIN_EOF

# for pkg in ${pkgs}
# do
#    pkgrm -n -a ${ADMIN} ${pkg}
# done

# rm -f ${ADMIN}

# IMPORTANT!  Delete entries that have a "/bin/rm\ -f\" directive without
# an argument.  Otherwise, the /bin symbolic link is removed!
# Dunno why there's no argument here - maybe L10n folks did something
# outside the scope of the SUNW0mc build scripts which the scripts do not 
# check for.
#
# OUT=/var/sadm/smc/properties/registry.properties.$$
# IN=/var/sadm/smc/properties/registry.properties
# if [ -f ${IN} ]; then
#    sed -e 's@remove=/bin/rm\\ -f\\@remove=@' ${IN} > ${OUT}
#    cp ${OUT} ${IN}
#    rm -f ${OUT}
# fi

exit 0
