#!/bin/sh
#
# Install AntiVir for UNIX
#
# Copyright (c) 2011 Avira Operations GmbH & Co. KG and its Licensors
#

set_commands()
{
	case "${OS}" in
		sunos)
			ECHO="sh `pwd`/script/echo_sunos"
			GROUPADD="/usr/sbin/groupadd"
			;;
		freebsd)
			ECHO="echo"
			GROUPADD="pw groupadd"
			;;
		darwin)
			ECHO="sh `pwd`/script/echo_sunos"
			;;
		*)
			ECHO="echo"
			GROUPADD="/usr/sbin/groupadd"
			;;
	esac
}


set_mailgate_acllist()
{
	if [ "${PRODUCT}" != "mailgate" ]
	then
		return 0
	fi

	ACLLIST=""
	case $OS in
		linux*)
			HOSTNAME_FQDN="hostname -f"
			HOSTNAME_DNS_DOMAIN="hostname -d"
			;;
		freebsd|openbsd)
			HOSTNAME_FQDN="hostname"
			HOSTNAME_DNS_DOMAIN="hostname -s"
			;;
		sunos)
			HOSTNAME_FQDN="hostname"
			HOSTNAME_DNS_DOMAIN="domainname"

			;;
	esac

	FQDN="`${HOSTNAME_FQDN} 2> /dev/null`"
	if [ "${?}" -ne "0" -o -z "${FQDN}" ]
	then
		FQDN="localhost"
	fi

	DNS_DOMAIN="`${HOSTNAME_DNS_DOMAIN} 2> /dev/null`"
	if [ "${?}" -ne "0" -o -z "${DNS_DOMAIN}" ]
	then
		DNS_DOMAIN="localhost"
	fi
	
	ACLLIST="${FQDN} ${DNS_DOMAIN}"	
}


getDEV()
{
	case "${OS}" in
		freebsd)
			DEV="`kldstat | grep dazuko`"
			;;
		sunos)
			DEV=`modinfo | grep ${DEVNAME}`
			;;
		*)
			DEV=""
			if [ -f "/proc/devices" ]
			then
				DEV="`grep dazuko /proc/devices`"
			fi
			;;
	esac
}


noop()
{
	if [ 0 -eq 1 ]
	then
		$ECHO "strange"
	fi
}


error_message()
{
	if [ "$PRODUCT" = "smcagent" ]
	then
		$ECHO "$1" >&2
	fi
}


check_copyfiles()
{
	MISSING_CPLIST=""

	for CPITEM in $CPLIST
	do
		if [ ! -f "$CPITEM" ]
		then
			MISSING_CPLIST="$MISSING_CPLIST $CPITEM"
		fi
	done

	if [ ! -z "$MISSING_CPLIST" ]
	then
		$ECHO " "
		$ECHO "Not all the installation files were found. Make sure"
		$ECHO "you have the complete installation package. This script"
		$ECHO "requires the following files:"
		for CPITEM in $MISSING_CPLIST
		do
			$ECHO "    $CPITEM"
			error_message "error: missing installation file $CPITEM"
		done
		$ECHO " "
		exit 1
	fi
}


check_yesno_input()
{
        INPUT="$2"
        INPUTRC=0
	if [ ! -z "$INPUT" ]
	then   # non-interactive mode, the input value is preset
		$ECHO -n "$1"
		$ECHO "$INPUT"
		case $INPUT in
			y|Y|yes|Yes|YEs|YES|yEs|yES)
				return 1
				;;

			n|N|no|NO|nO|No)
				return 0
				;;
		esac
	else			# query the user for the input value
        	while [ $INPUTRC -eq 0 ]
		do
                	$ECHO -n "$1"
                	read INPUT
                	case $INPUT in
				y|Y|yes|Yes|YEs|YES|yEs|yES)
					INPUTRC=1
					return 1
					;;

                        	n|N|no|NO|nO|No)
					INPUTRC=1
					return 0
					;;

				"")             # default answer
					INPUTRC=1
					return 2
					;;

                        	*)
					$ECHO "Invalid answer, please answer y/n"
					$ECHO ""
					;;
                	esac
        	done
	fi
}


findnewkey()
{
	FINDKEYCOUNT=""
	KEYBASENAME="avira"

	NEWKEY="$KEYBASENAME$FINDKEYCOUNT.key"

	while [ -f "$1/$NEWKEY" ]
	do
		if [ -z "$FINDKEYCOUNT" ]
		then
			FINDKEYCOUNT=2
		else
			FINDKEYCOUNT=`expr $FINDKEYCOUNT + 1`
		fi

		NEWKEY="$KEYBASENAME$FINDKEYCOUNT.key"
	done
}


check_executables()
{
	MISSING_EXELIST=""

	for EXEITEM in $EXELIST
	do
		if [ ! -x "`which $EXEITEM`" ]
		then
			MISSING_EXELIST="$MISSING_EXELIST $EXEITEM"
		fi
	done

	if [ ! -z "$MISSING_EXELIST" ]
	then
		$ECHO " "
		$ECHO "Not all the required tools were found. Please install"
		$ECHO "the following tools:"
		for EXEITEM in $MISSING_EXELIST
		do
			$ECHO "    $EXEITEM"
			error_message "error: missing required tool $EXEITEM"
		done
		$ECHO " "
		exit 1
	fi
}


find_backup()
{
	BACKUPNUMBER=0
	BACKUPFILE="${FILE_TO_BACKUP}.backup$BACKUPNUMBER"

	while [ -f "$BACKUPFILE" ]
	do
		BACKUPNUMBER=`expr $BACKUPNUMBER + 1`

		if [ $BACKUPNUMBER -eq 0 ]
		then
			return
		fi

		BACKUPFILE="${FILE_TO_BACKUP}.backup$BACKUPNUMBER"
	done
}


convert_version()
{
	set -- `$ECHO "${VERSION}" | sed 's/[^0-9]/\ /g'`

	MAJ=$1
	test $MAJ -eq 0
	if [ $? -gt 1 ]
	then
		MAJ=0
	fi

	MIN=$2
	test $MIN -eq 0
	if [ $? -gt 1 ]
	then
		MIN=0
	fi

	REV=$3
	test $REV -eq 0
	if [ $? -gt 1 ]
	then
		REV=0
	fi

	BLD=$4
	test $BLD -eq 0
	if [ $? -gt 1 ]
	then
		BLD=0
	fi

	VERSION=`expr $MAJ \* 1000000`
	TEMP1=`expr $MIN \* 10000`
	VERSION=`expr $VERSION + $TEMP1`
	TEMP1=`expr $REV \* 100`
	VERSION=`expr $VERSION + $TEMP1`
	VERSION=`expr $VERSION + $BLD`
}


compare_versions()
{
	# 0 = replace older version
	# 1 = do not replace same version
	# 2 = do not replace newer version
	# 3 = TOO new version (do not install)

	if [ $OLDVERSION -lt $NEWVERSION ]
	then
		return 0
	elif [ $OLDVERSION -eq $NEWVERSION ]
	then
		return 1
	elif [ $OLDVERSION -gt $NEWVERSION ]
	then
		if [ `expr $OLDVERSION / 10000` -gt `expr $NEWVERSION / 10000` ]
		then
			return 3
		fi

		return 2
	fi

	return 0
}


ldd_bin_check()
{
	if [ "${OS}" = "darwin" ]
	then
		OTOOL=`which otool`
		if [ "${?}" -eq "0" ]
		then
			LDD="${OTOOL} -L"
		else
			LDD=""
		fi
	else
		LDD=`which ldd`
	fi

	if [ -x "$LDD" ]
	then
		for BINS_2_CHECK in avguard.bin avwebgate.bin avmailgate.bin agent ium
		do
			if [ -f "bin/$CLASSIFICATION/$BINS_2_CHECK" ]
			then
				case $BINS_2_CHECK in
					avguard.bin)
						if [ "$CLASSIFICATION" = "solaris_sparc" ]
						then
							LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libgcc_s | grep -v libdazuko | grep -v libsavapi`"
						else
							LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libdazuko | grep -v libsavapi`"
						fi
						;;
	
					avmailgate.bin)
						if [ "$CLASSIFICATION" = "solaris_sparc" ]
						then
							LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libgcc_s | grep -v libasmailgate`"
						else
							LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libasmailgate`"
						fi
						;;
	
					avwebgate.bin)
						if [ "$CLASSIFICATION" = "solaris_sparc" ]
						then
							LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libgcc_s`"
						else
							LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK`"
						fi
						;;
	
					agent)
						if [ "$CLASSIFICATION" = "solaris_sparc" ]
						then
							LIB_CHECK="`$EXEC_AGENT $LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libstdc++.so.5 | grep -v libstdc++.so.6 | grep -v libcommon`"
						else
							LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libcommon | grep -v libstdc++.so.5`"
						fi
						;;
	
					ium)
						LIB_CHECK="`$LDD bin/$CLASSIFICATION/$BINS_2_CHECK | grep -v libupdate | grep -v libcommon`"
						;;
				esac

				$ECHO $LIB_CHECK | grep "not a dynamic executable" > /dev/null 2>&1
				if [ "$?" -eq "0" ]
				then
					$ECHO " "
					$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
					$ECHO " "
					error_message "error: not supported system platform"
					exit 1
				fi

				$ECHO $LIB_CHECK | grep "not found" > /dev/null 2>&1
				if [ "$?" -eq "0" ]
				then
					$ECHO "Not all needed libraries were found on your system:"
					$ECHO "$LIB_CHECK"
					$ECHO " "
					error_message "Not all needed libraries were found on your system:"
					error_message "$LIB_CHECK"
					exit 28
				fi
			fi
		done
	fi
}


create_antivir_group()
{
	if [ "${OS}" = "darwin" ]
	then
		GID="240"
		GID_OK="1"

		while [ $GID_OK -eq "1" ]
		do
			grep $GID /etc/group
			if [ "$?" -eq "0" ]
			then
				GID=`expr $GID + 1`
			else
				GID_OK="0"
			fi
		done

		dscl . create /groups/$PROGNAME > /dev/null 2>&1
		dscl . create /groups/$PROGNAME name $PROGNAME> /dev/null 2>&1
		dscl . create /groups/$PROGNAME passwd "*" > /dev/null 2>&1
		dscl . create /groups/$PROGNAME gid $GID > /dev/null 2>&1
	else
		GET_GROUP=`which getent`
		if [ -x "${GET_GROUP}" ]
		then
			SEARCH_ANTIVIR_GROUP="${GET_GROUP} group ${PROGNAME}"
		else
			SEARCH_ANTIVIR_GROUP="cat /etc/group"
		fi

		$GROUPADD $PROGNAME > /dev/null 2>&1
		if [ "${?}" != "0" ]
		then
			${SEARCH_ANTIVIR_GROUP} | grep antivir > /dev/null 2>&1
			if [ "${?}" -ne "0" ]
			then
				groupadd $PROGNAME > /dev/null 2>&1
				if [ "${?}" != "0" ]
				then
					${SEARCH_ANTIVIR_GROUP} | grep antivir > /dev/null 2>&1
					if [ "${?}" -ne "0" ]
					then
						${ECHO} ""
						${ECHO} "It was not possible to create the group antivir_start"
						error_message "It was not possible to create the group antivir_start"
						exit 1
					fi
				fi
			fi
		fi
	fi
}


install_smcplugin()
{
	if [ ! -d "$AVDIR/agent" ]
	then
		avinstall -T "$AVDIR/agent" -u root -g "$PROGNAME" -m 755
		if [ $? -ne 0 ]
		then
			error_message "error: failed to create $AVDIR/agent"
			exit 1
		fi
	fi

	if [ ! -d "$AVDIR_BASE/agent" ]
	then
		avinstall -T "$AVDIR_BASE/agent" -u root -g "$PROGNAME" -m 755
		if [ $? -ne 0 ]
		then
			error_message "error: failed to create $AVDIR_BASE/agent"
		fi
	fi

	if [ -f "smcpkg/scanparameters.txt" ]
        then
		avinstall -f -S smcpkg -s scanparameters.txt -T "$AVDIR/agent" -u root -g "$PROGNAME" -m 755
	fi

	if [ "$CLASSIFICATION" = "linux_glibc22_x86_64" ]
	then
		LIBPLUGINSRC="lib$SMCPLUGINPREFIX.so.linux_glibc22"
	else	
		LIBPLUGINSRC="lib$SMCPLUGINPREFIX.so.$CLASSIFICATION"
	fi

	LIBPLUGINDST="lib$SMCPLUGINPREFIX.so"

	if [ -f "smcpkg/$LIBPLUGINSRC" ]
	then
		for ITEM in `find smcpkg -type f | grep "libux" | grep "$CLASSIFICATION" | sed -e 's,smcpkg\/,,'`
		do
			INSTALL_ITEM=`$ECHO $ITEM | sed -e 's,\.'${CLASSIFICATION}',,'`
			avinstall -f -S smcpkg -s "$ITEM" -T "$AVDIR/agent" -t "$INSTALL_ITEM" -u root -g "$PROGNAME" -m 755

			$ECHO -n "linking $AVDIR/agent/$INSTALL_ITEM to $AVDIR_BASE/agent/$INSTALL_ITEM ... "
			rm -f $AVDIR_BASE/agent/$INSTALL_ITEM
			ln -sf $AVDIR/agent/$INSTALL_ITEM $AVDIR_BASE/agent/$INSTALL_ITEM
			$ECHO "done"
		
		done
	fi

	if [ "$PRODUCT" = "server" -o "$PRODUCT" = "workstation" ]
	then
		avinstall -f -S script -s write_fstab.sh -T "$AVDIR/agent" -u root -g "$PROGNAME" -m 755
	fi

	avinstall -T $AVDIR/gui -u root -g "$PROGNAME" -m 750
	avinstall -T $AVDIR/gui/cert -u root -g "$PROGNAME" -m 750
	avinstall -T $AVDIR/gui/src -u root -g "$PROGNAME" -m 750
	avinstall -T $AVDIR/gui/bin -u root -g "$PROGNAME" -m 750
	
	if [ "$PRODUCT" = "mailgate" ]
	then
		avinstall -f -S bin/$CLASSIFICATION -s avmg_stats.lck -T "$AVDIR/gui/bin" -u uucp -g "$PROGNAME" -m 640
		avinstall -f -S bin/$CLASSIFICATION -s avmg_stats -T "$AVDIR/gui/bin" -u uucp -g "$PROGNAME" -m 750
	fi

	if [ "$PRODUCT" = "server" -o "$PRODUCT" = "workstation" ]
	then
		avinstall -f -S bin/$CLASSIFICATION -s avgu_stats.lck -T "$AVDIR/gui/bin" -u nobody -g "$PROGNAME" -m 664
		avinstall -f -S bin/$CLASSIFICATION -s avgu_stats -T "$AVDIR/gui/bin" -u root -g "$PROGNAME" -m 750
	fi

	if [ "$PRODUCT" = "webgate" ]
	then
		avinstall -f -S bin/$CLASSIFICATION -s avwg_stats.lck -T "$AVDIR/gui/bin" -u nobody -g "$PROGNAME" -m 664
		avinstall -f -S bin/$CLASSIFICATION -s avwg_stats -T "$AVDIR/gui/bin" -u root -g "$PROGNAME" -m 750
	fi

	avinstall -f -S smcpkg/cert -s client.jks -T "$AVDIR/gui/cert" -u root -g "$PROGNAME" -m 644
	avinstall -f -S smcpkg/cert -s server.pem -T "$AVDIR/gui/cert" -u root -g "$PROGNAME" -m 644
	avinstall -f -S smcpkg/cert -s cacert.jks -T "$AVDIR/gui/cert" -u root -g "$PROGNAME" -m 644
	avinstall -f -S smcpkg/cert -s cacert.pem -T "$AVDIR/gui/cert" -u root -g "$PROGNAME" -m 644
}


patch_install_temp()
{
	$ECHO -n "patching temp-dir in  /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf ... "
	cp /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf.tmp
	cat /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf.tmp | sed 's,temp-dir=/tmp/avira_update,temp-dir=/tmp/avira_update/'$INSTALL_NAME',' > /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf
	rm /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf.tmp
	$ECHO "done"
}


setup_startup_scripts()
{
	RCPATH=`sh script/rcscript query "$SSS_SCRIPT"`

	if [ "$SSS_START" -eq 1 ]
	then
		RCOVERWRITE=1

		if [ ! -z "$RCPATH" ]
		then
			if [ $HAS_INF -eq 1 ]
			then
				INPUT="y"
				$ECHO "$INPUT"
			fi

			$ECHO " "
			$ECHO "Boot scripts for $SSS_NAME have been found."
			check_yesno_input "Should they be overwritten? [y] " $INPUT
			if [ "$?" -eq "1" -o "$?" -eq "2" ]
			then
				RCOVERWRITE=1
			else
				RCOVERWRITE=0
			fi
		fi

		if [ $RCOVERWRITE -eq 1 ]
		then
			$ECHO -n "setting up boot script ... "
			sh script/rcscript install "$SSS_SCRIPT"
			if [ $? -ne 0 ]
			then
				$ECHO "failed"
				$ECHO " "
				error_message "warning: unable to set up boot script"
				$ECHO " "
				$ECHO "************************************************"
				$ECHO " Unable to locate where boot scripts belong."
				$ECHO " You can launch $SSS_NAME with:"
				$ECHO " "
				$ECHO "      $SSS_SCRIPT start"
				$ECHO "************************************************"
				$ECHO " "
				$ECHO -n "Press <ENTER> to continue."
				if [ $HAS_INF -eq 0 ]
				then
					read INPUT
				else
					$ECHO " "
				fi
			else
				$ECHO "done"
			fi
		fi
	else
		if [ ! -z "$RCPATH" ]
		then
			INPUT=""

			if [ $HAS_INF -eq 1 ]
			then
				INPUT="y"
				$ECHO "$INPUT"
			fi
			$ECHO " "
			$ECHO "Boot scripts for $SSS_NAME have been found."
			check_yesno_input "Should they be removed? [n] " $INPUT
			if [ "$?" -eq "1" ]
			then
				sh script/rcscript remove "$SSS_SCRIPT"
			fi
		fi
	fi
}


install_smcagent()
{
# 	check for old smc-plugins
	for ITEM in $AVDIR_BASE/agent/libuxmgt.so \
		    $AVDIR_BASE/agent/libuxsrv.so \
		    $AVDIR_BASE/agent/libuxwgt.so \
		    $AVDIR_BASE/agent/libuxwks.so
	do
		if [ -f "$ITEM" ]
		then
			case $ITEM in
				*libuxmgt.so)
					SMC_PLUGIN_PRODUCT="Avira MailGate (UNIX)"
					;;

				*libuxsrv.so)
					SMC_PLUGIN_PRODUCT="Avira AntiVir Server (UNIX)"
					;;

				*libuxwgt.so)
					SMC_PLUGIN_PRODUCT="Avira AntiVir WebGate (UNIX)"
					;;

				*libuxwks.so)
					SMC_PLUGIN_PRODUCT="Avira AntiVir Workstation (UNIX)"
					;;
			esac

			for YEAR in 2006 2007 2008
			do
				strings $ITEM | grep -i "rev.*$YEAR" > /dev/null 2>&1
				ERR_PLUGIN_VERSION="$?"

				grep $ITEM /usr/lib/AntiVir/agent/agent.conf > /dev/null 2>&1
				ERR_PLUGIN_IN_AGENT_CONF="$?"

				if [ "$ERR_PLUGIN_VERSION" -eq 0 -a "$ERR_PLUGIN_IN_AGENT_CONF" -eq 0 ]
				then
					error_message "$ITEM not compatible with Avira SMC Agent 2.4, please uninstall $SMC_PLUGIN_PRODUCT first"
					exit 1
				fi
			done
		fi
	done

	if [ ! -d "$AVDIR_BASE" ]
	then
		avinstall -T "$AVDIR_BASE" -u root -g "$PROGNAME" -m 755
	fi

	if [ ! -d "$AVDIR" ]
	then
		avinstall -T "$AVDIR" -u root -g "$PROGNAME" -m 755
		if [ $? -ne 0 ]
		then
			error_message "error: failed to create $AVDIR"
			exit 1
		fi
	fi

	if [ ! -d /etc/avira ]
	then
		avinstall -T /etc/avira -u root -g "$PROGNAME" -m 775
	fi

	if [ ! -d "$AVDIR/ssl" ]
	then
		avinstall -T "$AVDIR/ssl" -u root -g "$PROGNAME" -m 755
	fi

	if [ -x $AVDIR/smc-agent ]
	then
		$ECHO -n "stop running $FULLPRODUCTNAME ... "
		$AVDIR/smc-agent stop > /dev/null 2>&1
		$ECHO "done"
	fi

	if [ -x $AVDIR/agent ]
	then
		$ECHO -n "remove current AMC node $FULLPRODUCTNAME ... "
		$AVDIR/agent -u > /dev/null 2>&1
		$ECHO "done"
	fi

	avinstall -f -s uninstall -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -s uninstall_smcplugin.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S etc -s file_list -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s dir_list -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s run.inf -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -s README.uninstall -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -s build.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664

	avinstall -f -S bin/$CLASSIFICATION -s agent -T "$AVDIR" -t agent -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s agent_msg.avr -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s common_msg.avr -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s libcommon.so -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s avpack.so -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s avverifier -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	if [ -f "bin/$CLASSIFICATION/libstdc++.so.5" ]
	then
		avinstall -f -S bin/$CLASSIFICATION -s libstdc++.so.5 -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	fi

	if [ -f "bin/$CLASSIFICATION/libstdc++.so.6" ]
	then
		avinstall -f -S bin/$CLASSIFICATION -s libstdc++.so.6 -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	fi
	
	if [ "$OS" = "sunos" ]
	then
		if [ -f "/usr/local/lib/libgcc_s.so.1" ]
		then
			LIBGCC_S_LOCATION="/usr/local/lib/libgcc_s.so.1"

		elif [ -f "/opt/sfw/lib/libgcc_s.so.1" ]
		then
			LIBGCC_S_LOCATION="/opt/sfw/lib/libgcc_s.so.1"
		fi

		if [ ! -z "$LIBGCC_S_LOCATION" ]
		then
			$ECHO -n "$AVDIR/libgcc_s.so.1 to $LIBGCC_S_LOCATION ... "
			rm -f "$AVDIR/libgcc_s.so.1"
			ln -s $LIBGCC_S_LOCATION "$AVDIR/libgcc_s.so.1"
			$ECHO "done"
		else
			error_message "error: failed to install ${FULLPRODUCTNAME}"
			$ECHO " "
			$ECHO "It was not possible to install a needed system library."
			$ECHO "If this library is not installed, it's not possible to"
			$ECHO "run Avira AMC Agent."
			exit 1
		fi
	fi
	
	if [ ! -x "$AVDIR/Agent" ]
	then
		$ECHO -n "linking $AVDIR/Agent to $AVDIR/$SMCAGENTNAME ... "
		rm -f $AVDIR/Agent
		ln -sf $AVDIR/$SMCAGENTNAME $AVDIR/Agent
		$ECHO "done"
	fi

	avinstall -f -S bin/$CLASSIFICATION -s avupdate.bin -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s avupdate_msg.avr -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	avinstall -f -S script -s $UPDATENAME.template -T "$AVDIR" -t "$UPDATENAME-$UPDATE_CONF_NAME" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s rcscript -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_start.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_restart.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_stop.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	avinstall -f -S script -s avira_start.sh.template -T "$AVDIR" -t smc-agent -u root -g "$PROGNAME" -m 755
	cp $AVDIR/smc-agent $AVDIR/smc-agent.orig
	cat $AVDIR/smc-agent.orig | sed -e 's,_PRODUCT_,'${PRODUCT}',' -e 's,_UPD-PRODUCT_,'${UPD_PRODUCT}',' -e 's,_FULLPRODUCTNAME_,'"${FULLPRODUCTNAME}"',' > $AVDIR/smc-agent
	rm $AVDIR/smc-agent.orig

	avinstall -f -S cert -s cacert.pem -T "$AVDIR/ssl" -u root -g "$PROGNAME" -m 755
	avinstall -f -S cert -s client.pem -T "$AVDIR/ssl" -u root -g "$PROGNAME" -m 755

	if [ ! -f /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf ]
	then
		avinstall -f -S etc -s $UPDATENAME.conf -T /etc/avira -t $UPDATENAME-$UPDATE_CONF_NAME.conf -u root -g "$PROGNAME" -m 640
		if [ "$PRODUCT" != "savapi" ]
		then
			patch_install_temp
		fi
	fi
	avinstall -f -S etc -s $UPDATENAME.conf -T /etc/avira -t $UPDATENAME-$UPDATE_CONF_NAME.conf.default -u root -g "$PROGNAME" -m 640
	avinstall -f -S etc -s agent.ini -T /etc/avira -u root -g "$PROGNAME" -m 640
	avinstall -f -S etc -s agent.ini -T /etc/avira -t agent.ini.default -u root -g "$PROGNAME" -m 640

# 	check if libstdc++.so.5/libstdc++.so.6 is available on this system
	if [ ${OS} = "sunos" ]
	then
		LIB_2_CHECK="libstdc++.so.6"
	else
		LIB_2_CHECK="libstdc++.so.5"
	fi

	$EXEC_AGENT ldd $AVDIR/$SMCAGENTNAME | grep "not found" > /dev/null
	if [ $? -eq 0 ]
	then
		$ECHO " "
		$ECHO "${LIB_2_CHECK} not found."
		case $SYSTEMINFO in
			*suse*11*)
				zypper -n install libstdc++33 > /dev/null 2>&1
				INSTALL_LIB="$?"
				;;


			*fedora*)
				yum -y install compat-libstdc++-33 > /dev/null 2>&1
				INSTALL_LIB="$?"
				;;

			*debian*)
				apt-get install libstdc++5 --assume-yes > /dev/null 2>&1
				INSTALL_LIB="$?"
				;;

			*)
				error_message "error: ${LIB_2_CHECK} missing, please install first."
				exit 1
				;;
		esac

		if [ $INSTALL_LIB -eq 0 ]
		then
			$ECHO "Installing missing ${LIB_2_CHECK} ... done"
		else
			error_message "error: failed to install ${LIB_2_CHECK}"
			$ECHO " "
			$ECHO "It was not possible to install a needed system library."
			$ECHO "If this library is not installed, it's not possible to"
			$ECHO "run Avira AMC Agent."
			exit 1
		fi

		$EXEC_AGENT ldd $AVDIR/$SMCAGENTNAME | grep "not found" > /dev/null
		if [ $? -eq 0 ]
		then
			$ECHO " "
			$ECHO "It was not possible to resolve all dependencies."
			exit 1
		fi
	fi

	$ECHO -n "setting up agent configuration ... "
	if [ "$AGENT_NETWORKNAME" != "$NO_VALUE" ]
	then
		AGENT_EXTRA_ARG1="--network_name="
		AGENT_EXTRA_ARG2="$AGENT_NETWORKNAME"
	else
		AGENT_EXTRA_ARG1=""
		AGENT_EXTRA_ARG2=""
	fi
	if [ "$AGENT_GUID" != "$NO_VALUE" ]
	then
		AGENT_EXTRA_ARG3="--guid="
		AGENT_EXTRA_ARG4="$AGENT_GUID"
	else
		AGENT_EXTRA_ARG3=""
		AGENT_EXTRA_ARG4=""
	fi
	if [ "$AGENT_PRODUCT_CONFIG" != "$NO_VALUE" ]
	then
		AGENT_EXTRA_ARG5="--product_config="
		AGENT_EXTRA_ARG6="$AGENT_PRODUCT_CONFIG"
	else
		AGENT_EXTRA_ARG5=""
		AGENT_EXTRA_ARG6=""
	fi

	AGENT_ERR=`$EXEC_AGENT $AVDIR/$SMCAGENTNAME --agent_port="$AGENT_AGENTPORT" --server_uri=http://"${AGENT_SERVERIP}:${AGENT_SERVERPORT}" --evmgr_uri=http://"${AGENT_EVENTMANAGERIP}:${AGENT_EVENTMANAGERPORT}" --update_uri=http://"${AGENT_UPDATEMANAGERIP}:${AGENT_UPDATEMANAGERPORT}" --display_name="$AGENT_DISPLAYNAME" $AGENT_EXTRA_ARG1$AGENT_EXTRA_ARG2 $AGENT_EXTRA_ARG3$AGENT_EXTRA_ARG4 $AGENT_EXTRA_ARG5$AGENT_EXTRA_ARG6 2>&1`
	if [ $? -ne 0 ]
	then
		$ECHO "failed."
		$ECHO " "
		error_message "error: failed to set up agent configuration"
		$ECHO "$AGENT_ERR" >&2
		exit 1
	fi
	$ECHO "done."

