
updateVerTxtFile()
{
	echo $FCNS_VER > "$VER_TXT"
	echo "#############" >> "$VER_TXT"
	echo "DO NOT REMOVE" >> "$VER_TXT"
	sudo chown $MY_USER:$MY_GROUP "$VER_TXT"
	sudo chmod 440 "$VER_TXT"
}


installUpgradeBatchFiles()
{
	echo -n "Installing FCNS upgrade scripts at \"$BATCH_FOLDER\" ... "
	tar xzf "$UPGRADE_TAR" -C "$BATCH_FOLDER"
	updateVerTxtFile
	echo "done."

	echo "[`$NOW`] Existing $PRODUCT_BRAND Network Store (FCNS) content was found..."
	echo "WARNING: Verifying large FCNS content stores could take a long time."
	echo -n 'Do you wish to verify FCNS permissions and ownership (y/n)? [n]'
	read ANSWER
	#ANSWER="n"
	if [ "$ANSWER" = "y" ] ||  [ "$ANSWER" = "Y" ] ; then
		VERIFY_PO=1
	else
		VERIFY_PO=2
		echo "Only executable and upgrade file permissions and ownership will be reset."
	fi
	echo
}


runInstallerWizard()
{
	######## Installer "wizard" ########
	echo " "
	echo "NEW INSTALLATION WIZARD"
	_FC_DNS=`awk '$1=="nameserver" {print $2;exit 0 };' /etc/resolv.conf`
	if [ "$_FC_PLATFORM" = "Mac OS X" ]; then
		IPADDR=`$IFCONFIG $NETCARD | awk '$1=="inet" {print $2;exit 0 };'`
	else
		IPADDR=`$IFCONFIG $NETCARD | awk '$1=="inet" {print $2;exit 0 };' | awk -F: '{print $2;exit 0 };'`
	fi
	_FC_SITE="$PRODUCT_BRAND $_FC_PLATFORM"
				if [ "$PRODUCT_BRAND" = "FirstClass" ]; then
	NODE=`uname -n`
	NODE1="`echo $NODE | awk -F. '{print $1};'`"
	
	NUMERIC_NODE=0
	if [ -n "$NODE1" ] ; then
		if `expr "$NODE1" + 1 >& /dev/null` ; then
			NUMERIC_NODE=1
		fi
	fi
	if [ "$NUMERIC_NODE" -eq "1" ] ; then
		_FC_SITE="$NODE"
	elif [ -n "$NODE1" ] ; then
		if [ "$NODE1" != "localhost" ] ; then
			_FC_SITE="$NODE1"
		fi
	fi
	#
	echo -n "  Name of this site [$_FC_SITE]: "
	read dummy
	if [ -n "$dummy" ] ; then
		_FC_SITE="$dummy"
	fi
				fi
	# Get system domain name
	while [ -z "$_FC_DOMAIN" ] ; do
		_FC_DOMAIN="`domainname`"
		if [ -z "$_FC_DOMAIN" -o "$_FC_DOMAIN" == "(none)" ] ; then
			echo "* No domain name configured on this machine.  Using IP address instead."
			_FC_DOMAIN="$IPADDR"
			if [ -z "$_FC_DOMAIN" -o "$_FC_DOMAIN" == "(none)" ] ; then
				echo "* IP could not be determined (machine connected?).  Using localhost address instead."
				_FC_DOMAIN="127.0.0.1"
			fi
		fi
		echo "The domain name your $PRODUCT_BRAND Server uses for outgoing Internet mail."
		echo -n "  Primary domain name (e.g. mydomain.com)  [$_FC_DOMAIN]: "
		read dummy
		if [ -n "$dummy" ] ; then
			_FC_DOMAIN="$dummy"
		fi
	done
	# Get FirstClass domain name
	DOMAIN1="`echo $_FC_DOMAIN | awk -F. '{print $1};'`"
	NUMERIC_DOMAIN=0
	if [ -n "$DOMAIN1" ] ; then
		if `expr "$DOMAIN1" + 1 >& /dev/null` ; then
			NUMERIC_DOMAIN=1
		fi
	fi
	if [ "$NUMERIC_DOMAIN" -eq "1" ] ; then
		#echo "* Using the IP address ($_FC_DOMAIN) for all domain names."
		_FC_FCDOMAIN="$_FC_DOMAIN"
		_FC_MAILDOMAIN="$_FC_DOMAIN"
		_FC_WWWDOMAIN="$_FC_DOMAIN"
		_FC_FTPDOMAIN="$_FC_DOMAIN"
		_FC_NEWSDOMAIN="$_FC_DOMAIN"
		_FC_FCWSDOMAIN="$_FC_DOMAIN"
	else
		#echo "* Using non-numeric domain name variants (e.g. www.$_FC_DOMAIN)."
		_FC_FCDOMAIN="fc.$_FC_DOMAIN"
		_FC_MAILDOMAIN="mail.$_FC_DOMAIN"
		_FC_WWWDOMAIN="www.$_FC_DOMAIN"
		_FC_FTPDOMAIN="ftp.$_FC_DOMAIN"
		_FC_NEWSDOMAIN="news.$_FC_DOMAIN"
		_FC_FCWSDOMAIN="fcws.$_FC_DOMAIN"
	fi
	echo "This is the domain name that resolves to the IP address of the computer running your $PRODUCT_BRAND Server."
	echo -n "  Domain Name [$_FC_FCDOMAIN]: "
	read dummy
	if [ -n "$dummy" ] ; then
		_FC_FCDOMAIN="$dummy"
	fi
	#
	echo "The IP address of your primary DNS server."
	echo -n "  Primary DNS [$_FC_DNS]: "
	read dummy
	if [ -n "$dummy" ] ; then
		_FC_DNS="$dummy"
	fi
	_FC_ORGANIZATION="Open Text"
	echo "What is the name of your organization? This is the name by which other $PRODUCT_BRAND servers know your server."
	echo "It is also displayed to users on their $PRODUCT_BRAND Web Services desktops."
	echo -n "  Organization Name [$_FC_ORGANIZATION]: "
	read dummy
	if [ -n "$dummy" ] ; then
		_FC_ORGANIZATION="$dummy"
	fi

	#
	echo " "
	echo "// This $PRODUCT_BRAND server batch file was created by the installer." >> "$BAFILE"
	echo "PUT PATH \"$BASIC_IS_FORM\" 1513 0 \"$_FC_DNS\"" >> "$BAFILE"
	echo "PUT PATH \"$BASIC_IS_FORM\" 1001 0 \"$_FC_DOMAIN\"" >> "$BAFILE"
	echo "PUT PATH \"$BASIC_IS_FORM\" 1020 0 \"$_FC_MAILDOMAIN\"" >> "$BAFILE"
	echo "PUT PATH \"$BASIC_IS_FORM\" 1022 0 \"$_FC_WWWDOMAIN\"" >> "$BAFILE"
	echo "PUT PATH \"$BASIC_IS_FORM\" 1024 0 \"$_FC_FTPDOMAIN\"" >> "$BAFILE"
	echo "PUT PATH \"$BASIC_IS_FORM\" 1021 0 \"$_FC_NEWSDOMAIN\"" >> "$BAFILE"
	echo "PUT SYSPROFILE 1009 0 \"$_FC_FCDOMAIN\"" >> "$BAFILE"
	echo "PUT SYSPROFILE 1201 0 \"$_FC_SITE\"" >> "$BAFILE"
	echo "PUT PATH \"$MSL_IS_FORM\" 5002 0 \"127.0.0.1\" 5003 0 \"$_FC_WWWDOMAIN\"" >> "$BAFILE"
	echo "PUT PATH \"$SITEPREF_IS_FORM\" 5523 0 \"$_FC_ORGANIZATION\"" >> "$BAFILE"
	echo "PUT \"groups:all users\" 1262 0 \"$_FC_WWWDOMAIN\"" >> "$BAFILE"
	echo "PUT \"groups:all users\" 1505 0 \"$_FC_FCWSDOMAIN\"" >> "$BAFILE"


	####################################
}
