displayHeader()
{
clear
if [ "$PRODUCT_BRAND_LONG" = "" ]; then
	echo "$PRODUCT_BRAND Services Install Script $SCRIPT_VER"
else
	echo "$PRODUCT_BRAND_LONG ($PRODUCT_BRAND) Services Install Script $SCRIPT_VER"
fi
echo "[`$NOW`] Installer started."

echo "[`$NOW`] Operating System detected as $_FC_PLATFORM on $cpu_type hardware."
echo ""
}

displayInstallerName()
{
if [ -e "$FCSD_TAR" ]; then
	if [ -e "$FCNSBUS_TAR" ]; then
		if [ -e "$FCNSEDU_TAR" ]; then
			THIS_INSTALLER_NAME="FirstClass Services Universal Installer$TYPE_SUFFIX"
		else
			THIS_INSTALLER_NAME="FirstClass Server Full Installer$TYPE_SUFFIX"
		fi
	elif [ -e "$FCNSEDU_TAR" ]; then
		THIS_INSTALLER_NAME="FirstClass Server Full Installer$TYPE_SUFFIX"
	elif [ -e "$FCNSARCH_TAR" ]; then
		THIS_INSTALLER_NAME="$PRODUCT_BRAND Archive Server Installer$TYPE_SUFFIX"
        elif [ -e "$FCNSOTSM_TAR" ]; then
                THIS_INSTALLER_NAME="$PRODUCT_BRAND Server Installer$TYPE_SUFFIX"
	elif [ -e "$FCISD_TAR" ]; then
		THIS_INSTALLER_NAME="$PRODUCT_BRAND Services Updater"
	else
		THIS_INSTALLER_NAME="$PRODUCT_BRAND Server Updater"
	fi
else
	if [ -e "$FCISD_TAR" ]; then
		THIS_INSTALLER_NAME="$PRODUCT_BRAND Internet Services Executable Updater"
	elif [ "$INSTALL_FCNS" -eq "1" ] ; then
		echo "Error: No executable tar files found.  Nothing to install."
		echo "You must put at least one of the component tar packages in the \"files\" subfolder."
		cleanup
		exit 1
	elif [ -e "$ADDON_TAR" ]; then
		THIS_INSTALLER_NAME="$PRODUCT_BRAND Component Installer"
	else
		echo "Error: No executable tar files, or add-on components found.  Nothing to install."
		echo "You must put at least one of the component tar packages in the \"files\" subfolder."
		cleanup
		exit 1	    
	fi
fi
}



displayIncludedFiles()
{
	echo
	if [ -e "$FCSD_TAR" -o -e "$FCISD_TAR" -o -e "$FCNSBUS_TAR" -o -e "$FCNSEDU_TAR" -o -e "$FCNSARCH_TAR" -o -e "$UPGRADE_TAR"  -o -e "$ADDON_TAR" -o -e "$FCNSOTSM_TAR" ]; then
		if [ ! -e "$ADDON_TAR" ]; then
			if [ -e "$FCSD_TAR" -a `cpu_compatibilty_check "$FCSD_TYPE"` -eq 1 ]; then 
				echo "$THIS_INSTALLER_NAME for $_FC_PLATFORM"
				echo "This $THIS_INSTALLER_TYPE includes the following:"
			elif [ -e "$FCISD_TAR" -a `cpu_compatibilty_check "$FCISD_TYPE"` -eq 1 ]; then 
				echo "$THIS_INSTALLER_NAME for $_FC_PLATFORM"
				echo "This $THIS_INSTALLER_TYPE includes the following:"
			else
				echo "Nothing to install..."
				cleanup
				exit 1
			fi
		else
			echo "$THIS_INSTALLER_NAME for $_FC_PLATFORM"
			echo "This $THIS_INSTALLER_TYPE includes the following:"
		fi
	else
		echo "Nothing to install..."
		cleanup
		exit 1
	fi
	
	if [ -e "$FCSD_TAR" ]; then
		echo "  $PRODUCT_BRAND Core Server $FCSD_VER ($FCSD_TYPE)"
	fi
	if [ -e "$FCISD_TAR" ]; then
		echo "  $PRODUCT_BRAND Internet Services $FCISD_VER ($FCISD_TYPE)"
	fi
	if [ -e "$FCNSBUS_TAR" ]; then
		echo "  FirstClass Network Store (FCNS)"
	fi
	if [ -e "$FCNSEDU_TAR" ]; then
		echo "  FirstClass Network Store (FCNS)"
	fi
	if [ -e "$FCNSARCH_TAR" ]; then
		echo "  $PRODUCT_BRAND Network Store (FCNS) - Archive Server"
	fi
	if [ -e "$FCNSOTSM_TAR" ]; then
			echo "  $PRODUCT_BRAND Network Store (FCNS)"
	fi
	
	if [ -e "$UPGRADE_TAR" ]; then
		if [ -e "$FCSD_TAR" ]; then
			echo "  $PRODUCT_BRAND Network Store (FCNS) - Upgrade for existing stores"
		else
			echo "  $PRODUCT_BRAND Network Store (FCNS) - Upgrade for existing stores: Ignored due to incompatible installer configuration."
		fi
	fi
	if [ -e "$ADDON_TAR" ]; then
		if [ -e "$UPGRADE_TAR" ]; then
			echo "  $ADD_ON_NAME $ADD_ON_VERSION: Ignored due to incompatible installer configuration."
		else
			echo "  $ADD_ON_NAME $ADD_ON_VERSION"
		fi
	fi
}



display_UpgradePhaseComplete()
{
	echo "[`$NOW`] Installer upgrade phase complete."
}

display_BatchOnStartup_Instructions()
{
	echo "Note that a second, possibly lengthy upgrade phase will begin when the server is started."
	echo "During that upgrade phase, the server will apply the upgrade batch scripts."
	echo "This process may take a few minutes to as much as 30 minutes or so on some machines."
	echo "Please be patient and do not force-kill the server until the process is complete."
}

display_BatchUpgrade_Instructions()
{
		echo "Note that a second, possibly lengthy upgrade phase will begin when the server processes"
		echo "the installed upgrade batch scripts.  This process may take a few minutes to as much"
		echo "as 30 minutes or so on some machines, and will occur on server startup, or if the server"
		echo "is currently running, it can be manually started via the Server Control form and monitored"
		echo "via the Server Monitor / Activity tab."
		echo "If processed at server startup, no logins will be allowed until the process has completed." 
		echo "Please be patient and do not force-kill the server until completed as shown in fcsd.log file."
}

displayInstallComplete()
{
	echo "[`$NOW`] Installation complete."
	echo ""
	echo "For scripting, you may find 'fcsctl' and 'fcisctl' scripts under $CTL_FOLDER."
	echo "For example, you can start the server with '$CTL_FOLDER/fcsctl start',"
	echo "and stop the server with '$CTL_FOLDER/fcsctl stop'."
	echo "Check status with '$CTL_FOLDER/fcsctl status'."
	echo "See the documentation for more information."
}

displayFooter()
{
if [ "$_FC_PLATFORM" != "Mac OS X" ]; then
	if [ "`id -un`" = "root" ]; then
		echo "* NOTE: Please ensure that you exit from the root shell before continuing."
	fi
fi
echo "* NOTE: The $PRODUCT_BRAND services should be started from the 'fcadmin' account."
if [ "$UPGRADE_FCNS" -eq "1" ] ; then
	echo "You may then restart the server when you are ready."
fi
echo
}