# 	check for products and their smc plugins
	for INSTALLED_PRODUCTS in $AVDIR_BASE/guard/avguard.bin $AVDIR_BASE/avguard.bin $AVDIR_BASE/mailgate/avmailgate.bin $AVDIR_BASE/avmailgate.bin $AVDIR_BASE/webgate/avwebgate.bin $AVDIR_BASE/avwebgate.bin
	do
		SMC_PLUGIN_LIB=""

		if [ -f "$INSTALLED_PRODUCTS" ]
		then
			case $INSTALLED_PRODUCTS in
				*guard*)
					if [ -f $AVDIR_BASE/guard/AV_SRV_PROF ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/guard/agent/libuxsrv.so"

					elif [ -f $AVDIR_BASE/guard/AV_WKS_PROF ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/guard/agent/libuxwks.so"

					elif [ -f $AVDIR_BASE/AV_SRV_PROF ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/agent/libuxsrv.so"

					elif [ -f $AVDIR_BASE/AV_WKS_PROF ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/agent/libuxwks.so"
					fi
					;;

				*mailgate*)
					if [ -f "$AVDIR_BASE/mailgate/agent/libuxmgt.so" ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/mailgate/agent/libuxmgt.so"

					elif [ -f "$AVDIR_BASE/agent/libuxmgt.so" ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/agent/libuxmgt.so"
					fi
					;;

				*webgate*)
					if [ -f "$AVDIR_BASE/webgate/agent/libuxwgt.so" ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/webgate/agent/libuxwgt.so"

					elif [ -f "$AVDIR_BASE/agent/libuxwgt.so" ]
					then
						SMC_PLUGIN_LIB="$AVDIR_BASE/agent/libuxwgt.so"
					fi
					;;
			esac

			if [ ! -z "${SMC_PLUGIN_LIB}" ]
			then
				KEYWORD=`$ECHO $SMC_PLUGIN_LIB | sed -e 's/^.*ux/ux/; s/\.so$//'`
				$ECHO -n "registering SMC UNIX Agent plug-in ($KEYWORD) ... "
				$EXEC_AGENT $AVDIR/$SMCAGENTNAME --install-plugin $KEYWORD $SMC_PLUGIN_LIB > /dev/null 2>&1
				$ECHO "done"
			else
				${ECHO} ""
				${ECHO} "AMC plugin not found: ${SMC_PLUGIN_LIB}"
			fi
		fi
	done

	STARTAGENT=1
	$ECHO " "
	$ECHO "Please specify if boot scripts should be set up."
	check_yesno_input "Set up boot scripts? [y] " $AGENT_AUTOSTART
	if [ "$?" -eq 0 ]
	then
		STARTAGENT=0
	fi

	SSS_START=$STARTAGENT
	SSS_SCRIPT="$AVDIR/smc-agent"
	SSS_NAME="AMC UNIX Agent"
	setup_startup_scripts

	$ECHO " "
	check_yesno_input "Would you like to start the Avira AMC Agent now? [y] " $AGENT_STARTNOW
	if [ "$?" -eq "1" -o "$?" -eq "2" ]
	then
		$AVDIR/smc-agent start
	fi

	$ECHO "installation of the Avira AMC Agent complete"
}


print_openbsd_startup_msg()
{
	$ECHO " "
	$ECHO "If you would like $SSS_NAME to start up"
	$ECHO "automatically on system boot, please add the following"
	$ECHO "to the bottom of the /etc/rc.local file:"

	$ECHO " "
	$ECHO "    if [ -x $SSS_SCRIPT ]; then"
	$ECHO "        $SSS_SCRIPT start"
	$ECHO "    fi"

	$ECHO " "
	$ECHO -n "Press <ENTER> to continue."
	read INPUT
}


install_sapvsa()
{
	avinstall -f -S bin/$CLASSIFICATION -s libantivirvsa.so -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	if [ $? -ne 0 ]
	then
		exit 1
	fi

	if [ ! -f /etc/avira/"${CONFNAME}.conf" ]
	then
		avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -u root -g "$PROGNAME" -m 644
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	else
		FOUNDCONF="1"
	fi
	avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -t "${CONFNAME}.conf.default" -u root -g "$PROGNAME" -m 644
}


install_webgate()
{
	if [ "$VARIANT" = "AVDE" ]
	then
    		avinstall -f -S doc -s antivir_webgate_en.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_webgate_de.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	fi

	avinstall -f -S doc -s RELEASE_NOTES_webgate_EN.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s RELEASE_NOTES_webgate_DE.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644

	if [ -x $AVDIR_BASE/avwebgate ]
	then
		$AVDIR_BASE/avwebgate status > /dev/null 2>&1
		if [ "${?}" -eq "0" ]
		then
			WEBGATE_WAS_RUNNING="1"
		fi

		$ECHO -n "stop running $FULLPRODUCTNAME ... "
		$AVDIR_BASE/avwebgate stop > /dev/null 2>&1
		$ECHO "done"

	elif [ -x $AVDIR/avwebgate ]
	then
		$AVDIR/avwebgate status > /dev/null 2>&1
		if [ "${?}" -eq "0" ]
		then
			WEBGATE_WAS_RUNNING="1"
		fi


		$ECHO -n "stop running $FULLPRODUCTNAME ... "
		$AVDIR/avwebgate stop > /dev/null 2>&1
		$ECHO "done"
	fi

	avinstall -f -S bin/$CLASSIFICATION -s avwebgate.bin -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	if [ $? -ne 0 ]
	then
		exit 1
	fi

	avinstall -f -S bin -s wskeyfile -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	if [ $? -ne 0 ]
	then
		exit 1
	fi

	avinstall -f -S bin/$CLASSIFICATION -s webcattool -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S doc -s README.webcattool -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -s build.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664

	avinstall -f -S script -s avwebgate_start.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avwebgate_restart.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avwebgate_reload.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avwebgate_stop.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avwebgate_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s start_webgate_upgrade.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s create-db.sql -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_reload.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_plugin_reload.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	avinstall -f -S script -s avira_start.sh.template -T "$AVDIR" -t avwebgate -u root -g "$PROGNAME" -m 755
	cp $AVDIR/avwebgate $AVDIR/avwebgate.orig
	cat $AVDIR/avwebgate.orig | sed -e 's,_PRODUCT_,'${PRODUCT}',' -e 's,_UPD-PRODUCT_,'${UPD_PRODUCT}',' -e 's,_FULLPRODUCTNAME_,'"${FULLPRODUCTNAME}"',' > $AVDIR/avwebgate
	rm $AVDIR/avwebgate.orig

	cp $AVDIR/avwebgate $AVDIR/avwebgate.orig
	cat $AVDIR/avwebgate.orig | sed -e 's,\#\ Required-Start\:,\#\ Required-Start\:\ \$network\ \$remote_fs,' > $AVDIR/avwebgate
	rm $AVDIR/avwebgate.orig

	if [ ! -f /etc/avira/${CONFNAME}.conf ]
	then
		avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -u root -g "$PROGNAME" -m 640
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	else
		FOUNDCONF="1"
	fi
	avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -t "${CONFNAME}.conf.default" -u root -g "$PROGNAME" -m 640

	if [ ! -f /etc/avira/${CONFNAME}-scanner.conf ]
	then
		avinstall -f -S etc -s "${CONFNAME}-scanner.conf" -T /etc/avira -u root -g "$PROGNAME" -m 640
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	fi
	avinstall -f -S etc -s "${CONFNAME}-scanner.conf" -T /etc/avira -t "${CONFNAME}-scanner.conf.default" -u root -g "$PROGNAME" -m 640

	avinstall -f -S etc -s webcat0.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s webcat1.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s webcat2.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s webcat3.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s webcat4.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664

	avinstall -T "$AVDIR/data" -u root -g "$PROGNAME" -m 755
	avinstall -S etc -s AVIRA-MIB.txt -T $AVDIR/data -u root -g "$PROGNAME" -m 644
	avinstall -S etc -s AVIRA-WEBGATE-V0-MIB.txt -T $AVDIR/data -u root -g "$PROGNAME" -m 644

	avinstall -f -S cert -s avira_ca.crt -T "$AVDIR" -u root -g "$PROGNAME" -m 640

	if [ ! -f "/etc/avira/avwebgate-odbc.ini" ]
	then
		avinstall -S etc -s avwebgate-odbc.ini -T /etc/avira -u root -g "$PROGNAME" -m 660
	fi
	avinstall -S etc -s avwebgate-odbc.ini -T /etc/avira -t avwebgate-odbc.ini.default -u root -g "$PROGNAME" -m 660

	avinstall -f -S doc -s antivir_webgate_en.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s antivir_webgate_de.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s WebGateDatabase.odb -T "$AVDIR" -u root -g "$PROGNAME" -m 640
	avinstall -f -S doc -s WebGateReportsExample.ods -T "$AVDIR" -u root -g "$PROGNAME" -m 640
	avinstall -f -S doc -s avwebgate.acl.example -T /etc/avira -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s README.db-support-SLES10-SP2-64bit -T "$AVDIR" -u root -g "$PROGNAME" -m 644

	avinstall -T "$AVDIR/templates" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/en" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/de" -u root -g "$PROGNAME" -m 775

	$ECHO -n "installing example templates to $AVDIR/templates ... "
	for item_tmpl in `ls templates/`
	do
		$ECHO -n " $item_tmpl"
	        for item in `ls templates/$item_tmpl`
	        do
	                avinstall -q -f -S templates/$item_tmpl -s "$item" -T "$AVDIR/templates/examples/$item_tmpl" -u root -g "$PROGNAME" -m 664
	        done
	done
	$ECHO "done"
	$ECHO " "

	if [ ! -x "/usr/sbin/avwebgate" ]
	then
		$ECHO " "
		check_yesno_input "Would you like to create a link in /usr/sbin for avwebgate? [y] " $WEBGATE_ADDLINK
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			$ECHO -n "linking /usr/sbin/avwebgate to $AVDIR/avwebgate ... "
			rm -f /usr/sbin/avwebgate
			ln -s $AVDIR/avwebgate /usr/sbin/avwebgate
			$ECHO "done"
		fi
	fi

	SSS_SCRIPT="$AVDIR/avwebgate"
	SSS_NAME="Avira WebGate"

	STARTWEBGATE=1
	$ECHO " "
	$ECHO "Please specify if boot scripts should be set up."
	check_yesno_input "Set up boot scripts? [y] " $WEBGATE_AUTOSTART
	if [ "$?" -eq "0" ]
	then
		STARTWEBGATE=0
	fi

	SSS_START=$STARTWEBGATE
	setup_startup_scripts

	$ECHO "installation of main program complete"
}


install_mailgate()
{
	if [ "$VARIANT" = "AVDE" ]
	then
		avinstall -f -S doc -s antivir_mailgate_de.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_mailgate_en.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	fi

	avinstall -f -S doc -s CHANGELOG -T "$AVDIR" -u root -g "$PROGNAME" -m 644

	if [ -x $AVDIR_BASE/avmailgate ]
	then
		$AVDIR_BASE/avmailgate status > /dev/null 2>&1
		if [ "${?}" -eq "0" ]
		then
			MAILGATE_WAS_RUNNING="1"
		fi

		$ECHO -n "stop running $FULLPRODUCTNAME ... "
		$AVDIR_BASE/avmailgate stop > /dev/null 2>&1
		$ECHO "done"

	elif [ -x $AVDIR/avmailgate ]
	then
		$AVDIR/avmailgate status > /dev/null 2>&1
		if [ "${?}" -eq "0" ]
		then
			MAILGATE_WAS_RUNNING="1"
		fi

		$ECHO -n "stop running $FULLPRODUCTNAME ... "
		$AVDIR/avmailgate stop > /dev/null 2>&1
		$ECHO "done"
	fi

	avinstall -f -S bin/$CLASSIFICATION -s avmailgate.bin -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	if [ $? -ne 0 ]
	then
		exit 1
	fi

	avinstall -f -S bin/$CLASSIFICATION -s avqmd -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	if [ $? -ne 0 ]
	then
		exit 1
	fi
	avinstall -f -S bin/$CLASSIFICATION -s avqmc-mgt -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	if [ $? -ne 0 ]
	then
		exit 1
	fi
	avinstall -T "/var/run/avqmd" -u root -g "$PROGNAME" -m 775

	if [ ! -x "/usr/sbin/avqmc-mgt" ]
	then
		$ECHO -n "linking /usr/sbin/avqmc-mgt to $AVDIR/avqmc-mgt ... "
		rm -f /usr/sbin/avqmc-mgt
		ln -s "$AVDIR/avqmc-mgt" /usr/sbin/avqmc-mgt
		$ECHO "done"
	fi

	ASMAILGATE_SRC="contrib/asmailgate"
	ASMAILGATE_BINDIR="$ASMAILGATE_SRC/bin/$CLASSIFICATION"
	if [ ! -d "$ASMAILGATE_BINDIR" -a ! -z "$USE_CLASSIFICATION" ]
	then
		ASMAILGATE_BINDIR="$ASMAILGATE_SRC/bin/$USE_CLASSIFICATION"
	fi
	ASMAILGATE_DATADIR="$ASMAILGATE_SRC/data"
	ASMAILGATE_LIB="libasmailgate.so"
	ASMAILGATE_BIN="avmg_ext_filter.bin"
	if [ -f "$ASMAILGATE_BINDIR/$ASMAILGATE_LIB" ]
	then
		# install asmailgate

		avinstall -f -S $ASMAILGATE_BINDIR -s $ASMAILGATE_LIB -T "$AVDIR" -u root -g "$PROGNAME" -m 755
		avinstall -f -S $ASMAILGATE_BINDIR -s $ASMAILGATE_BIN -T "$AVDIR" -u root -g "$PROGNAME" -m 755

		for item_expg in `ls $ASMAILGATE_DATADIR/`
		do
			avinstall -f -S $ASMAILGATE_DATADIR -s $item_expg -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		done
	fi

	avinstall -f -s build.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664

	avinstall -f -S script -s avmailgate_start.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avmailgate_restart.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avmailgate_smc_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avmailgate_stop.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avmailgate_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s create-db.sql -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s upgrade-db.sql -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_reload.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_plugin_reload.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s start_mailgate_upgrade.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	avinstall -f -S script -s avira_start.sh.template -T "$AVDIR" -t avmailgate -u root -g "$PROGNAME" -m 755
	cp $AVDIR/avmailgate $AVDIR/avmailgate.orig
	cat $AVDIR/avmailgate.orig | sed -e 's,_PRODUCT_,'${PRODUCT}',' -e 's,_UPD-PRODUCT_,'${UPD_PRODUCT}',' -e 's,_FULLPRODUCTNAME_,'"${FULLPRODUCTNAME}"',' > $AVDIR/avmailgate
	rm $AVDIR/avmailgate.orig

	cp $AVDIR/avmailgate $AVDIR/avmailgate.orig
	cat $AVDIR/avmailgate.orig | sed -e 's,\#\ Should-Start\:,\#\ Should-Start\:\ mysql,' > $AVDIR/avmailgate
	rm $AVDIR/avmailgate.orig

	avinstall -f -S doc -s antivir_mailgate_de.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s antivir_mailgate_en.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644

	avinstall -T "$AVDIR/templates" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/de" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/en" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/es" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/hu" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/it" -u root -g "$PROGNAME" -m 775
	avinstall -T "$AVDIR/templates/examples/nl" -u root -g "$PROGNAME" -m 775

	$ECHO -n "installing example templates to $AVDIR/templates ... "
	for item_tmpl in `ls templates/`
	do
	        for item in `ls templates/$item_tmpl`
	        do
	                avinstall -q -f -S templates/$item_tmpl -s "$item" -T "$AVDIR/templates/examples/$item_tmpl" -u root -g "$PROGNAME" -m 664
	        done
	done
	$ECHO "done"
	$ECHO " "

	if [ -f templates/spamfilter-subjects ]
	then
		avinstall -f -S templates -s spamfilter-subjects -T "$AVDIR/templates/examples" -t spamfilter-subjects -u root -g "$PROGNAME" -m 664
	fi
	$ECHO " "

	avinstall -T "$AVDIR/data" -u root -g "$PROGNAME" -m 755
	avinstall -S etc -s AVIRA-MIB.txt -T $AVDIR/data -u root -g "$PROGNAME" -m 644
	avinstall -S etc -s AVIRA-MAILGATE-V0-MIB.txt -T $AVDIR/data -u root -g "$PROGNAME" -m 644

	if [ ! -f /etc/avira/${CONFNAME}.conf ]
	then
		avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -u root -g "$PROGNAME" -m 640
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	else
		FOUNDCONF="1"
	fi
	avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -t "${CONFNAME}.conf.default" -u root -g "$PROGNAME" -m 640
	
	if [ ! -f /etc/avira/${CONFNAME}-scanner.conf ]
	then
		avinstall -f -S etc -s "${CONFNAME}-scanner.conf" -T /etc/avira -u root -g "$PROGNAME" -m 640
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	fi
	avinstall -f -S etc -s "${CONFNAME}-scanner.conf" -T /etc/avira -t "${CONFNAME}-scanner.conf.default" -u root -g "$PROGNAME" -m 640

	avinstall -S etc -s avmailgate.ignore -T /etc/avira -u root -g "$PROGNAME" -m 640
	avinstall -S etc -s avmailgate.scan -T /etc/avira -u root -g "$PROGNAME" -m 640
	avinstall -S etc -s avmailgate.warn -T /etc/avira -u root -g "$PROGNAME" -m 640
	avinstall -S etc -s asmailgate.except -T /etc/avira -u root -g "$PROGNAME" -m 640

	if [ ! -f "/etc/avira/avmailgate-odbc.ini" ]
	then
		avinstall -S etc -s avmailgate-odbc.ini -T /etc/avira -u root -g "$PROGNAME" -m 660
	fi
	avinstall -S etc -s avmailgate-odbc.ini -T /etc/avira -t avmailgate-odbc.ini.default -u root -g "$PROGNAME" -m 660

	avinstall -S etc -s avmailgate.groups -T /etc/avira -u root -g "$PROGNAME" -m 640

	avinstall -T "/var/spool/avmailgate" -u $MGTUSER -g "$PROGNAME" -m 700
	avinstall -T "/var/spool/avmailgate/incoming" -u $MGTUSER -g "$PROGNAME" -m 700
	avinstall -T "/var/spool/avmailgate/outgoing" -u $MGTUSER -g "$PROGNAME" -m 700
	avinstall -T "/var/spool/avmailgate/rejected" -u $MGTUSER -g "$PROGNAME" -m 700

	if [ ! -h "/usr/sbin/avmailgate" ]
	then
		rm -f /usr/sbin/avmailgate
	fi

	MANPAGES_DIR="`$ECHO $MANPATH | sed -e 's/:.*//'`"
	if [ -z "$MANPAGES_DIR" ]
	then
		MANPATH_COMMAND=`which manpath`
		if [ -x "$MANPATH_COMMAND" ]
		then
			MANPAGES_DIR="`$MANPATH_COMMAND | sed -e 's/:.*//'`"
		fi
	fi

	if [ ! -d $MANPAGES_DIR/man5 ]
	then
		mkdir $MANPAGES_DIR/man5
	fi
	avinstall -f -S doc/man -s avmailgate.conf.5 -T "$MANPAGES_DIR/man5" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc/man -s avmailgate.acl.5 -T "$MANPAGES_DIR/man5" -u root -g "$PROGNAME" -m 644

	if [ ! -d $MANPAGES_DIR/man8 ]
	then
		mkdir $MANPAGES_DIR/man8
	fi
	avinstall -f -S doc/man -s avmailgate.8 -T "$MANPAGES_DIR/man8" -u root -g "$PROGNAME" -m 644

	if [ ! -f "/etc/avira/avmailgate.acl" ]
	then
		LOCAL_ACL=""
		for aclitem in $ACLLIST
		do
			if [ -z "$LOCAL_ACL" ]
			then
				LOCAL_ACL="$aclitem"
			else
				LOCAL_ACL="$LOCAL_ACL $aclitem"
			fi
		done

		$ECHO " "
		$ECHO "Enter the hosts and/or domains that are local:"
		$ECHO -n "[$LOCAL_ACL]: "

		INPUT=$MAILGATE_LOCALACL
		if [ -z "$INPUT" ]
		then
			read INPUT
			if [ -z "$INPUT" ]
			then
				INPUT="$LOCAL_ACL"
			fi
		else
			$ECHO "$INPUT"
		fi
		LOCAL_ACL="$INPUT"

		RELAY_ACL="127.0.0.1/8"

		$ECHO " "
		$ECHO "Please enter the hosts and networks that are allowed to relay."
		$ECHO "When running MailGate in content filter mode (SMTP), the address"
		$ECHO "suggested below will be sufficient. You can change this setting by"
		$ECHO "editing the file /etc/avira/avmailgate.acl afterwards."
		$ECHO -n "[$RELAY_ACL]: "

		INPUT=$MAILGATE_RELAYACL
		if [ -z "$INPUT" ]
		then
			read INPUT
			if [ -z "$INPUT" ]
			then
				INPUT="$RELAY_ACL"
			fi
		else
			$ECHO "$INPUT"
		fi
		RELAY_ACL="$INPUT"

		$ECHO "# Access lists for Avira MailGate" > /etc/avira/avmailgate.acl
		$ECHO "" >> /etc/avira/avmailgate.acl
		$ECHO "# These hosts and/or domains are local." >> /etc/avira/avmailgate.acl
		$ECHO "local: localhost" >> /etc/avira/avmailgate.acl
		if [ "${LOCAL_ACL}" != "localhost localhost" ]
		then
			$ECHO "local: $LOCAL_ACL" >> /etc/avira/avmailgate.acl
		fi
		$ECHO "" >> /etc/avira/avmailgate.acl
		$ECHO "# These hosts and networks are allowed to relay." >> /etc/avira/avmailgate.acl
		$ECHO "relay: $RELAY_ACL" >> /etc/avira/avmailgate.acl
		$ECHO "" >> /etc/avira/avmailgate.acl

		chown root:antivir /etc/avira/avmailgate.acl
		chmod 640 /etc/avira/avmailgate.acl
	fi

	if [ ! -x "/usr/sbin/avmailgate" ]
	then
		$ECHO " "
		check_yesno_input "Would you like to create a link in /usr/sbin for avmailgate? [y] " $MAILGATE_ADDLINK
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			$ECHO -n "linking /usr/sbin/avmailgate to $AVDIR/avmailgate ... "
			rm -f /usr/sbin/avmailgate
			ln -s "$AVDIR/avmailgate" /usr/sbin/avmailgate
			$ECHO "done"
		fi
	fi

	SSS_SCRIPT="$AVDIR/avmailgate"
	SSS_NAME="Avira MailGate"

	STARTMAILGATE=1
	$ECHO " "
	$ECHO "Please specify if boot scripts should be set up."
	check_yesno_input "Set up boot scripts? [y] " $MAILGATE_AUTOSTART
	if [ "$?" -eq "0" ]
	then
		STARTMAILGATE=0
	fi

	SSS_START=$STARTMAILGATE
	setup_startup_scripts

	$ECHO "installation of main program complete"
}


mount_scan_paths()
{
	# show what will be mounted
	while read FSTAB_LINE
	do
		# use awk to ignore tabs or spaces from variable name
                FSTYPE=`$ECHO $FSTAB_LINE |sed 's/^[ \t]*//' |grep -v ^#|  awk -F' ' '{ print $3 }'`
                MOUNT_PATH=`$ECHO $FSTAB_LINE |sed 's/^[ \t]*//' |grep -v ^#|  awk -F' ' '{ print $2 }'`
		if [ "$FSTYPE" = "dazukofs" ]
		then
			$ECHO "Mounting $MOUNT_PATH as dazukofs..."
			$ECHO ""
		fi
	done < /etc/fstab

	mount -a -t dazukofs  >/dev/null 2>&1
	if [ $? -ne 0 ]
	then
		$ECHO "Mount failed maybe some mount points are not valid"
	fi
}


edit_includepath_4_fstab()
{
	# Add current /etc/fstab dazukofs entries to INCLUDEPATH
	while read FSTAB_LINE
	do
		FSTYPE=`$ECHO $FSTAB_LINE | sed 's/^[ \t]*//' | grep -v ^# | awk -F' ' '{ print $3 }'`
		NEW_INCLUDE_PATH=`$ECHO $FSTAB_LINE | sed 's/^[ \t]*//' | grep -v ^# | awk -F' ' '{ print $2 }'`
		if [ "$FSTYPE" = "dazukofs" ]
		then
			if [ -d $NEW_INCLUDE_PATH ]
			then
				INCLUDEPATH="$INCLUDEPATH ${NEW_INCLUDE_PATH}"
			fi
                fi
        done < /etc/fstab

        # If nothing was found in /etc/fstab,
        # import from old /etc/avguard.conf
        NEW_PATHS=0 # This variable is needed for preventing duplicate entries in /etc/fstab
        if [ -z "$INCLUDEPATH" -a -f /etc/avguard.conf ]
        then
                for ITEM in `sed 's/^[ \t]*//' /etc/avguard.conf | grep -v ^# | grep -i IncludePath | awk -F' ' '{ print $2 }' | sort | uniq`
		do
			if [ -d $ITEM ]
			then
				INCLUDEPATH="$INCLUDEPATH $ITEM"
			fi
		done
                NEW_PATHS=1
        fi

        $ECHO ""
        $ECHO "Guard will automatically protect all directories"
        $ECHO "which are mounted upon dazukofs filesystem."
        $ECHO ""
        sleep 1

	if [ "$HAS_INF" -eq 0 ]
	then 
		if [ -z "$INCLUDEPATH" ]
		then
			$ECHO "Please specify at least one directory to be protected"
			$ECHO -n "by Guard to add in /etc/fstab : [/home] "
			read INPUT
			if [ -z "$INPUT" ]
			then
				INPUT="/home"
			fi

			while [ ! -d "$INPUT" ]
			do
				$ECHO "$INPUT is not a valid directory path,"
				$ECHO -n "please reenter: "
				read INPUT
			done
                        INCLUDEPATH=$INPUT
			NEW_PATHS=1
		fi
	else
# 		use the non-interactive value, even if this is empty
		INCLUDEPATH="$INCLUDEPATH $NEW_INCLUDEPATH"
		NEW_PATHS=1
	fi
	
	$ECHO "The following directories will be protected by Guard:"
	for ITEM in $INCLUDEPATH
	do
		if [ -d $ITEM ]
		then
			$ECHO "$ITEM"
		fi
	done

	$ECHO ""
	$ECHO "If you want to remove or include more directories"
	$ECHO "you will need to edit your /etc/fstab file and remount dazukofs."
	$ECHO ""

	sleep 1

	if [ "$NEW_PATHS" -eq 1 ]
	then
		$ECHO "backup original /etc/fstab to /etc/fstab.orig"
		cp /etc/fstab /etc/fstab.orig
	
		# add the example
		$ECHO "# DazukoFS ...
# Example of mounting one dir onto dazukofs (directory to be protected by Avira Guard)
#/home/shared /home/shared dazukofs" >> /etc/fstab

		for ITEM in $INCLUDEPATH
		do
			$ECHO -n "adding DazukoFS IncludePath $ITEM to /etc/fstab ... "
			$ECHO   "$ITEM    $ITEM    dazukofs" >> /etc/fstab
			$ECHO "done"
		done

		$ECHO "# ... DazukoFS" >> /etc/fstab
	fi
}


move_file_link()
{
	LINK_2_MOVE="$1"

	if [ -x "`which dpkg-divert 2>/dev/null`" ]
	then
		$ECHO -n "move ${LINK_2_MOVE} to ${LINK_2_MOVE}.pre-installed ... "
		dpkg-divert --rename --divert ${LINK_2_MOVE}.pre-installed ${LINK_2_MOVE} > /dev/null
		if [ $? -eq 0 ]
		then
			$ECHO "done"
		else
			$ECHO "fail"
		fi
	else
		$ECHO -n "move /usr/bin/avscan to /usr/bin/avscan.pre-installed ... "
		mv ${LINK_2_MOVE} ${LINK_2_MOVE}.pre-installed
		$ECHO "done"
	fi
}


enable_unsupported_modules()
{
# 	check if the os is a suse os
	if [ -f "/etc/SuSE-release" ]
	then
# 		check if the os is a enterprise version and what version
		cat /etc/SuSE-release | grep "Enterprise" > /dev/null 2>&1
		if [ "$?" -eq "0" ]
		then
			SLES_VERSION="0"
			ENTERPRISE="1"
			SLES_VERSION="`cat /etc/SuSE-release | grep "VERSION" | sed -s 's,VERSION\ \=\ ,,'`"
		else
			ENTERPRISE="0"
			SLES_VERSION="0"
		fi

# 		if the os is a suse enterprise an the version equal or greater than 11 start the user question
		if [ "$ENTERPRISE" -eq "1" -a "$SLES_VERSION" -ge "11" ]
		then
			cat /etc/modprobe.d/unsupported-modules | grep "^allow_unsupported_modules\ 1" > /dev/null 2>&1
			if [ "$?" -ne "0" ]
			then
				${ECHO} "To run DazukoFS on your system you have to enable the feature to"
				${ECHO} "load unsupported kernel modules. When this feature is not enabled,"
				${ECHO} "DazukoFS will not work properly."
				${ECHO} " "
				${ECHO} "INFO: Loading unsupported modules results in, the kernel being tainted"
				${ECHO} "Because ot this, your kernel may not be fully supported by Novell"
				check_yesno_input "Would you like to enable the feature to load unsupported modules? [y] " $INST_DAZUKO
				if [ "$?" -eq "1" -o "$?" -eq "2" ]
				then
					cp /etc/modprobe.d/unsupported-modules /etc/modprobe.d/unsupported-modules.orig
					
					${ECHO} -n "patch /etc/modprobe.d/unsupported-modules and enable the unsupported modules ... "
					cat /etc/modprobe.d/unsupported-modules.orig | sed -e 's,^allow_unsupported_modules\ 0,allow_unsupported_modules\ 1,' > /etc/modprobe.d/unsupported-modules
					${ECHO} "done"

					rm /etc/modprobe.d/unsupported-modules.orig
				fi
			fi
		fi
	fi
}


add_dazuko_support()
{
	ACTIVE_DAZUKO_LIB=''
	if [ $OS = 'sunos' ]
	then
		SUNOS_VERSION="`sh script/getsysteminfo | sed 's/sunos\-//'`"
		case ${SUNOS_VERSION} in
			5.9)
				ACTIVE_DAZUKO_LIB="libdazukoSolaris9.so"
				;;
			5.10)
				ACTIVE_DAZUKO_LIB="libdazukoSolaris10.so"
				;;
			*)
				${ECHO} "The Dazuko library in this package was not complied for Sun ${SUNOS_VERSION}"
				exit 27
				;;
		esac

		INSTALL_DAZUKOFS='n'
		return 0
	else
		ACTIVE_DAZUKO_LIB='libdazuko3compat2.so'
	fi
	INSTALL_DAZUKOFS='y'

	grep dazukofs /proc/devices > /dev/null 2>&1
	DAZUKO_MODULE_LOADED="$?"

# 	update the module list
	depmod -ae > /dev/null 2>&1

	modprobe -l | grep dazukofs.ko > /dev/null 2>&1
	PREINSTALLED_DAZUKO_FOUND="$?"

	if [ "$DAZUKO_MODULE_LOADED" -eq 0 -o "$PREINSTALLED_DAZUKO_FOUND" -eq 0 ]
	then
		$ECHO " "
		$ECHO "Preinstalled dazukofs module found on your system."
		check_yesno_input "Would you like to reinstall dazukofs now? [y] " $INST_DAZUKO
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			enable_unsupported_modules
			$ECHO -n "installing dazuko ... "
			cd contrib/dazuko
			/bin/sh install_dazuko.sh
			DAZUKOFS_INSTALL_FAIL="$?"
			if [ "$DAZUKOFS_INSTALL_FAIL" -eq 0 ]
			then
				cd ../..
				return 0
			fi
			cd ../..
		fi
	fi

	if [ "$DAZUKO_MODULE_LOADED" -eq 0 ]
	then
		$ECHO 'Dazukofs module is loaded'
		return 0
	fi

	if [ "$PREINSTALLED_DAZUKO_FOUND" -eq 0 ]
	then
		$ECHO -n 'Preinstalled dazukofs module found, probing... '
		modprobe dazukofs >/dev/null 2>&1
		if [ "$?" -eq 0 ]
		then
			$ECHO 'success'
			return 0
		else
			$ECHO 'failed'
		fi
	fi

	# Try to compile a dazukofs module      
	$ECHO
	$ECHO 'No Dazukofs module found on your system.'
	$ECHO
	$ECHO 'DazukoFS is a stackable filesystem driver developed independently'
	$ECHO 'by the Dazuko project (www.dazuko.org).'
	$ECHO 'Which means codechanges, bugfixes and roadmap of this driver is completely'
	$ECHO 'done by the Dazuko project and their community.'
	$ECHO
	$ECHO 'For your convenience you can start the DazukoFS installation from here.'
	$ECHO
	check_yesno_input "Would you like to install dazukofs now? [y] " $INST_DAZUKO
	if [ "$?" -eq "1" -o "$?" -eq "2" ]
	then
		enable_unsupported_modules
		$ECHO -n "installing dazuko ... "
		cd contrib/dazuko
		/bin/sh install_dazuko.sh
		DAZUKOFS_INSTALL_FAIL="$?"
		if [ "$DAZUKOFS_INSTALL_FAIL" -eq 0 ]
		then
			cd ../..
			return 0
		fi
		cd ../..
	else
		INSTALL_DAZUKOFS='n'
		NO_DAZUKO='1'
	fi

# 	update the module list
	depmod -ae > /dev/null 2>&1

	# Check for a precompiled dazuko2 module
	modprobe -l | grep dazuko.ko  > /dev/null 2>&1
	if [ "$?" -eq 0 ]
	then
		$ECHO
		$ECHO "Precompiled Dazuko2 module was detected on your machine."
		$ECHO "Running Avira Guard with dazuko2 is no longer officially supported."
		$ECHO
		check_yesno_input "Do you still want to use Guard with dazuko2 module? [y] " $USE_DAZUKO2_IF_AVAILABLE
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			$ECHO -n "probing Dazuko2 module ..."
			modprobe dazuko > /dev/null 2>&1
			if [ "$?" -eq 0 ]
			then
				$ECHO "success"
				ACTIVE_DAZUKO_LIB="libdazuko2.so"
				return 0
			else
				$ECHO 'failed'
			fi
		fi
		sleep 1
	fi

	return $DAZUKOFS_INSTALL_FAIL
}


install_guard()
{
	if [ "$VARIANT" = "AVDE" ]
	then
		avinstall -f -S doc -s antivir_server_and_professional_en.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_personal_en.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_server_and_professional_de.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_personal_de.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644

		avinstall -f -S doc -s antivir_server_and_professional_en.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_personal_en.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_server_and_professional_de.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		avinstall -f -S doc -s antivir_personal_de.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	fi

	if [ -x $AVDIR/avguard ]
	then
		$ECHO -n "stop running $FULLPRODUCTNAME ... "
		$AVDIR/avguard stop > /dev/null 2>&1
		$ECHO "done"
	fi


	if [ $OS = "sunos" ]
	then
		DAZUKOLIBS="libdazukoSolaris9.so libdazukoSolaris10.so"
		GCC_LIBS="libgcc_s.so.1 libstdc++.so.6"
	else
		DAZUKOLIBS="libdazuko2.so libdazuko3compat2.so"
		GCC_LIBS="libgcc_s.so.1 libstdc++.so.6"
	fi

	for ITEM in $DAZUKOLIBS $GCC_LIBS avguard-ondemand-mgmt avguard-scanner avscan avsavapi-super avguard.bin
	do
		avinstall -f -S bin/$CLASSIFICATION -s $ITEM -T "$AVDIR" -u root -g "$PROGNAME" -m 755
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	done

        add_dazuko_support
	DAZUKOFS_INSTALL="$?"
        if [ "$DAZUKOFS_INSTALL" -ne '0' -a "$INSTALL_DAZUKOFS" = 'y' ]
        then
                NO_DAZUKO='1'
                $ECHO 'Dazuko installation failed'
                $ECHO
                $ECHO "Dazuko module (www.dazuko.org) provides a virtual device driver allowing"
                $ECHO "Avira Guard to provide resident realtime  protection of specified directories from malicious files."
                $ECHO "Guard will not offer \"on access\" protection if it does not find a loaded dazuko"
		$ECHO "module or OnAccessManagement is set to \"no\". You can still continue with the"
                $ECHO "installation if you are only planning to use the command-line scanner (avscan)"
                $ECHO "or you are going to compile your own dazuko module later."
                $ECHO
                check_yesno_input "Would you like to continue the installation? [y] " $CONTINUE_IF_DAZUKO_FAILED
                if [ "$?" -eq "0" ]
		then
			error_message "dazuko installation failed"
                        exit $DAZUKOFS_INSTALL
                fi
	fi
	$ECHO
	$ECHO -n "linking $AVDIR/libdazuko.so to $AVDIR/$ACTIVE_DAZUKO_LIB ... "
	rm -f $AVDIR/libdazuko.so
	ln -s $AVDIR/$ACTIVE_DAZUKO_LIB $AVDIR/libdazuko.so
	$ECHO "done"
	
	if [ "$ACTIVE_DAZUKO_LIB" = 'libdazuko3compat2.so' -a "$NO_DAZUKO" -eq '0' ]
        then
        	edit_includepath_4_fstab
		mount_scan_paths
	fi

	if [ ! -f /etc/avira/${CONFNAME}.conf ]
	then
		avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -u root -g "$PROGNAME" -m 644
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	else
		FOUNDCONF="1"
	fi
	avinstall -f -S etc -s "${CONFNAME}.conf" -T /etc/avira -t "${CONFNAME}.conf.default" -u root -g "$PROGNAME" -m 644

	if [ ! -f /etc/avira/${CONFNAME}-scanner.conf ]
	then
		avinstall -f -S etc -s "${CONFNAME}-scanner.conf" -T /etc/avira -u root -g "$PROGNAME" -m 644
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	fi
	avinstall -f -S etc -s "${CONFNAME}-scanner.conf" -T /etc/avira -t "${CONFNAME}-scanner.conf.default" -u root -g "$PROGNAME" -m 644

	if [ ! -f /etc/avira/avscan.conf ]
	then
		avinstall -f -S etc -s avscan.conf -T "/etc/avira" -u root -g "$PROGNAME" -m 644
		if [ $? -ne 0 ]
		then
			exit 1
		fi
	fi
	avinstall -f -S etc -s avscan.conf -T "/etc/avira" -t avscan.conf.default -u root -g "$PROGNAME" -m 644

	avinstall -f -s build.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664

	avinstall -f -S script -s avguard_start.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avguard_restart.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avguard_stop.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avguard_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avguardkey_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s start_guard_upgrade.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_reload.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s smcagent_plugin_reload.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	avinstall -f -S script -s avira_start.sh.template -T "$AVDIR" -t "$GUARDNAME" -u root -g "$PROGNAME" -m 755
	cp $AVDIR/avguard $AVDIR/avguard.orig
	cat $AVDIR/avguard.orig | sed -e 's,_PRODUCT_,'${PRODUCT_SCRIPT}',' -e 's,_UPD-PRODUCT_,'${UPD_PRODUCT}',' -e 's,_FULLPRODUCTNAME_,'"${FULLPRODUCTNAME_SCRIPT}"',' > $AVDIR/avguard
	rm $AVDIR/avguard.orig

# 	check if /var/run/avguard has the correct permissions at installtime. if not, set it to default 644
	if [ -d "/var/run/avguard" ]
	then
		chmod 711 /var/run/avguard
	fi

	if [ "$OS" = "sunos" ]
	then
		$ECHO " "
		$ECHO "Version $PRODUCTVERSION of $FULLPRODUCTNAME is capable of on-access,"
		$ECHO "real-time scanning of files. This provides the ultimate protection"
		$ECHO "against viruses and other unwanted software. The on-access scanner"
		$ECHO "(called Avira Guard) is based on Dazuko, a free software project providing"
		$ECHO "access control."
		$ECHO " "
		check_yesno_input "Would you like to install dazuko now? [y] " $INST_DAZUKO
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			KMODULE="dazuko"
	
			SUNOS_VERSION="`sh script/getsysteminfo | sed 's/sunos\-//'`"
			case ${SUNOS_VERSION} in
				5.9)
					KMODULE_SOURCE="dazuko_5.9"
					;;
				5.10)
					KMODULE_SOURCE="dazuko_5.10"
					;;
				*)
					${ECHO} "The Dazuko modue in this package was not complied for Sun ${SUNOS_VERSION}"
					exit 1
					;;
			esac
	
			
			OSPROC=`uname -p`
			case "${OSPROC}" in
			sparc)  USR_KERNEL_DRV_SUBDIR="/sparcv9";;
			i386)   USR_KERNEL_DRV_SUBDIR="";;
			esac
	
			if [ ! -d "/usr/kernel/drv" ]
			then
				mkdir -p /usr/kernel/drv
				chmod 755 /usr/kernel/drv
			fi
	
			avinstall -f -S bin/$CLASSIFICATION -s dazuko.conf -T /usr/kernel/drv -u root -g root -m 644
			if [ $? -ne 0 ]
			then
				exit 1
			fi
	
			if [ -n "${USR_KERNEL_DRV_SUBDIR}" -a ! -d "/usr/kernel/drv${USR_KERNEL_DRV_SUBDIR}" ]
			then
				mkdir -p /usr/kernel/drv${USR_KERNEL_DRV_SUBDIR}
				chmod 755 /usr/kernel/drv${USR_KERNEL_DRV_SUBDIR}
			fi
	
			avinstall -f -S bin/$CLASSIFICATION -s "$KMODULE_SOURCE" -T /usr/kernel/drv${USR_KERNEL_DRV_SUBDIR} -t "$KMODULE" -u root -g root -m 644
			if [ $? -ne 0 ]
			then
				exit 1
			fi
	
			avinstall -T "$AVDIR/$KERNELVERSION" -u root -g "$PROGNAME" -m 755
	
			avinstall -f -S bin/$CLASSIFICATION -s "$KMODULE_SOURCE" -T "$AVDIR/$KERNELVERSION" -t "$KMODULE" -u root -g "$PROGNAME" -m 644
			if [ $? -ne 0 ]
			then
				exit 1
			fi
	
			if [ ! -c "/devices/pseudo/dazuko@0:dazuko" ]
			then
				$ECHO -n "installing Dazuko ... "
				add_drv $KMODULE
				if [ $? -ne 0 ]
				then
					$ECHO "failed"
					$ECHO " "
					exit 1
				fi
				$ECHO "done"
			fi
		fi
	fi

	if [ -f "/home/quarantine/.bashrc" -o -f "/home/quarantine/.profile" ]
	then
		$ECHO " "
		$ECHO "INFO: /home/quarantine, the Avira Guard default quarantine directory,"
		$ECHO "      already exist and is probably a user directory."
		$ECHO "      You can change the quarantine directory in /etc/avira/avguard.conf."
		$ECHO "      and /etc/avira/avscan.conf after the installation."
		$ECHO " "
		check_yesno_input "Would you like to continue the installation? [y]" $CREATE_QUAR_SMC
		if [ "$?" -eq "0" ]
		then
			exit 1
		fi
	fi

	if [ ! -d "/home/quarantine" ]
	then
		$ECHO "/home/quarantine, the Avira Guard default quarantine directory,"
		$ECHO "does not exist."
		$ECHO " "
		$ECHO "INFO: You can change the quarantine directory in /etc/avira/avguard.conf."
		$ECHO "      and /etc/avira/avscan.conf after the installation."
		$ECHO " "
		check_yesno_input "Would you like to create /home/quarantine? [y] " $CREATE_QUAR_SMC
		if [ "$?" -eq "0" ]
		then
			CREATE_QUAR=0
		fi
	fi

	if [ $CREATE_QUAR -eq 1 ]
	then
		avinstall -T "/home/quarantine" -u root -g "$PROGNAME" -m 1770
	fi

	BASH=`which bash`
	if [ -x "$BASH" ]
	then
		$ECHO " "
		check_yesno_input "Would you like to install the Avira Guard GNOME plugin? [n] " $GNOME_INSTALL
		if [ "$?" -eq "1" ]
		then
			$ECHO 'installing Avira Guard GNOME plugin ... '
			cd contrib/applet
			$BASH install.sh
			if [ $? -eq 0 ]
			then
				$ECHO "done"
				ADD_GNOME_PLUGIN_SUPPORT=1
			else
				$ECHO "fail"
			fi

			cd ../..
		fi
	else
		$ECHO " "
		$ECHO "Cannot execute bash shell."
		$ECHO "This shell is necessary to build the Avira Guard GNOME plugin."
	fi

	if [ -h /usr/bin/avscan -o -x /usr/bin/avscan ]
	then
		ls -la /usr/bin/avscan | grep $AVDIR/avscan > /dev/null 2>&1
		if [ "$?" -eq 0 ]
		then
			$ECHO -n "linking /usr/bin/avscan to $AVDIR/avscan ... "
			rm -f /usr/bin/avscan
			ln -s $AVDIR/avscan /usr/bin/avscan
			$ECHO "done"
		else
			move_file_link /usr/bin/avscan
	
			$ECHO -n "linking /usr/bin/avscan to $AVDIR/avscan ... "
			rm -f /usr/bin/avscan
			ln -s $AVDIR/avscan /usr/bin/avscan
			$ECHO "done"
		fi
	else
		$ECHO -n "linking /usr/bin/avscan to $AVDIR/avscan ... "
		ln -s $AVDIR/avscan /usr/bin/avscan
		$ECHO "done"
	fi

	if [ -h /usr/bin/scan -o -x /usr/bin/scan ]
	then
		ls -la /usr/bin/scan | grep $AVDIR/avscan > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			$ECHO -n "linking /usr/bin/scan to $AVDIR/avscan ... "
			rm -f /usr/bin/scan
			ln -s $AVDIR/avscan /usr/bin/scan
			$ECHO "done"
		else
			move_file_link /usr/bin/scan
	
			$ECHO -n "linking /usr/bin/scan to $AVDIR/avscan ... "
			rm -f /usr/bin/scan
			ln -s $AVDIR/avscan /usr/bin/scan
			$ECHO "done"
		fi
	else
		$ECHO -n "linking /usr/bin/scan to $AVDIR/avscan ... "
		ln -s $AVDIR/avscan /usr/bin/scan
		$ECHO "done"
	fi

	if [ ! -x "/usr/sbin/$GUARDNAME" ]
	then
		$ECHO " "
		check_yesno_input "Would you like to create a link in /usr/sbin for ${GUARDNAME}? [y] " $GUARD_ADDLINK
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			$ECHO -n "linking /usr/sbin/$GUARDNAME to $AVDIR/$GUARDNAME ... "
			rm -f /usr/sbin/$GUARDNAME
			ln -s $AVDIR/$GUARDNAME /usr/sbin/$GUARDNAME
			$ECHO "done"
		fi
	fi

	SSS_SCRIPT="$AVDIR/$GUARDNAME"
	SSS_NAME="Avira Guard"

	STARTGUARD=1
	$ECHO " "
	$ECHO "Please specify if boot scripts should be set up."
	check_yesno_input "Set up boot scripts? [y] " $GUARD_AUTOSTART
	if [ "$?" -eq "0" ]
	then
		STARTGUARD=0
	fi

	SSS_START=$STARTGUARD
	setup_startup_scripts

	$ECHO " "
	$ECHO "installation of Avira Guard complete"

}


