#!/bin/sh
# $Id: backto40,v 1.5 2004/05/03 18:00:46 jp148923 Exp $

#    SAM-QFS_notice_begin
#
#   Solaris 2.x Sun Storage & Archiving Management File System
#
#   Copyright (c) 2004 Sun Microsystems, Inc.
#   All Rights Reserved.
#
#   Government Rights Notice
#   Use, duplication, or disclosure by the U.S. Government is
#   subject to restrictions set forth in the Sun Microsystems,
#   Inc. license agreements and as provided in DFARS 227.7202-1(a)
#   and 227.7202-3(a) (1995), DRAS 252.227-7013(c)(ii) (OCT 1988),
#   FAR 12.212(a)(1995), FAR 52.227-19, or FAR 52.227-14 (ALT III),
#   as applicable.  Sun Microsystems, Inc.
#
#    SAM-QFS_notice_end

echo " "

ETCDIR=/etc/opt/SUNWsamfs
SBINDIR=/opt/SUNWsamfs/sbin

#  Function definitions

#  main script.

if [ -d /var/sadm/pkg/SUNWsamfsr ]; then
	echo "Converting back a SAM-FS/QFS system"

	echo "Renaming files to the 4.0 names."

	# rename rft.cmd to ftp.cmd

	if [ ! -f ${ETCDIR}/ftp.cmd ] ; then
		if [ -f ${ETCDIR}/rft.cmd ] ; then
			/bin/cp ${ETCDIR}/rft.cmd ${ETCDIR}/ftp.cmd
		fi
	fi


	if [ ! -f ${ETCDIR}/LICENSE.4.0 ]; then
		echo " "
		echo "No LICENSE.4.0 file exists copying LICENSE.4.1 to LICENSE.4.0"
		echo " "
		/bin/cp ${ETCDIR}/LICENSE.4.1 ${ETCDIR}/LICENSE.4.0
	else
		/bin/diff ${ETCDIR}/LICENSE.4.1 ${ETCDIR}/LICENSE.4.0 > /dev/null
		if [ $? -ne 0 ]; then
			echo " "
			echo "Your 4.1 License is different from your 4.0 License"
			echo "Leaving both Licenses as they are. Upgrading to 4.1"
			echo "in the future will not run the upgrade scripts because"
			echo "the LICENSE.4.1 file will exist"
			echo " "
		else
			echo " "
			echo "Removing /etc/opt/SUNWsamfs/LICENSE.4.1 file, so a future upgrade"
			echo "will copy all necessary files to the correct locations"
			echo " "
			rm ${ETCDIR}/LICENSE.4.1
		fi
	fi

	echo "Conversion to the 4.0 names complete."
else
	echo "Converting back for a Standalone QFS system"
fi

# Save any hosts information for shared filesystems

${SBINDIR}/backto40shared