install_ium()
{
	if [ ! -d "$AVDIR_BASE" ]
	then
		avinstall -T "$AVDIR_BASE" -u root -g "$PROGNAME" -m 755
		if [ $? -ne 0 ]
		then
			error_message "error: failed to create $AVDIR_BASE"
			exit 1
		fi
	fi

	if [ ! -d "$AVDIR" ]
	then
		avinstall -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	fi

	if [ ! -d "$AVDIR/ssl" ]
	then
		avinstall -T "$AVDIR/ssl" -u root -g "$PROGNAME" -m 755
	fi

	if [ ! -d /etc/avira ]
	then
		avinstall -T "/etc/avira" -u root -g "$PROGNAME" -m 775
	fi

	if [ -x $AVDIR/avium ]
	then
		$ECHO -n "stop running $FULLPRODUCTNAME ... "
		$AVDIR/avium stop > /dev/null 2>&1
		$ECHO "done"
	fi

	avinstall -f -s uninstall -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -s uninstall_smcplugin.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S etc -s file_list -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s dir_list -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -S etc -s run.inf -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -s README.uninstall -T "$AVDIR" -u root -g "$PROGNAME" -m 664
	avinstall -f -s build.dat -T "$AVDIR" -u root -g "$PROGNAME" -m 664

	avinstall -f -S bin/$CLASSIFICATION -s ium -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s ium_msg.avr -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s common_msg.avr -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s libcommon.so -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s libupdate.so -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s avverifier -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	
	avinstall -f -S bin/$CLASSIFICATION -s avupdate.bin -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S bin/$CLASSIFICATION -s avupdate_msg.avr -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	avinstall -f -S doc -s avupdater.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s MANUAL -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s man_avira_antivir-internetupdatemanager_de.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	avinstall -f -S doc -s man_avira_antivir-internetupdatemanager_en.pdf -T "$AVDIR" -u root -g "$PROGNAME" -m 644

	avinstall -f -S script -s $UPDATENAME.template -T "$AVDIR" -t $UPDATENAME-$UPDATE_CONF_NAME -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avium_start.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avium_restart.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avium_stop.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s avium_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S script -s rcscript -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	avinstall -f -S script -s avira_start.sh.template -T "$AVDIR" -t avium -u root -g "$PROGNAME" -m 755
	cp $AVDIR/avium $AVDIR/avium.orig
	cat $AVDIR/avium.orig | sed -e 's,_PRODUCT_,'${PRODUCT}',' -e 's,_UPD-PRODUCT_,'${UPD_PRODUCT}',' -e 's,_FULLPRODUCTNAME_,'"${FULLPRODUCTNAME}"',' > $AVDIR/avium
	rm $AVDIR/avium.orig

	avinstall -f -S cert -s cacert.pem -T "$AVDIR/ssl" -u root -g "$PROGNAME" -m 755
	avinstall -f -S cert -s server.pem -T "$AVDIR/ssl" -u root -g "$PROGNAME" -m 755

	avinstall -f -S etc -s iumproducts.xml -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	if [ ! -f /etc/avira/mirrorconfig.xml ]
	then
		avinstall -f -S etc -s mirrorconfig.xml -T "/etc/avira" -u root -g "$PROGNAME" -m 640
	fi
	avinstall -f -S etc -s mirrorconfig.xml -T "/etc/avira" -t mirrorconfig.xml.default -u root -g "$PROGNAME" -m 640

	if [ ! -f /etc/avira/ium.conf ]
	then
		avinstall -f -S etc -s ium.conf -T "/etc/avira" -u root -g "$PROGNAME" -m 640
	fi
	avinstall -f -S etc -s ium.conf -T "/etc/avira" -t ium.conf.default -u root -g "$PROGNAME" -m 640

	if [ ! -f /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf ]
	then
		avinstall -f -S etc -s $UPDATENAME.conf -T /etc/avira -t $UPDATENAME-$UPDATE_CONF_NAME.conf -u root -g "$PROGNAME" -m 640
		if [ "$PRODUCT" != "savapi" ]
		then
			patch_install_temp
		fi
	fi
	avinstall -f -S etc -s $UPDATENAME.conf -T /etc/avira -t $UPDATENAME-$UPDATE_CONF_NAME.conf.default -u root -g "$PROGNAME" -m 640

	avinstall -f -S templates -s ium_index.htm -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S templates -s ium_error501.htm -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S templates -s ium_error404.htm -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	avinstall -f -S doc -s mail_template_iumstatus.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	if [ ! -x "/usr/sbin/avium" ]
	then
		$ECHO " "
		check_yesno_input "Would you like to create a link in /usr/sbin for avium? [y] "
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			$ECHO -n "linking /usr/sbin/avium to $AVDIR/avium ... "
			rm -f /usr/sbin/avium
			ln -s "$AVDIR/avium" /usr/sbin/avium
			$ECHO "done"
		fi
	fi

	SSS_SCRIPT="$AVDIR/avium"
	SSS_NAME="Avira AUM"

	STARTIUM=1
	$ECHO " "
	$ECHO "Please specify if boot scripts should be set up."
	check_yesno_input "Set up boot scripts? [y] "
	if [ "$?" -eq "0" ]
	then
		STARTIUM=0
	fi

	SSS_START=$STARTIUM
	setup_startup_scripts

	$ECHO "installation of Avira AUM complete"
}


parse_iface_for_ip_port()
{
	# input: IFACE

	PARSED_IP="?"
	PARSED_PORT="?"

	if [ -z "$IFACE" ]
	then
		return 1
	fi

	$ECHO $IFACE | grep ":" > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		PARSED_IP=`$ECHO $IFACE | sed -e 's/:.*//'`
		PARSED_PORT=`$ECHO $IFACE | sed -e 's/.*://'`
	else
		PARSED_IP="$IFACE"
	fi

	return 0
}


check_ip_exit()
{
	CHECK_IP_EXIT_RC=0

	if [ -z "$1" ]
	then
		CHECK_IP_EXIT_RC=1
	elif [ "$1" != "0.0.0.0" ]
	then
		ping -n -c 1 "$1" > /dev/null 2>&1
		if [ $? -ne 0 ]
		then
			(echo ""; sleep 1 ) | telnet "$1" 7000 2>&1 | grep 'Connected to' > /dev/null 2>&1
			if [ $? -ne 0 ]
			then
				CHECK_IP_EXIT_RC=1
			fi
		fi
	fi

	if [ $CHECK_IP_EXIT_RC -ne 0 ]
	then
		$ECHO " "
		$ECHO "invalid address: $1"
		$ECHO " "
		error_message "error: invalid address $1"
		exit 1
	fi
}


check_smc_parameters()
{
	CHECK_SMC_PARAMETER_ERROR=0

	if [ "$AGENT_AGENTPORT" = "$NO_VALUE" ]
	then
		$ECHO " "
		$ECHO "missing argument: --agent_port=PORT"
		$ECHO " "
		$ECHO "See doc/INSTALL for more information."
		$ECHO " "
		error_message "error: missing ---agent_port argument"
		CHECK_SMC_PARAMETER_ERROR=1
	fi

	if [ "$AGENT_SERVERIP" = "$NO_VALUE" ]
	then
		$ECHO " "
		$ECHO "missing argument: --server_uri=http://HOST[:PORT]"
		$ECHO " "
		$ECHO "See doc/INSTALL for more information."
		$ECHO " "
		error_message "error: missing --server_uri argument"
		CHECK_SMC_PARAMETER_ERROR=1
	fi

	if [ "$AGENT_DISPLAYNAME" = "$NO_VALUE" ]
	then
		$ECHO " "
		$ECHO "missing argument: --display_name=<AMC display name>"
		$ECHO " "
		$ECHO "See doc/INSTALL for more information."
		$ECHO " "
		error_message "error: missing --display_name argument"
		CHECK_SMC_PARAMETER_ERROR=1
	fi

	if [ "$AGENT_UPDATEMANAGERIP" = "$NO_VALUE" ]
	then
		$ECHO " "
		$ECHO "missing argument: --update_uri=http://HOST[:PORT]"
		$ECHO " "
		$ECHO "See doc/INSTALL for more information."
		$ECHO " "
		error_message "error: missing --update_uri argument"
		CHECK_SMC_PARAMETER_ERROR=1
	fi


	if [ $CHECK_SMC_PARAMETER_ERROR -ne 0 ]
	then
		exit 1
	fi

	if [ "$AGENT_EVENTMANAGERIP" = "$NO_VALUE" ]
	then
		AGENT_EVENTMANAGERIP="$AGENT_SERVERIP"
	fi

	check_ip_exit $AGENT_SERVERIP
	check_ip_exit $AGENT_EVENTMANAGERIP
	check_ip_exit `$ECHO $AGENT_UPDATEMANAGERIP`
}


install_avupdate()
{
	INSTALLUPDATER=1
	if [ ! -x "/usr/sbin/$UPDATENAME-$UPDATE_CONF_NAME" ]
	then
		$ECHO " "
		check_yesno_input "Would you like to create a link in /usr/sbin for $UPDATENAME-$UPDATE_CONF_NAME? [y] " $UPDATER_ADDLINK
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			$ECHO -n "linking /usr/sbin/$UPDATENAME-$UPDATE_CONF_NAME to $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME ... "
			rm -f /usr/sbin/$UPDATENAME-$UPDATE_CONF_NAME
			ln -s $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME /usr/sbin/$UPDATENAME-$UPDATE_CONF_NAME
			$ECHO "done"
		else
			NO_UPDATE_LINK="--no-update-link"
		fi
	fi

	if [ $PRODUCT != "ium" -a $PRODUCT != "smcagent" ]
	then
		grep -i "$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner" /etc/cron.d/avira_updater > /dev/null 2>&1
		CRON_SCANNER="$?"
		grep -i "$UPDATENAME-$UPDATE_CONF_NAME --product=Engine" /etc/cron.d/avira_updater > /dev/null 2>&1
		CRON_ENGINE="$?"

		CRON_SCANNER_OLD="1"
		CRON_ENGINE_OLD="1"
		if [ ! -x "$AVDIR_BASE/avguard.bin" -a ! -x "$AVDIR_BASE/avwebgate.bin" ]
		then
			grep -i "$UPDATENAME --product=Scanner" /etc/cron.d/avira_updater > /dev/null 2>&1
			CRON_SCANNER_OLD="$?"
			grep -i "$UPDATENAME --product=Engine" /etc/cron.d/avira_updater > /dev/null 2>&1
			CRON_ENGINE_OLD="$?"
		fi

		if [ "$CRON_SCANNER" -eq "0" -o "$CRON_ENGINE" -eq "0" -o "${CRON_SCANNER_OLD}" -eq "0" -o "${CRON_ENGINE_OLD}" -eq "0" ]
		then
			REPLACE_CRONJOB_4_REAL=0

			$ECHO " "
			$ECHO "Scanner cronjob found in /etc/cron.d/avira_updater"
			check_yesno_input "Would you like to replace the old cronjob? [n] " $REPLACE_CRONJOB
			if [ "$?" -eq "1" ]
			then
				cp /etc/cron.d/avira_updater /etc/cron.d/avira_updater.bak
				touch /etc/cron.d/avira_updater.bak2

				cat /etc/cron.d/avira_updater.bak | grep -vi "$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner" > /etc/cron.d/avira_updater.bak2
				cat /etc/cron.d/avira_updater.bak2 | grep -vi "$UPDATENAME-$UPDATE_CONF_NAME --product=Engine" > /etc/cron.d/avira_updater

				rm /etc/cron.d/avira_updater.bak /etc/cron.d/avira_updater.bak2

				if [ ! -x "$AVDIR_BASE/avguard.bin" -a ! -x "$AVDIR_BASE/avwebgate.bin" ]
				then
					cp /etc/cron.d/avira_updater /etc/cron.d/avira_updater.bak
					cat /etc/cron.d/avira_updater.bak | grep -vi "$AVDIR_BASE/avupdate --product=scanner" > /etc/cron.d/avira_updater
					rm /etc/cron.d/avira_updater.bak
				fi

				REPLACE_CRONJOB_4_REAL=1
			fi
		fi

		if [ $REPLACE_CRONJOB_4_REAL -eq 1 ]
		then
			$ECHO " "
			check_yesno_input "Would you like to setup Scanner update as cron task? [y] " $UPDATER_ADDCRONJOB
			if [ "$?" -eq "1" -o "$?" -eq "2" ]
			then
				if [ ! -f "AV_WKS_PERS" ]
				then
					$ECHO "Please specify the interval to check."
					$ECHO "Recommended values are daily or 2 hours."
					$ECHO " "
					$ECHO -n "available options: d [2] "
					INPUT=$UPDATER_CYCLE_SIG_EN
					if [ -z "$INPUT" ]
					then
						read INPUT
					else
						$ECHO "$INPUT"
					fi
			
					case $INPUT in
						d*|D*)
							UPDATER_CYCLE_SIG_EN="d"
							;;
						*)
							UPDATER_CYCLE_SIG_EN="2h"
							;;
					esac
			
					if [ $UPDATER_CYCLE_SIG_EN = "2h" ]
					then
						START_MIN=`date +%M`
						$ECHO -n "creating Scanner update cronjob ... "
						if [ -d /etc/cron.d ]
						then
							if [ ! -f /etc/cron.d/avira_updater ]
							then
								touch /etc/cron.d/avira_updater
							fi
							
							grep -i Scanner /etc/cron.d/avira_updater > /dev/null 2>&1
							CRON_SCANNER="$?"
							grep -i Engine /etc/cron.d/avira_updater > /dev/null 2>&1
							CRON_ENGINE="$?"
							if [ $CRON_SCANNER -ne 0 -o $CRON_ENGINE -ne 0 ]
							then
								$ECHO "$START_MIN */2 * * * root $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner > /dev/null" >> /etc/cron.d/avira_updater
								chmod 644 /etc/cron.d/avira_updater
							fi
						else
							grep -i Scanner /etc/cron.d/avira_updater > /dev/null 2>&1
							CRON_SCANNER="$?"
							grep -i Engine /etc/cron.d/avira_updater > /dev/null 2>&1
							CRON_ENGINE="$?"
							if [ $CRON_SCANNER -ne 0 -o $CRON_ENGINE -ne 0 ]
							then
								crontab -l | grep -v "$AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner" > $AVDIR/avira_updater
								$ECHO "$START_MIN */2 * * * root $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner > /dev/null" >> $AVDIR/avira_updater
								crontab $AVDIR/avira_updater
							fi
						fi
						$ECHO "done"
					fi
				else
					UPDATER_CYCLE_SIG_EN="d"
				fi
		
				if [ $UPDATER_CYCLE_SIG_EN = "d" ]
				then
					$ECHO " "
					$ECHO "The AntiVir Updater can be set to always check for updates at a"
					$ECHO "particular time of day. This is specified in a HH:MM format"
					$ECHO "(where HH is the hour and MM is the minutes). If you do not have a"
					$ECHO "permanent connection, you may set it to a time when you are usually"
					$ECHO "online."
					$ECHO " "
					$ECHO "available option: HH:MM"
					
					OK=0
					while [ $OK -eq 0 ]
					do
						$ECHO " "
						HH="00"
						MM="15"
						$ECHO -n "What time should updates be done [$HH:$MM]? "
						read INPUT
				
						if [ -z "$INPUT" ]
						then
							OK="1"
						else
							HH=""
							MM=""
							TIME_TEMP=`$ECHO $INPUT | sed -e 's,\:,\ ,'`
							for ITEM in $TIME_TEMP
							do
								if [ -z "$HH" ]
								then
									HH=$ITEM
								elif [ -z "$MM" ]
								then
									MM=$ITEM
								fi
							done
				
							#check if it is a valid time	
							if [ ! -z "$HH" -a ! -z "$MM" ]
							then
								if [ -z "`$ECHO $HH | sed -e 's/[0-9]//g'`" ]
								then
									if [ $HH -ge 0 -a $HH -le 23 ]
									then
										if [ -z "`$ECHO $MM | sed -e 's/[0-9]//g'`" ]
										then
											if [ $MM -ge 0 -a $MM -le 59 ]
											then
												if [ $HH -lt 10 ]
												then
													HH="`$ECHO $HH | sed -e 's/0//g'`"
													if [ -z "$HH" ]
													then
														HH="0"
													fi
													HH="0$HH"
												fi
				
												if [ $MM -lt 10 ]
												then
													MM="`$ECHO $MM | sed -e 's/0//g'`"
													if [ -z "$MM" ]
													then
														MM="0"
													fi
													MM="0$MM"
												fi
												OK=1
											fi
										fi
									fi
								fi
							fi
						fi
				
						if [ $OK -eq 0 ]
						then
							$ECHO "invalid answer: $INPUT"
						fi
					done

					$ECHO -n "creating Scanner update cronjob ... "
					if [ -d /etc/cron.d ]
					then
						if [ ! -f /etc/cron.d/avira_updater ]
						then
							touch /etc/cron.d/avira_updater
						fi

						grep -i Scanner /etc/cron.d/avira_updater > /dev/null 2>&1
						CRON_SCANNER="$?"
						grep -i Engine /etc/cron.d/avira_updater > /dev/null 2>&1
						CRON_ENGINE="$?"
						if [ $CRON_SCANNER -ne 0 -o $CRON_ENGINE -ne 0 ]
						then
							$ECHO "$MM $HH * * * root $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner > /dev/null" >> /etc/cron.d/avira_updater
							chmod 644 /etc/cron.d/avira_updater
						fi
					else
						grep -i Scanner /etc/cron.d/avira_updater > /dev/null 2>&1
						CRON_SCANNER="$?"
						grep -i Engine /etc/cron.d/avira_updater > /dev/null 2>&1
						CRON_ENGINE="$?"
						if [ $CRON_SCANNER -ne 0 -o $CRON_ENGINE -ne 0 ]
						then
							crontab -l | grep -v "$AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner" >> $AVDIR/avira_updater
							$ECHO "$MM $HH * * * root $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=Scanner > /dev/null" >> $AVDIR/avira_updater
							crontab $AVDIR/avira_updater
						fi
					fi
					$ECHO "done"
				fi
			fi
		fi
	fi

	grep -i "$UPDATENAME-$UPDATE_CONF_NAME --product=$CRON_NAME" /etc/cron.d/avira_updater > /dev/null 2>&1
	PRODUCT_CRON="${?}"
	grep -i "$UPDATENAME --product=$CRON_NAME" /etc/cron.d/avira_updater > /dev/null 2>&1
	PRODUCT_CRON_OLD="${?}"
	if [ ${PRODUCT_CRON} -eq "0" -o "${PRODUCT_CRON_OLD}" -eq "0"  ]
	then
		REPLACE_CRONJOB_PRODUCT_4_REAL=0

		$ECHO " "
		$ECHO "$CRON_NAME cronjob found in /etc/cron.d/avira_updater"
		check_yesno_input "Would you like to replace the old cronjob? [n] " $REPLACE_CRONJOB_PRODUCT
		if [ "$?" -eq "1" ]
		then
			cp /etc/cron.d/avira_updater /etc/cron.d/avira_updater.bak
			cat /etc/cron.d/avira_updater.bak | grep -vi "$UPDATENAME-$UPDATE_CONF_NAME --product=$CRON_NAME" > /etc/cron.d/avira_updater
			rm /etc/cron.d/avira_updater.bak
			cp /etc/cron.d/avira_updater /etc/cron.d/avira_updater.bak
			cat /etc/cron.d/avira_updater.bak | grep -vi "$UPDATENAME --product=$CRON_NAME" > /etc/cron.d/avira_updater
			rm /etc/cron.d/avira_updater.bak
			REPLACE_CRONJOB_PRODUCT_4_REAL=1
		fi
	fi

	if [ $REPLACE_CRONJOB_PRODUCT_4_REAL -eq 1 -a "$PRODUCT" != "savapi" ]
	then
		$ECHO " "
		check_yesno_input "Would you like to check for $UPD_PRODUCT updates once a week? [n] " $UPDATER_CYCLE_PROD
		if [ "$?" -eq "1" ]
		then
			START_MIN=`date +%M`
			START_HOUR=`date +%H`
			$ECHO -n "creating $UPD_PRODUCT update cronjob ... "
			if [ -d /etc/cron.d ]
			then
				if [ ! -f /etc/cron.d/avira_updater ]
				then
					touch /etc/cron.d/avira_updater
				fi
	
				grep $CRON_NAME /etc/cron.d/avira_updater > /dev/null 2>&1
				if [ $? -ne 0 ]
				then
					$ECHO "$START_MIN $START_HOUR * * Tue root $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=$CRON_NAME > /dev/null" >> /etc/cron.d/avira_updater
					chmod 644 /etc/cron.d/avira_updater
				fi
			else
				grep $CRON_NAME $AVDIR/avira_updater > /dev/null 2>&1
				if [ $? -ne 0 ]
				then
					crontab -l | grep -v "$AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=$CRON_NAME" > $AVDIR/avira_updater
					$ECHO "$START_MIN * * * Tue root $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=$CRON_NAME > /dev/null" >> $AVDIR/avira_updater
					crontab $AVDIR/avira_updater
				fi
			fi
			$ECHO "done"
		fi
	fi
}


check_old_savapi_based_product()
{
	if [ "${PRODUCT}" = "savapi" ]
	then
		if [ -f ${AVDIR_BASE}/savapi ]
		then
			${ECHO} ""
			${ECHO} "INFO: A Savapi3 binary was found: ${AVDIR_BASE}/savapi"
			${ECHO} "The ${FULLPRODUCTNAME} installation package is not compatible to savapi"
			${ECHO} "based  products. Please remove the installed product first."
			exit 1
		fi
	fi
}


# main
	echo $0 | grep "^/" > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		CHECKINSTALLERDIR=$0
	else
		CHECKINSTALLERDIR=`pwd`/$0
	fi
	
	INSTALLERDIR=`dirname $CHECKINSTALLERDIR 2> /dev/null`
	
	if [ ! -z "$INSTALLERDIR" ]
	then
		cd "$INSTALLERDIR"
	fi
	
	if [ -f ".installrc" ]
	then
		. ./.installrc
	fi
	
	AVDIR_BASE="/usr/lib/AntiVir"
	PROGNAME="antivir"
	SAVAPI3="savapi"
	VDFNAME="vbase000.vdf vbase001.vdf vbase002.vdf vbase003.vdf vbase004.vdf vbase005.vdf vbase006.vdf \
		 vbase007.vdf vbase008.vdf vbase009.vdf vbase010.vdf vbase011.vdf vbase012.vdf vbase013.vdf \
		 vbase014.vdf vbase015.vdf vbase016.vdf vbase017.vdf vbase018.vdf vbase019.vdf vbase020.vdf \
		 vbase021.vdf vbase022.vdf vbase023.vdf vbase024.vdf vbase025.vdf vbase026.vdf vbase027.vdf \
		 vbase028.vdf vbase029.vdf vbase030.vdf vbase031.vdf"
	UPDATENAME="avupdate"
	GUARDNAME="avguard"
	SMCAGENTNAME="agent"
	MGTUSER="uucp"
	STEP="1"
	HASGUARD="0"
	NO_DAZUKO="0"
	HASCMDSCANNER="0"
	HASSMC="0"
	HASCOREBINARY="0"
	INSTALLUPDATER="0"
	INSTALLSMC="0"
	CONFIG_CORE="0"
	REPLACE_CRONJOB_4_REAL="1"
	REPLACE_CRONJOB_PRODUCT_4_REAL="1"
	ACTIVATE_SMC_SUPPORT="0"
	GUARD_START_EXIT="0"
	INSTALL_DAZUKO_ERR="0"
	INIT_SMC_PLUGIN="0"
	CREATE_QUAR="1"
	HAS_INF="0"
	ERR_PLUGIN_VERSION="1"
	ERR_PLUGIN_IN_AGENT_CONF="1"
	INSTALL_GUARD_TYPE="0"
	ADD_GNOME_PLUGIN_SUPPORT="0"
	NO_SCANNERLISTENADDRESS="0"
	FOUNDCONF="0"
	CONF_FILES_MOVED="0"
	MAILGATE_WAS_RUNNING="0"
	WEBGATE_WAS_RUNNING="0"
	CREATE_QUAR_SMC=""
	EXEC_AGENT=""
	WEBGATE_ADDLINK=""
	WEBGATE_AUTOSTART=""
	GUARD_ADDLINK=""
	GUARD_AUTOSTART=""
	GUARD_STARTNOW=""
	UPDATER_ADDLINK=""
	UPDATER_ADDCRONJOB=""
	UPDATER_CYCLE_SIG_EN=""
	UPDATER_CYCLE_PROD=""
	INSTALLED_PRODUCTS=""
	LIBGCC_S_LOCATION=""
	CPLIST=""
	FULLPRODUCTNAME=""
	CONFNAME=""
	SMCPLUGINPREFIX=""
	NO_UPDATE_LINK=""

# 	SMC agent defaults
	NO_VALUE="install_no_user_value_defined"
	AGENT_AGENTPORT=7030
	AGENT_SERVERIP="$NO_VALUE"
	AGENT_SERVERPORT=7000
	AGENT_EVENTMANAGERIP="$NO_VALUE"
	AGENT_EVENTMANAGERPORT=7010
	AGENT_UPDATEMANAGERIP="$NO_VALUE"
	AGENT_UPDATEMANAGERPORT=80
	AGENT_DISPLAYNAME="$NO_VALUE"
	AGENT_NETWORKNAME="$NO_VALUE"
	AGENT_GUID="$NO_VALUE"
	AGENT_PRODUCT_CONFIG="$NO_VALUE"
# 	SMC agent defaults END

	OS=`uname | env LANG=C LC_ALL=C LC_CTYPE=C tr '[:upper:]' '[:lower:]'`
	OSREL="`uname -r`"
	KERNELVERSION="${OS}-${OSREL}"

	if [ "${OS}" = "darwin" ]
	then
		if [ "$PRODUCT" = "savapi" ]
		then
			EXELIST="which id head sleep cat grep cp chmod ln uname ps sed gzip tar file"
		else
			EXELIST="which id head sleep cat grep cp chmod ln uname ps sed gzip tar file otool"
		fi
	else
		if [ "${PRODUCT}" = "smcagent" ]
		then
			EXELIST="which id head sleep cat grep cp chmod ln uname ps sed gzip tar file ldd strings"
		else
			EXELIST="which id head sleep cat grep cp chmod ln uname ps sed gzip tar file ldd"
		fi
	fi
	
	
	if [ $OS = "sunos" ]
	then
		EXEC_AGENT="env LD_LIBRARY_PATH="/usr/local/lib:/usr/lib/AntiVir/agent""
	fi
	
	case "${OS}" in
		linux)
			echo $OSREL | grep "^2\.6\." > /dev/null 2>&1
			if [ $? -eq 0 ]
			then
				OS="linux26"
			fi
			;;
	esac
	
	set_commands
	set_mailgate_acllist
	
	for param in "$@"
	do
		case $param in
			--inf=*)
				TEMP="`$ECHO $param | sed -e 's/^--inf=//'`"
				if [ -f "$TEMP" ]
				then
					. "$TEMP"
					HAS_INF=1
				fi
				;;

			--agent_port=*)
				AGENT_AGENTPORT="`$ECHO $param | sed -e 's/^--agent_port=//'`"
				;;

			--server_uri=http://*)
				IFACE="`$ECHO $param | sed -e 's/^--server_uri=http:\/\///'`"
				parse_iface_for_ip_port
				if [ "$PARSED_IP" != "?" ]
				then
					AGENT_SERVERIP=$PARSED_IP
				fi
				if [ "$PARSED_PORT" != "?" ]
				then
					AGENT_SERVERPORT=$PARSED_PORT
				fi
				;;

			--evmgr_uri=http://*)
				IFACE="`$ECHO $param | sed -e 's/^--evmgr_uri=http:\/\///'`"
				parse_iface_for_ip_port
				if [ "$PARSED_IP" != "?" ]
				then
					AGENT_EVENTMANAGERIP=$PARSED_IP
				fi
				if [ "$PARSED_PORT" != "?" ]
				then
					AGENT_EVENTMANAGERPORT=$PARSED_PORT
				fi
				;;

			--update_uri=http://*)
				IFACE="`$ECHO $param | sed -e 's/^--update_uri=http:\/\///'`"
				parse_iface_for_ip_port
				if [ "$PARSED_IP" != "?" ]
				then
					AGENT_UPDATEMANAGERIP=$PARSED_IP
				fi
				if [ "$PARSED_PORT" != "?" ]
				then
					AGENT_UPDATEMANAGERPORT=$PARSED_PORT
				fi
				;;

			--display_name=*)
				TEMP="`$ECHO $param | sed -e 's/^--display_name=//'`"
				AGENT_DISPLAYNAME="$TEMP"
				;;

			--network_name=*)
				TEMP="`$ECHO $param | sed -e 's/^--network_name=//'`"
				AGENT_NETWORKNAME="$TEMP"
				;;

			--guid=*)
				TEMP="`$ECHO $param | sed -e 's/^--guid=//'`"
				AGENT_GUID="$TEMP"
				;;

			--product_config=*)
				TEMP="`$ECHO $param | sed -e 's/^--product_config=//'`"
				AGENT_PRODUCT_CONFIG="$TEMP"
				;;
			--no-dazuko)
				INST_DAZUKO=n
				;;
		esac
	done
	
	ID="`id`"
	CUT=`${ECHO} $ID | sed -e s/\^uid=0\(//`
	if [ "$CUT" = "$ID" ]
	then
		CUT=`${ECHO} $ID | sed -e s/\euid=0\(//`
		if [ "$CUT" = "$ID" ]
		then
			$ECHO " "
			$ECHO "This script must be run as root."
			$ECHO " "
			error_message "error: script must be run as root"
			exit 1
		fi
	fi
	
	CLASSIFICATION=`sh script/getsysteminfo --classification`
	USE_CLASSIFICATION=""
	
	case $PRODUCT in
		savapi)
			INSTALL_NAME="savapi"
			UPDATE_CONF_NAME="savapi"
			AVDIR="$AVDIR_BASE/$INSTALL_NAME"

			UPD_PRODUCT="Scanner"
			CPLIST=""
			FULLPRODUCTNAME="Avira AntiVir Savapi (UNIX)"
			HASGUARD=0
			HASCMDSCANNER=0
			HASCOREBINARY=1
			CRON_NAME="Savapi"
			;;

		vsa)
			INSTALL_NAME="vsa"
			CONFNAME="avira-vsa-v3"
			AVDIR="$AVDIR_BASE/SAP-VSA-Adapter"

			UPD_PRODUCT="VSA"
			CPLIST=""
			FULLPRODUCTNAME="Avira AntiVir VSA (UNIX)"
			HASGUARD=0
			HASCMDSCANNER=0
			HASCOREBINARY=1
			CRON_NAME="VSA"
			;;

		webgate)
			INSTALL_NAME="webgate"
			UPDATE_CONF_NAME="$PRODUCT"
			AVDIR="$AVDIR_BASE/$INSTALL_NAME"

			UPD_PRODUCT="WebGate"
			CPLIST=""
			FULLPRODUCTNAME="Avira AntiVir WebGate (UNIX)"
			CONFNAME="avwebgate"
			HASGUARD=0
			HASCMDSCANNER=0
			SMCPLUGINPREFIX="uxwgt"
			HASCOREBINARY=1
			CONFIG_CORE=1
			CRON_NAME="Webgate"
			;;

		mailgate)
			INSTALL_NAME="mailgate"
			UPDATE_CONF_NAME="$PRODUCT"
			AVDIR="$AVDIR_BASE/$INSTALL_NAME"
	
			UPD_PRODUCT="MailGate"
			CPLIST=""
			FULLPRODUCTNAME="Avira MailGate (UNIX)"
			CONFNAME="avmailgate"
			HASGUARD=0
			HASCMDSCANNER=0
			SMCPLUGINPREFIX="uxmgt"
			HASCOREBINARY=1
			CONFIG_CORE=1
			CRON_NAME="MailGate"
			;;

		server)
			INSTALL_NAME="guard"
			UPDATE_CONF_NAME="guard"
	
			AVDIR="$AVDIR_BASE/$INSTALL_NAME"
	
			UPD_PRODUCT="Guard"
			CPLIST=""
			FULLPRODUCTNAME="Avira AntiVir Server (UNIX)"
			CONFNAME="avguard"
			HASGUARD=1
			HASCMDSCANNER=1
			SMCPLUGINPREFIX="uxsrv"
			HASCOREBINARY=1
			CONFIG_CORE=1
			CRON_NAME="Guard"
			FULLPRODUCTNAME_SCRIPT="Avira AntiVir Guard (UNIX)"
			PRODUCT_SCRIPT="guard"
			;;

		workstation)
			INSTALL_NAME="guard"
			UPDATE_CONF_NAME="guard"
			AVDIR="$AVDIR_BASE/$INSTALL_NAME"
	
			UPD_PRODUCT="Guard"
			CPLIST=""
			FULLPRODUCTNAME="Avira AntiVir Workstation (UNIX)"
			CONFNAME="avguard"
			HASGUARD=1
			HASCMDSCANNER=1
			SMCPLUGINPREFIX="uxwks"
			HASCOREBINARY=1
			CONFIG_CORE=1
			CRON_NAME="Guard"
			FULLPRODUCTNAME_SCRIPT="Avira AntiVir Guard (UNIX)"
			PRODUCT_SCRIPT="guard"
			;;

		smcagent)
			INSTALL_NAME="agent"
			UPDATE_CONF_NAME="agent"
			AVDIR="$AVDIR_BASE/$INSTALL_NAME"

			check_smc_parameters
			UPD_PRODUCT="Agent"
			CPLIST=""
			FULLPRODUCTNAME="Avira Management Console Agent (UNIX)"
			CONFNAME=""
			HASGUARD=0
			HASCMDSCANNER=0
			SMCPLUGINPREFIX="uxagt"
			HASCOREBINARY=0
			SYSTEMINFO=`sh script/getsysteminfo`
			CRON_NAME="Agent"
			;;

		ium)
			INSTALL_NAME="$PRODUCT"
			UPDATE_CONF_NAME="$PRODUCT"
			AVDIR="$AVDIR_BASE/$INSTALL_NAME"

			UPD_PRODUCT="AUM"
			FULLPRODUCTNAME="Avira Update Manager (UNIX)"
			CONFNAME=""
			HASGUARD=0
			HASCMDSCANNER=0
			SMCPLUGINPREFIX="uxium"
			HASCOREBINARY=0
			CRON_NAME="ium"
			;;
	esac

# 	check for several platform support
	if [ ${PRODUCT} = "savapi" ]
	then
		case $CLASSIFICATION in
			solaris_sparc_v8)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v8)
				CLASSIFICATION="solaris_sparc64_v8"
				;;
			solaris_sparc_v9)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v9)
				CLASSIFICATION="solaris_sparc64_v8"
				;;
			solaris_sparc_v10)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v10)
				CLASSIFICATION="solaris_sparc64_v8"
				;;
			macosx_x86_32)
				CLASSIFICATION="macosx_x86_64"
				;;
		esac

		if [ "$CLASSIFICATION" != "linux_glibc22" -a "$CLASSIFICATION" != "linux_glibc22_s390" -a \
		     "$CLASSIFICATION" != "linux_glibc24_x86_64" -a \
		     "$CLASSIFICATION" != "solaris_sparc" -a "$CLASSIFICATION" != "solaris_sparc64_v8" -a \
		     "$CLASSIFICATION" != "freebsd_v62" -a \
		     "$CLASSIFICATION" != "openbsd_v39" -a \
		     "$CLASSIFICATION" != "macosx_x86_32" -a "$CLASSIFICATION" != "macosx_x86_64" ]
		then
			$ECHO " "
			$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
			$ECHO " "
			error_message "error: not supported system platform"
			exit 1
		fi

	elif [ ${PRODUCT} = "vsa" ]
	then
		case $CLASSIFICATION in
			solaris_sparc_v8)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v8)
				CLASSIFICATION="solaris_sparc64_v8"
				;;
			solaris_sparc_v9)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v9)
				CLASSIFICATION="solaris_sparc64_v8"
				;;
			solaris_sparc_v10)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v10)
				CLASSIFICATION="solaris_sparc64_v8"
				;;
		esac

		if [ "$CLASSIFICATION" != "linux_glibc24_x86_64" -a \
		     "$CLASSIFICATION" != "solaris_sparc64_v8" ]
		then
			$ECHO " "
			$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
			$ECHO " "
			error_message "error: not supported system platform"
			exit 1
		fi

	elif [  "$PRODUCT" = "ium" ]
	then
		if [ "$CLASSIFICATION" != "linux_glibc22" -a \
		     "$CLASSIFICATION" != "linux_glibc24_x86_64" ]
		then
			$ECHO " "
			$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
			$ECHO " "
			error_message "error: not supported system platform"
			exit 1
		fi

# 		check for 32-bit support
		if [ "$CLASSIFICATION" = "linux_glibc24_x86_64" ]
		then
			HAS_32Bit=false
# 			check for 32-bit libaries
			if file /lib/* | grep 32 > /dev/null 2>&1
			then
				HAS_32Bit=true
				CLASSIFICATION="linux_glibc22"
			fi
		
			ls -l /lib/ld-linux.so.2 > /dev/null 2>&1
			ERR="$?"
			if [ $ERR -eq 0 ]
			then
				ls -l /lib/ld-linux.so.2 | grep lrwxrwxrwx > /dev/null 2>&1
				if [ "$ERR" -eq 0 -a -s "/emul/ia32-linux/lib/ld-linux.so.2" ]
				then
					HAS_32Bit=true
					CLASSIFICATION="linux_glibc22"
				fi
			fi
		
	# 		ask the user if the system supports 32-bit binaries
			if ! $HAS_32Bit
			then
				$ECHO " "
				check_yesno_input "Does your system support 32-bit applications? [n] " $BIT_SUPPORT
				if [ "$?" -eq "0" -o "$?" -eq "2" ]
				then
					$ECHO " "
					$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
					$ECHO "There are libraries missing to enable 32-bit support."
					$ECHO " "
					error_message "error: not supported system platform, libraries are missing for 32-bit support."
					exit 1
				else
					CLASSIFICATION="linux_glibc22"
				fi
			fi
		fi

	elif [  "$PRODUCT" = "server" -o "${PRODUCT}" = "workstation" ]
	then
		case $CLASSIFICATION in
			solaris_sparc_v8)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v8)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc_v9)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v9)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc_v10)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v10)
				CLASSIFICATION="solaris_sparc"
				;;
		esac

		if [ "$CLASSIFICATION" != "linux_glibc22" -a \
		     "$CLASSIFICATION" != "linux_glibc24_x86_64" -a \
		     "$CLASSIFICATION" != "solaris_sparc" ]
		then
			$ECHO " "
			$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
			$ECHO " "
			error_message "error: not supported system platform"
			exit 1
		fi

	else
		case $CLASSIFICATION in
			solaris_sparc_v8)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v8)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc_v9)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v9)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc_v10)
				CLASSIFICATION="solaris_sparc"
				;;
			solaris_sparc64_v10)
				CLASSIFICATION="solaris_sparc"
				;;
		esac

		if [ "$CLASSIFICATION" != "linux_glibc22" -a \
		     "$CLASSIFICATION" != "linux_glibc24_x86_64" -a \
		     "$CLASSIFICATION" != "solaris_sparc" ]
		then
			$ECHO " "
			$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
			$ECHO " "
			error_message "error: not supported system platform"
			exit 1
		fi

# 		check for 32-bit support
		if [ "$CLASSIFICATION" = "linux_glibc24_x86_64" ]
		then
			HAS_32Bit=false
# 			check for 32-bit libaries
			if file /lib/* | grep 32 > /dev/null 2>&1
			then
				HAS_32Bit=true
				CLASSIFICATION="linux_glibc22"
			fi
		
			ls -l /lib/ld-linux.so.2 > /dev/null 2>&1
			ERR="$?"
			if [ $ERR -eq 0 ]
			then
				ls -l /lib/ld-linux.so.2 | grep lrwxrwxrwx > /dev/null 2>&1
				if [ "$ERR" -eq 0 -a -s "/emul/ia32-linux/lib/ld-linux.so.2" ]
				then
					HAS_32Bit=true
					CLASSIFICATION="linux_glibc22"
				fi
			fi
		
	# 		ask the user if the system supports 32-bit binaries
			if ! $HAS_32Bit
			then
				$ECHO " "
				check_yesno_input "Does your system support 32-bit applications? [n] " $BIT_SUPPORT
				if [ "$?" -eq "0" -o "$?" -eq "2" ]
				then
					$ECHO " "
					$ECHO "It is not possible to install "$FULLPRODUCTNAME", because your system platform is not supported."
					$ECHO "There are libraries missing to enable 32-bit support."
					$ECHO " "
					error_message "error: not supported system platform, libraries are missing for 32-bit support."
					exit 1
				else
					CLASSIFICATION="linux_glibc22"
				fi
			fi
		fi
	fi

	check_copyfiles
	check_executables
	ldd_bin_check
	check_old_savapi_based_product
	
# 	load avinstall
	. script/sh.avinstall
	
	$ECHO " "
	$ECHO "Starting $FULLPRODUCTNAME $PRODUCTVERSION installation..."
	$ECHO " "
	$ECHO "Before installing this software, you must agree to the terms"
	$ECHO "of the license."
	$ECHO " "
	$ECHO "Use the arrow keys to scroll through the license. When you"
	$ECHO "are finished reading, press 'q' to exit the viewer."
	$ECHO " "
	$ECHO "Press <ENTER> to view the license."
	if [ $HAS_INF -eq 0 ]
	then
		read INPUT
	fi
	
	if [ $HAS_INF -ne 0 ]
	then
		PAGER="cat"
	else
		if [ -z "$PAGER" ]
		then
			PAGER="more"
		fi
	fi
	$PAGER LICENSE
	$ECHO " "
	
	check_yesno_input "Do you agree to the license terms? [n] " $LICENSE_AGREEMENT
	if [ "$?" -eq "0" -o "$?" -eq "2" ]
	then
		$ECHO "Installation aborted."
		exit 1
	fi
	
	$ECHO " "
	$ECHO " "
	
	if [ -d "$AVDIR" ]
	then
		$ECHO "previous installation of AntiVir found"
		$ECHO "(updating necessary components)"
		$ECHO " "
	fi
	
	create_antivir_group

	avinstall -T "$AVDIR_BASE" -u root -g "$PROGNAME" -m 755 > /dev/null 2>&1
	
	if [ -f "$AVDIR" ]
	then
		$ECHO -n "remove the script $AVDIR_BASE ... "
		rm $AVDIR
		if [ "$?" -eq 0 ]
		then
			$ECHO "done"
		else
			$ECHO "fail"
		fi
	fi
	
	avinstall -T "$AVDIR" -u root -g "$PROGNAME" -m 755 > /dev/null 2>&1
	avinstall -f -s install_list_$INSTALL_NAME -T "$AVDIR" -u root -g "$PROGNAME" -m 755

	GUARD_TYPE="AV_SRV_PROF AV_WKS_PERS AV_WKS_PROF"
	for ITEM in `$ECHO $GUARD_TYPE`
	do
		if [ -f "$ITEM" ]
		then
			NEWCHECK=`$ECHO $GUARD_TYPE | sed -e 's,'$ITEM',,'`
			for CHECK in `$ECHO $NEWCHECK`
			do
				if [ -f "$AVDIR/$CHECK" ]
				then
					case $CHECK in
						AV_SRV_PROF)
							INSTALLED_PRODUCT="Avira AntiVir Server (UNIX)"
							;;
	
						AV_WKS_PROF)
							INSTALLED_PRODUCT="Avira AntiVir Workstation (UNIX)"
							;;
	
						AV_WKS_PERS)
							INSTALLED_PRODUCT="Avira AntiVir Workstation Personal (UNIX)"
							;;
					esac
						
					$ECHO " "
					$ECHO "$INSTALLED_PRODUCT already installed. Please uninstall this product,"
					$ECHO "because it is not compatible with $FULLPRODUCTNAME"
					$ECHO " "
					$ECHO "sh uninstall --product=Guard"
					exit 3
				fi
			done
	
			DAZUKO_TYPE_2_INSTALL="$ITEM"
			INSTALL_GUARD_TYPE="1"
		fi
	done

	GUARD_TYPE="AV_SRV_PROF AV_WKS_PROF AV_WKS_PERS"
	for ITEM in `$ECHO $GUARD_TYPE`
	do
		if [ -f "$ITEM" ]
		then
			case $ITEM in
				AV_SRV_PROF)
					SMC_PLUGIN1="libuxsrv.so"
					SMC_PLUGIN2="libuxwks.so"
					INSTALLED_PRODUCT1="Avira AntiVir Server (UNIX)"
					INSTALLED_PRODUCT2="Avira AntiVir Workstation (UNIX)"
					;;
		
				AV_WKS_PROF)
					SMC_PLUGIN1="libuxwks.so"
					SMC_PLUGIN2="libuxsrv.so"
					INSTALLED_PRODUCT1="Avira AntiVir Workstation (UNIX)"
					INSTALLED_PRODUCT2="Avira AntiVir Server (UNIX)"
					;;
			esac

			if [ ! -f "$AVDIR_BASE/guard/$ITEM" -a ! -f "$AVDIR_BASE/$ITEM" -a -f "$AVDIR_BASE/agent/$SMC_PLUGIN1" ]
			then
				$ECHO " "
				$ECHO "Old $INSTALLED_PRODUCT1 (with smc/gui support) already installed."
				$ECHO "Please uninstall this product, because it is not compatible"
				$ECHO "with $FULLPRODUCTNAME"
				$ECHO " "
				$ECHO "sh uninstall --product=Guard"
				exit 4

			elif [ ! -f "$AVDIR_BASE/guard/$ITEM" -a ! -f "$AVDIR_BASE/$ITEM" -a -f "$AVDIR_BASE/agent/$SMC_PLUGIN2" ]
			then
				$ECHO " "
				$ECHO "Old $INSTALLED_PRODUCT1 (with smc/gui support) already installed."
				$ECHO "Please uninstall this product, because it is not compatible"
				$ECHO "with $FULLPRODUCTNAME"
				$ECHO " "
				$ECHO "sh uninstall --product=Guard"
				exit 4
			fi
		fi
	done

	if [ "$INSTALL_GUARD_TYPE" -eq 1 ]
	then
		avinstall -s $DAZUKO_TYPE_2_INSTALL -T "$AVDIR" -u root -g "$PROGNAME" -m 755
	fi

	if [ ! -f $AVDIR/LICENSE-$PRODUCT ]
	then
		avinstall -s LICENSE -T "$AVDIR" -t LICENSE-$PRODUCT -u root -g "$PROGNAME" -m 755
	fi

	if [ -d smcpkg -a $PRODUCT != "smcagent" ]
	then
		HASSMC="1"
		INSTALLSMC="1"
	fi

	if [ "${OS}" = "sunos" ]
	then
		avinstall -S script -s echo_sunos -T "$AVDIR" -u root -g "$PROGNAME" -m 755
		if [ $? -ne 0 ]
		then
			error_message "error: failed to copy script/echo_sunos to $AVDIR"
			exit 1
		fi
	fi
	
	if [ $HASCOREBINARY -eq 1 ]
	then
		$ECHO " "
		$ECHO "$STEP) installing AntiVir Core Components (Engine, Savapi and Avupdate)"
	
		avinstall -f -s uninstall -T "$AVDIR" -u root -g "$PROGNAME" -m 755
		if [ -f "uninstall_smcplugin.sh" ]
		then
			avinstall -f -s uninstall_smcplugin.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
		fi
		avinstall -f -S etc -s file_list -T "$AVDIR" -u root -g "$PROGNAME" -m 664
		avinstall -f -S etc -s dir_list -T "$AVDIR" -u root -g "$PROGNAME" -m 664
		avinstall -f -S etc -s run.inf -T "$AVDIR" -u root -g "$PROGNAME" -m 664
		avinstall -f -s README.uninstall -T "$AVDIR" -u root -g "$PROGNAME" -m 664
		avinstall -f -S script -s rcscript -T "$AVDIR" -u root -g "$PROGNAME" -m 755

		if [ -f "etc/savapi3.conf" ]
		then
			if [ ! -f "$AVDIR/savapi3.conf" ]
			then
				avinstall -f -S etc -s savapi3.conf -T $AVDIR -t savapi3.conf -u root -g "$PROGNAME" -m 644
			fi
			avinstall -f -S etc -s savapi3.conf -T $AVDIR -t savapi3.conf.default -u root -g "$PROGNAME" -m 644
		fi
		
		for item in `ls bin/$CLASSIFICATION | grep -v .bin | grep -v dazuko | grep -v guard | grep -v avscan | grep -v super |\
						grep -v mailgate | grep -v webgate | grep -v antivir_start | grep -v stats`
		do
			avinstall -f -S bin/$CLASSIFICATION -s "$item" -T "$AVDIR" -u root -g "$PROGNAME" -m 755
			if [ $? -ne 0 ]
			then
				$ECHO "This system is probably not supported by $FULLPRODUCTNAME."
				$ECHO " "
				exit 1
			fi
		done

		if [ -d "plugins/antispam" -a "${OS}" = "darwin" ]
		then
			avinstall -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755 > /dev/null 2>&1
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s "plg_antispam.dylib" -T "$AVDIR" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libcares.dylib -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libsqlite3.dylib -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libxml2.dylib -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libpcre.dylib -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libantispam.dylib -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libasata.dylib -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s global_words.db -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 644
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s settings.db -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 644

			for LINK_ANTISPAM_DEPENDENCIES in `ls ${AVDIR}/antispam | grep .dylib$`
			do
				if [ ! -f "/usr/lib/${LINK_ANTISPAM_DEPENDENCIES}" -a ! -h "/usr/lib/${LINK_ANTISPAM_DEPENDENCIES}" ]
				then
					$ECHO -n "linking $AVDIR/antispam/${LINK_ANTISPAM_DEPENDENCIES} to /usr/lib/${LINK_ANTISPAM_DEPENDENCIES} ... "
					rm -f /usr/lib/${LINK_ANTISPAM_DEPENDENCIES}
					ln -sf $AVDIR/antispam/${LINK_ANTISPAM_DEPENDENCIES} /usr/lib/${LINK_ANTISPAM_DEPENDENCIES}
					$ECHO "done"
				fi
			done
			

		elif [ -d "plugins/antispam" ]
		then
			avinstall -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755 > /dev/null 2>&1
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s "plg_antispam.so" -T "$AVDIR" -u root -g "$PROGNAME" -m 755

			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libcares.so -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libsqlite3.so -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libxml2.so -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libpcre.so -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libantispam.so -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s libasata.so -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 755
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s global_words.db -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 644
			avinstall -f -S plugins/antispam/$CLASSIFICATION -s settings.db -T "$AVDIR/antispam" -u root -g "$PROGNAME" -m 644

			if [ "$CLASSIFICATION" = "freebsd_v62" -o "$CLASSIFICATION" = "openbsd_v39" ]
			then
				for LINK_ANTISPAM_DEPENDENCIES in `ls ${AVDIR}/antispam | grep .so$`
				do
					if [ ! -f "/usr/lib/${LINK_ANTISPAM_DEPENDENCIES}" -a ! -h "/usr/lib/${LINK_ANTISPAM_DEPENDENCIES}" ]
					then
						$ECHO -n "linking $AVDIR/antispam/${LINK_ANTISPAM_DEPENDENCIES} to /usr/lib/${LINK_ANTISPAM_DEPENDENCIES} ... "
						rm -f /usr/lib/${LINK_ANTISPAM_DEPENDENCIES}
						ln -sf $AVDIR/antispam/${LINK_ANTISPAM_DEPENDENCIES} /usr/lib/${LINK_ANTISPAM_DEPENDENCIES}
						$ECHO "done"
					fi
				done
			fi
		fi

		if [ -d "src" -a "${PRODUCT}" = "savapi" ]
		then
			avinstall -T "$AVDIR/src" -u root -g "$PROGNAME" -m 755
			cp -rp src/* $AVDIR/src > /dev/null 2>&1
			chown -R root:antivir $AVDIR/src
		fi

		if [ -d "include" -a "${PRODUCT}" = "savapi" ]
		then
			avinstall -T "$AVDIR/include" -u root -g "$PROGNAME" -m 755
			avinstall -f -S include -s Doxyfile -T "$AVDIR/include" -u root -g "$PROGNAME" -m 644
			avinstall -f -S include -s Doxyfile-fops -T "$AVDIR/include" -u root -g "$PROGNAME" -m 644
			avinstall -f -S include -s asc_bin.h -T "$AVDIR/include" -u root -g "$PROGNAME" -m 644
			avinstall -f -S include -s fops.h -T "$AVDIR/include" -u root -g "$PROGNAME" -m 644
			avinstall -f -S include -s fopstypes.h -T "$AVDIR/include" -u root -g "$PROGNAME" -m 644
			avinstall -f -S include -s savapi3.h -T "$AVDIR/include" -u root -g "$PROGNAME" -m 644
			avinstall -f -S include -s stchar.h -T "$AVDIR/include" -u root -g "$PROGNAME" -m 644
		fi

		if [ -d "doc" -a "${PRODUCT}" = "savapi" ]
		then
			avinstall -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 755
			avinstall -f -S doc -s Avira_Engine_File_OPerationS.pdf -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 644
			avinstall -f -S doc -s SAVAPI-cmdline-params.pdf -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 644
			avinstall -f -S doc -s SAVAPI-conf-file.pdf -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 644
			avinstall -f -S doc -s SAVAPI-manual.pdf -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 644
			avinstall -f -S doc -s SAVAPI-protocol.pdf -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 644
			avinstall -f -S doc -s SAVAPI-api.pdf -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 644
			avinstall -f -S doc -s readme.txt -T "$AVDIR/doc" -u root -g "$PROGNAME" -m 644
		fi

		$ECHO -n "linking /usr/bin/avlinfo to $AVDIR/avlinfo ... " 
		rm -f /usr/bin/avlinfo
		ln -s $AVDIR/avlinfo /usr/bin/avlinfo
		$ECHO "done"

		avinstall -f -S bin/$CLASSIFICATION -s avupdate.bin -T "$AVDIR" -u root -g "$PROGNAME" -m 755

		if [ "$PRODUCT" =  "savapi" ]
		then
			for OEM_CONF in avupdate-engine.conf avupdate-scanner.conf
			do
				if [ ! -f $AVDIR/$OEM_CONF ]
				then
					avinstall -f -S etc/$CLASSIFICATION -s $OEM_CONF -T $AVDIR -u root -g "$PROGNAME" -m 644
				fi
				avinstall -f -S etc/$CLASSIFICATION -s $OEM_CONF -T $AVDIR -t $OEM_CONF.default -u root -g "$PROGNAME" -m 644
			done

		elif [ "$PRODUCT" =  "vsa" ]
		then
			for VSA_CONF in avupdate-engine.conf
			do
				if [ ! -f $AVDIR/$OEM_CONF ]
				then
					avinstall -f -S etc/$CLASSIFICATION -s $VSA_CONF -T $AVDIR -u root -g "$PROGNAME" -m 640
				fi
				avinstall -f -S etc/$CLASSIFICATION -s $VSA_CONF -T $AVDIR -t $VSA_CONF.default -u root -g "$PROGNAME" -m 640
			done

		else
			if [ ! -d "/etc/avira" ]
			then
				avinstall -T "/etc/avira" -u root -g "$PROGNAME" -m 775
			fi

			if [ ! -f /etc/avira/$UPDATENAME-$UPDATE_CONF_NAME.conf ]
			then
				avinstall -f -S etc -s $UPDATENAME.conf -T /etc/avira -t $UPDATENAME-$UPDATE_CONF_NAME.conf -u root -g "$PROGNAME" -m 640
				if [ "$PRODUCT" != "savapi" ]
				then
					patch_install_temp
				fi
			fi
			avinstall -f -S etc -s $UPDATENAME.conf -T /etc/avira -t $UPDATENAME-$UPDATE_CONF_NAME.conf.default -u root -g "$PROGNAME" -m 640
		fi
	
		avinstall -f -S doc -s avupdater.txt -T "$AVDIR" -u root -g "$PROGNAME" -m 644
	
		if [ "$PRODUCT" = "savapi" -o "$PRODUCT" = "vsa" ]
		then
			avinstall -f -S script -s update.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755
		else
			avinstall -f -S script -s $UPDATENAME.template -T "$AVDIR" -t $UPDATENAME-$UPDATE_CONF_NAME -u root -g "$PROGNAME" -m 755
		fi
		avinstall -f -S script -s savapi3_post.sh -T "$AVDIR" -u root -g "$PROGNAME" -m 755

		for VDF_NAME in $VDFNAME
		do
			avinstall -f -S vdf -s "$VDF_NAME" -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		done
	
		if [ -f hbedv_key ]
		then
			avinstall -f -s hbedv_key -T "$AVDIR" -u root -g "$PROGNAME" -m 644
		fi
	
		if [ -f AV_WKS_PERS ]
		then
			if [ -f "$AVDIR/avira_personal.key" ]
			then
				rm "$AVDIR/avira_personal.key"
			fi
			$ECHO -n "copying $AVDIR/hbedv_key to $AVDIR/avira_personal.key ... "
			cp "$AVDIR/hbedv_key" "$AVDIR/avira_personal.key"
			$ECHO "done"
		fi
	
		if [ "$VARIANT" = "AVDE" -a ! -f AV_WKS_PERS ]
		then
			INPUTERROR=1
			while [ $INPUTERROR -eq 1 ]
			do
				KEYDEFAULT=""
				for item in `ls | grep -i "\.key$"`
				do
					KEYDEFAULT="$item"
				done
				$ECHO " "
				$ECHO -n "Enter the path to your key file: [$KEYDEFAULT] "
				INPUT="$KEY_FILE"
				if [ -z "$INPUT" ]
				then
					if [ $HAS_INF -eq 0 ]
					then
						read INPUT
						if [ -z "$INPUT" ]
						then
							INPUT="$KEYDEFAULT"
						fi
					else
						INPUT="$KEYDEFAULT"
						$ECHO "$INPUT"
					fi
				else
					$ECHO "$INPUT"
				fi
	
				if [ -z "$INPUT" ]
				then
					INPUTERROR=0
				else
					if [ ! -f "$INPUT" ]
					then
						$ECHO "....... $INPUT  ......"
						$ECHO "$INPUT not found"
					else
						INPUTERROR=0
					fi
				fi
			done
	
			if [ -z "$INPUT" ]
			then
				$ECHO "no key file will be installed"

			elif [ "`dirname "$INPUT"`" = "$AVDIR" ]
			then
				$ECHO "key file already installed"
			else
				findnewkey "$AVDIR"
				$ECHO -n "copying $INPUT to $AVDIR/$NEWKEY ... "
				cp -f "$INPUT" "$AVDIR/$NEWKEY"
				chmod 644 "$AVDIR/$NEWKEY"
				chown root:$PROGNAME "$AVDIR/$NEWKEY"
				$ECHO "done"
			fi
		fi
	
		$ECHO " "
		$ECHO "installation of AntiVir Core Components (Engine, Savapi and Avupdate) complete"

		if [ "$PRODUCT" != "updateplugin" -a "$PRODUCT" != "savapi" -a "$PRODUCT" != "vsa" ]
		then
			STEP=`expr $STEP + 1`
			$ECHO " "
			$ECHO " "
			$ECHO "$STEP) Configuring updates"
			$ECHO "An internet updater is available with $FULLPRODUCTNAME"
			$ECHO "It will ensure that you always have the latest malware detection"
			$ECHO "patterns and engine updates. In order to trigger an update you"
			$ECHO "will need to run the command:"
			$ECHO " "
			$ECHO "     $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME"
			$ECHO " "
	
			install_avupdate
			$ECHO " "
			$ECHO "setup internet updater complete"
		fi
	fi

	if [ "$PRODUCT" = "server" -o "$PRODUCT" = "workstation" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) installing main program"
	
		install_guard
	fi
	
	if [ "$PRODUCT" = "webgate" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) installing main program"
	
		install_webgate
	fi
	
	if [ "$PRODUCT" = "mailgate" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) installing main program"
	
		install_mailgate
	fi
	
	if [ "$PRODUCT" = "updateplugin" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) installing AntiVir Internet Update Daemon"
	
		install_avupdate
	fi
	
	if [ "$PRODUCT" = "ium" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) installing Avira AUM"
	
		install_ium
	
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) Configuring updates"
	
		$ECHO "An internet updater is available with version $PRODUCTVERSION of "
		$ECHO "$FULLPRODUCTNAME. You can use it to get the latest build"
		$ECHO "update of the AUM whenever it is released."
		$ECHO "In order to trigger an update you will need to run the command:"
		$ECHO " "
		$ECHO "     $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=$UPD_PRODUCT"
		$ECHO " "
	
		install_avupdate
		$ECHO "setup internet updater complete"
	fi
	
	if [ "$PRODUCT" = "smcagent" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) installing Avira AMC Agent"
	
		install_smcagent
	fi

	if [ "$PRODUCT" = "vsa" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) installing Avira AntiVir VSA"
	
		install_sapvsa
	fi

	if [ $HASSMC -eq 1  -a ! -f "AV_WKS_PERS" ]
	then
		STEP=`expr $STEP + 1`
		$ECHO " "
		$ECHO " "
		$ECHO "$STEP) activate AMC support"
		$ECHO "If you are going to use Avira Management Console Agent (AMC)"
		$ECHO "to manage this software remotely you need this"
		$ECHO " "
		check_yesno_input "Would you like to activate AMC support? [y] " $SMC_INSTALL
		if [ "$?" -eq "1" -o "$?" -eq "2" ]
		then
			ACTIVATE_SMC_SUPPORT=1
			INIT_SMC_PLUGIN=1
		else
			if [ $PRODUCT != "ium" -a $PRODUCT != "smcagent" ]
			then
				$ECHO " "
				$ECHO "AMC will NOT be activated"
			fi
		fi
	fi
	
	if [ ! -z "$CONFNAME" ]
	then
		if [ "$ADD_GNOME_PLUGIN_SUPPORT" -eq 1 ]
		then
			cp /etc/avira/${CONFNAME}.conf /etc/avira/${CONFNAME}.conf.bak
			cat /etc/avira/${CONFNAME}.conf.bak | sed -e 's,\#\ Default\:\ ActiveLockFile\ NONE,ActiveLockFile\ \/var\/lock\/LCK..avguard,' | \
			sed -e 's,\#\ Default\:\ ExternalProgram\ NONE,ExternalProgram\ /\bin\/sh\ \/usr\/lib\/AntiVir\/guard\/popup\_message\.sh \[\%Sn\]\ \%p,' > /etc/avira/${CONFNAME}.conf
			rm /etc/avira/${CONFNAME}.conf.bak
		fi
	
		if [ "$ACTIVATE_SMC_SUPPORT" -eq 1 ]
		then
			cp /etc/avira/${CONFNAME}.conf /etc/avira/${CONFNAME}.conf.bak
			cat /etc/avira/$CONFNAME.conf.bak | sed -e 's,\#\ Default\: GuiSupport\ no,GuiSupport\ yes,' \
							        -e 's,\#\ GuiSupport.*NO,GuiSupport\ yes,' \
							        -e 's,\#.*GuiSupport\ no,GuiSupport\ yes,' \
							        -e 's/^GuiSupport.*/GuiSupport\ yes/g' > /etc/avira/$CONFNAME.conf
			rm /etc/avira/${CONFNAME}.conf.bak

			if [ "$PRODUCT" = "server" -o "$PRODUCT" = "workstation" ]
			then
				cp /etc/avira/avscan.conf /etc/avira/avscan.conf.bak
				cat /etc/avira/avscan.conf.bak | sed -e 's,\#\ Default\: GuiSupport\ no,GuiSupport\ yes,' -e 's,\#\ GuiSupport.*NO,GuiSupport\ yes,' -e 's/^GuiSupport.*/GuiSupport\ yes/g' > /etc/avira/avscan.conf
				rm /etc/avira/avscan.conf.bak
			fi
		fi

		if [ "$ACTIVE_DAZUKO_LIB" = "libdazuko2.so" -o "$ACTIVE_DAZUKO_LIB" = "libdazukoSolaris9.so" -o "$ACTIVE_DAZUKO_LIB" = "libdazukoSolaris10.so" ]
		then
			cp /etc/avira/${CONFNAME}.conf /etc/avira/${CONFNAME}.conf.bak
			cat /etc/avira/$CONFNAME.conf.bak | sed -e 's,\#\ IncludePath\ \/home,IncludePath\ \/home,' > /etc/avira/$CONFNAME.conf
			rm /etc/avira/${CONFNAME}.conf.bak
		fi
	fi
	
	if [ $HASSMC -eq 1 ]
	then
		install_smcplugin
	fi
	
	if [ $HASGUARD -eq 1 ]
	then
		if [ -x "$AVDIR_BASE/avguard.bin" -a ! -f "$AVDIR_BASE/avguard.bin.obsolete" ]
		then
			/bin/sh $AVDIR/start_guard_upgrade.sh
		else
			$ECHO " "
			$ECHO " "
			check_yesno_input "Would you like to start Avira Guard now? [y] " $GUARD_STARTNOW
			if [ "$?" -eq "1" -o "$?" -eq "2" ]
			then
				$AVDIR/$GUARDNAME start
				GUARD_START_EXIT="$?"
				if [ "$GUARD_START_EXIT" -eq "0" -a "$INIT_SMC_PLUGIN" -eq "1" ]
				then
					INIT_SMC_PLUGIN="1"
				else
					INIT_SMC_PLUGIN="0"
				fi
			fi
		fi
	fi

	if [ "${PRODUCT}" = "mailgate" ]
	then
		if [ -x "$AVDIR_BASE/avmailgate.bin" -a ! -f "$AVDIR_BASE/avmailgate.bin.obsolete" ]
		then
			/bin/sh $AVDIR/start_mailgate_upgrade.sh --deploy-upgrade ${NO_UPDATE_LINK}
			CONF_FILES_MOVED="1"
		fi

		if [ "${MAILGATE_WAS_RUNNING}" -eq "1" ]
		then
			${ECHO} ""
			${AVDIR}/avmailgate start
		fi
	fi

	if [ "${PRODUCT}" = "webgate" ]
	then
		if [ -x "$AVDIR_BASE/avwebgate.bin" -a ! -f "$AVDIR_BASE/avwebgate.bin.obsolete" ]
		then
			/bin/sh $AVDIR/start_webgate_upgrade.sh --deploy-upgrade ${NO_UPDATE_LINK}
			CONF_FILES_MOVED="1"
		fi

		if [ "${WEBGATE_WAS_RUNNING}" -eq "1" ]
		then
			${ECHO} ""
			${AVDIR}/avwebgate start
		fi
	fi

	if [ "$HASSMC" -eq 1 -a "$INIT_SMC_PLUGIN" -eq "1" ]
	then
		if [ -x "$AVDIR_BASE/agent/$SMCAGENTNAME" -a -f "$AVDIR/agent/$LIBPLUGINDST" -a ! -f $AVDIR/AV_WKS_PERS ]
		then
			$ECHO -n "registering AMC plug-in ... "
			$EXEC_AGENT $AVDIR_BASE/agent/$SMCAGENTNAME --install-plugin "$SMCPLUGINPREFIX" "$AVDIR/agent/$LIBPLUGINDST" > /dev/null 2>&1
			if [ $? -eq 0 ]
			then
				$ECHO "done"
			else
				$ECHO "fail"
			fi
		fi
	fi

	if [ "$HASSMC" -eq 1 -a "$INIT_SMC_PLUGIN" -eq "0" ]
	then
		$ECHO " "
		$ECHO "INFO: Your AMC plug-in was not registered."
		$ECHO "You can register the AMC plug-in with the following command:"
		$ECHO "$AVDIR_BASE/agent/$SMCAGENTNAME --install-plugin $SMCPLUGINPREFIX $AVDIR/agent/$LIBPLUGINDST"
	fi
	
	$ECHO " "
	$ECHO " "
	$ECHO "Installation of the following features complete:"
	if [ "$PRODUCT" != "smcagent" -a "$PRODUCT" != "ium" ]
	then
		if [ "$PRODUCT" != "updateplugin" ]
		then
			$ECHO -n "     AntiVir Core Components (Engine, Savapi and Avupdate)"
			$ECHO " "
		fi
		if [ -f "$AVDIR/$UPDATENAME-$UPDATE_CONF_NAME" ]
		then
			$ECHO -n "     Avira Internet Updater"
			$ECHO " "
		fi
	fi
	if [ $HASGUARD -eq 1 ]
	then
		$ECHO  "    Avira Guard"
	fi
	if [ "$PRODUCT" = "webgate" ]
	then
		$ECHO "     Avira WebGate"
	fi
	if [ "$PRODUCT" = "mailgate" ]
	then
		$ECHO "     Avira MailGate"
	fi
	if [ "$PRODUCT" = "savapisdk" ]
	then
		$ECHO "     AntiVir SAVAPI SDK"
	fi
	if [ "$PRODUCT" = "smcagent" ]
	then
		$ECHO "     Avira AMC Agent"

# 		create a mark, that the product was installed in the new structure
		touch $AVDIR/UPGRADE_COMPLETE
	fi
	if [ "$PRODUCT" = "ium" ]
	then
		$ECHO "     Avira Update Manager"
		if [ -f "$AVDIR/$UPDATENAME-$UPDATE_CONF_NAME" ]
		then
			$ECHO -n "     Avira Update Manager"
			$ECHO " "
		fi

# 		create a mark, that the product was installed in the new structure
		touch $AVDIR/UPGRADE_COMPLETE
	fi
	if [ $INSTALLSMC -eq 1 ]
	then
		$ECHO "     AMC plugin"
	fi
	
	if [ "$PRODUCT" = "mailgate" ]
	then
		if [ "$CONF_FILES_MOVED" -eq "1" ]
		then
		$ECHO " "
		$ECHO " "
		$ECHO "************************************************************"
		$ECHO " NOTICE:  There was a pre-installed MailGate installed."
		$ECHO "          The files still remains in /usr/lib/AntiVir and"
		$ECHO "          can be used as fallback if there are any problems"
		$ECHO "          with the new installation."
		$ECHO "************************************************************"
		fi
		$ECHO " "
		$ECHO " "
		$ECHO "***********************************************************"
		$ECHO "NOTICE: Since version 3.0.0 a new scanner backend is used."
		$ECHO "        Old scanner specific configuration options that are"
		$ECHO "        not known to MailGate must be moved from /etc/avira/avmailgate.conf"
		$ECHO "        to the scanner specific configuration file /etc/avmailgate-scanner.conf."
		$ECHO " "
		$ECHO "Configuration files:"
		$ECHO "        /etc/avira/avmailgate.conf             (Avira MailGate main config)"
		$ECHO "        /etc/avira/avmailgate-scanner.conf     (Avira MailGate scanners config)"
		$ECHO "        /etc/avira/avmailgate.acl              (Avira MailGate access list)"
		$ECHO "        /etc/avira/avmailgate.ignore           (Avira MailGate ignore list)"
		$ECHO "        /etc/avira/avmailgate.scan             (Avira MailGate scan list)"
		$ECHO "        /etc/avira/avmailgate.warn             (Avira MailGate warn list)"
		$ECHO "        /etc/avira/asmailgate.except           (Avira MailGate spamfilter config)"
		$ECHO "        /etc/avira/avupdate-mailgate.conf      (Avira Avupdate options)"
		if [ $FOUNDCONF -eq 1 ]
		then
		$ECHO " "
		$ECHO "        The new avmailgate.conf was installed to /etc/avira/avmailgate.conf.default,"
		$ECHO "        because there was already a config file available."
		fi
		if [ $NO_SCANNERLISTENADDRESS -eq 1 ]
		then
		$ECHO " "
		$ECHO "        In your /etc/avira/avmailgate.conf was no ScannerListenAddress found."
		$ECHO "        Please look in /etc/avira/avmailgate.conf.default, how to implement this"
		$ECHO "        necessary feature in your current configuration file."
		fi
		$ECHO "***********************************************************"
	
		if [ -f "/etc/avguard.conf" -o -f "/etc/avira/avguard.conf" ]
		then
		$ECHO " "
		$ECHO " "
		$ECHO "************************************************************"
		$ECHO " WARNING: Avira Guard detected. Make sure the Avira MailGate SpoolDir"
		$ECHO "          and TemporaryDir are configured as ExcludePath's"
		$ECHO "          in /etc/avguard.conf. Otherwise Guard will"
		$ECHO "          prevent Avira MailGate from detecting alerts."
		$ECHO "************************************************************"
		fi

# 		create a mark, that the product was installed in the new structure
		touch $AVDIR/UPGRADE_COMPLETE
	fi
	
	if [ "$PRODUCT" = "webgate" ]
	then
		if [ "$CONF_FILES_MOVED" -eq "1" ]
		then
		$ECHO " "
		$ECHO " "
		$ECHO "************************************************************"
		$ECHO " NOTICE:  There was a pre-installed WebGate installed."
		$ECHO "          The files still remains in /usr/lib/AntiVir and"
		$ECHO "          can be used as fallback if there are any problems"
		$ECHO "          with the new installation."
		$ECHO "************************************************************"
		fi
		$ECHO " "
		$ECHO " "
		$ECHO "***********************************************************"
		$ECHO "Configuration files:"
		$ECHO "        /etc/avira/avwebgate.conf            (Avira WebGate main config)"
		$ECHO "        /etc/avira/avwebgate-scanner.conf    (Avira WebGate scanner config)"
		$ECHO "        /etc/avira/avupdate-webgate.conf     (Avira Avupdate options)"
		if [ $FOUNDCONF -eq 1 ]
		then
		$ECHO " "
		$ECHO "        The new avwebgate.conf was installed to /etc/avira/avwebgate.conf.default,"
		$ECHO "        because there was already a config file available."
		fi
		if [ $NO_SCANNERLISTENADDRESS -eq 1 ]
		then
		$ECHO " "
		$ECHO "        In your /etc/avira/avwebgate.conf was no ScannerListenAddress found."
		$ECHO "        Please look in /etc/avira/avwebgate.conf.default, how to implement this"
		$ECHO "        necessary feature in your current configuration file."
		fi
		$ECHO "***********************************************************"
	
		if [ -f "/etc/avguard.conf" -o -f "/etc/avira/avguard.conf" ]
		then
		$ECHO " "
		$ECHO " "
		$ECHO "************************************************************"
		$ECHO " WARNING: Avira Guard detected. Make sure the WebGate"
		$ECHO "          TemporaryDir is configured as an ExcludePath in"
		$ECHO "          /etc/avguard.conf. Otherwise Guard will prevent"
		$ECHO "          WebGate from detecting alerts."
		$ECHO "************************************************************"
		fi

# 		create a mark, that the product was installed in the new structure
		touch $AVDIR/UPGRADE_COMPLETE
	fi
	
	if [ "$PRODUCT" = "savapi" ]
	then
		$ECHO " "
		$ECHO " "
		$ECHO "***********************************************************"
		$ECHO "Configuration files:"
		$ECHO "        /usr/lib/AntiVir/savapi/savapi3.conf               (Avira Savapi3 options )"
		$ECHO "        /usr/lib/AntiVir/savapi/avupdate-engine.conf       (Avira Avupdate options )"
		$ECHO "        /usr/lib/AntiVir/savapi/avupdate-scanner.conf      (Avira Avupdate options )"
		$ECHO "***********************************************************"
	fi

	if [ "$PRODUCT" = "ium" ]
	then
		$ECHO " "
		$ECHO " "
		$ECHO "***********************************************************"
		$ECHO "Configuration files:"
		$ECHO "        /etc/avira/ium.conf              (Avira AUM main config)"
		$ECHO "***********************************************************"
	fi
	
	if [ "$PRODUCT" = "server" -o "$PRODUCT" = "workstation" ]
	then
		$ECHO " "
		$ECHO " "
		$ECHO "***********************************************************"
		$ECHO "Configuration files:"
		$ECHO "        /etc/avira/avguard.conf              (Avira Guard main config)"
		$ECHO "        /etc/avira/avscan.conf               (Avira Guard avscan config)"
		$ECHO "        /etc/avira/avguard-scanner.conf      (Avira Guard scanner config)"
		$ECHO "        /etc/avira/avupdate-guard.conf       (Avira Avupdate options)"
		if [ $FOUNDCONF -eq 1 ]
		then
		$ECHO " "
		$ECHO "        The new avguard.conf was installed to /etc/avira/avguard.conf.default,"
		$ECHO "        because there was already a config file available."
		fi
		if [ $NO_SCANNERLISTENADDRESS -eq 1 ]
		then
		$ECHO " "
		$ECHO "        In your /etc/avguard.conf was no ScannerListenAddress found."
		$ECHO "        Please look in /etc/avira/avguard.conf.default, how to implement this"
		$ECHO "        necessary feature in your current configuration file."
		fi
		$ECHO "***********************************************************"
		if [ -f "/etc/avguard.conf" ]
		then
		$ECHO " "
		$ECHO " "
		$ECHO "************************************************************"
		$ECHO " INFO:    /etc/avguard.conf is no longer used. The new"
		$ECHO "          Savapi-based-guard uses /etc/avira/avguard.conf"
		$ECHO "************************************************************"
		fi

# 		create a mark, that the product was installed in the new structure
		touch $AVDIR/UPGRADE_COMPLETE
	fi
	
	if [ $CLASSIFICATION = "solaris_sparc" -a ! -f "/usr/local/lib/libgcc_s.so.1" -a ! -f "$AVDIR/libgcc_s.so.1" ]
	then
		$ECHO " "
		$ECHO " "
		$ECHO "************************************************************"
		$ECHO " WARNING: No libgcc_s.so.1 found in $AVDIR and"
		$ECHO "          /usr/local/lib. This lib is necessary to run"
		$ECHO "          Savapi3 on your system. Please download this lib"
		$ECHO "          from www.sunfreeware.com:"
		$ECHO "          ftp://ftp.sunfreeware.com/pub/freeware/sparc/8/libgcc-3.4.6-sol8-sparc-local.gz"
		$ECHO "          ftp://ftp.sunfreeware.com/pub/freeware/sparc/9/libgcc-3.4.6-sol9-sparc-local.gz"
		$ECHO "          ftp://ftp.sunfreeware.com/pub/freeware/sparc/10/libgcc-3.4.6-sol10-sparc-local.gz"
		$ECHO "************************************************************"
	fi
	
	if [ -f "/etc/prelink.conf" ]
	then
		$ECHO " "
		$ECHO "************************************************************"
		$ECHO "NOTICE: This system has a prelinker. Prelinking the"
		$ECHO "        product binaries will not work correctly. Either"
		$ECHO "        disable prelinking or add $AVDIR as an"
		$ECHO "        excluded prelink path."
		$ECHO " "
		$ECHO "        For example, add '-b $AVDIR'"
		$ECHO "        to /etc/prelink.conf"
		$ECHO "************************************************************"
		$ECHO " "
	fi
	
	$ECHO " "
	
	if [ "$VARIANT" = "AVDE" -a "${PRODUCT}" != "smcagent" ]
	then
		if [ -z "`ls $AVDIR | grep -i \.key$`" ]
		then
		$ECHO " "
		$ECHO "Please copy your license key file in $AVDIR before"
		$ECHO "running the software. Without a valid license, $FULLPRODUCTNAME"
		$ECHO "will not start."
		fi
	fi
	
	if [ $HASCOREBINARY -eq 1 -a "$PRODUCT" != "savapi" ]
	then
		$ECHO " "
		$ECHO "Note: It is highly recommended that you perform an update now to"
		$ECHO "      ensure up-to-date protection. This can be done by running:"
		$ECHO " "
		$ECHO "      $AVDIR/$UPDATENAME-$UPDATE_CONF_NAME --product=$UPD_PRODUCT"
	fi
	
	$ECHO " "
	$ECHO "Be sure to read the manual file for additional information."
	$ECHO "Thank you for your interest in $FULLPRODUCTNAME."
	$ECHO " "
	
	if [ "$PRODUCT" = "server" -o "$PRODUCT" = "workstation" ]
	then
		if [ "$GUARD_START_EXIT" -ne 0 -a "$INSTALL_DAZUKO_ERR" -ne 0 ]
		then
			exit $INSTALL_DAZUKO_ERR
		else
			exit $GUARD_START_EXIT
		fi
	fi

#  