#!/bin/sh
#
# AMC agent install script
#
# Copyright (c) 2012 Avira Operations GmbH & Co. KG and its Licensors
#


# set some default values
OS=`uname | env LANG=C LC_ALL=C LC_CTYPE=C tr '[:upper:]' '[:lower:]'`
OSREL="`uname -r`"
AVDIR_BASE="/opt/avira"
AVGAURDDIR_BASE="/Applications/Avira.app/Contents"
ETCDIR_BASE="/opt/avira/etc"
EXELIST="which id head sleep cat grep cp chmod ln uname ps sed gzip tar file"
KERNELVERSION="${OS}-${OSREL}"
DEFAULT_GROUP="antivir"
DEFAULT_USER="root"
NOBODY_GROUP="nobody"
NOBODY_USER="nobody"
ECHO="f_echo_me"
STEP="0"
SILENCE="0"
CHECK="0"
HAS_INF="0"
SHUTDOWN_TIMEOUT="10"
INF_FILE=""
CUSTOM_MODULE_LIST=""
AGENT_PID=""
DO_SOMETHING=""


# set some smc agent default values
AGENT_AGENTPORT=7030
AGENT_SERVERIP=""
AGENT_SERVERPORT=7000
AGENT_EVENTMANAGERIP=""
AGENT_EVENTMANAGERPORT=7010
AGENT_UPDATEMANAGERIP=""
AGENT_UPDATEMANAGERPORT=80
AGENT_DISPLAYNAME=""
AGENT_NETWORKNAME=""
AGENT_GUID=""
AGENT_PRODUCT_CONFIG=""


f_echo_sun()
{
	# this script comes from the man page of echo(1) on Solaris 9
	
	if [ "X${1}" = "X-n" ]
	then
		shift
		printf "%s" "${*}"
	else
		printf "%s\n" "${*}"
	fi
}


f_echo_me()
{
	if [ "${SILENCE}" -eq "0" ]
	then
		if [ "${OS}" = "sunos" -o "${OS}" = "darwin" ]
		then
			f_echo_sun ${*}
		else
			if [ "X$1" = "X-n" ]
			then
				shift
				echo -n "${*}"
			else
				echo "${*}"
			fi
		fi
	fi
}


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


f_answer_me()
{
        INPUT="$2"
        INPUTRC=0
	if [ ! -z "${INPUT}" ]
	then
		f_echo_me -n "${1}"
		f_echo_me "${INPUT}"
		case ${INPUT} in
			y|Y|yes|Yes|YEs|YES|yEs|yES|1)
				return 1
				;;

			n|N|no|NO|nO|No|0)
				return 0
				;;
		esac
	else
        	while [ ${INPUTRC} -eq 0 ]
		do
                	f_echo_me -n "${1}"
                	read INPUT
                	case ${INPUT} in
				y|Y|yes|Yes|YEs|YES|yEs|yES|1)
					INPUTRC=1
					return 1
					;;

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

				"")
					INPUTRC=1
					return 2
					;;

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


f_display_version()
{
	f_echo_me "product:                  Avira AMC Agent Install for MacOS"
	f_echo_me "product version:          1.0.0"
}


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

	CHECK_SMC_PARAMETER_ERROR=0

	if [ -z "${AGENT_AGENTPORT}" ]
	then
		f_echo_me ""
		f_echo_me "missing argument: --agent_port=PORT"
		f_echo_me ""
		f_echo_me "See doc/INSTALL for more information."
		f_error_message "error: missing ---agent_port argument"
		CHECK_SMC_PARAMETER_ERROR=1
	fi

	if [ -z "${AGENT_SERVERIP}" ]
	then
		f_echo_me ""
		f_echo_me "missing argument: --server_uri=http://HOST[:PORT]"
		f_echo_me ""
		f_echo_me "See doc/INSTALL for more information."
		f_error_message "error: missing --server_uri argument"
		CHECK_SMC_PARAMETER_ERROR=1
	fi

	if [ -z "${AGENT_DISPLAYNAME}" ]
	then
		f_echo_me ""
		f_echo_me "missing argument: --display_name=<AMC display name>"
		f_echo_me ""
		f_echo_me "See doc/INSTALL for more information."
		f_error_message "error: missing --display_name argument"
		CHECK_SMC_PARAMETER_ERROR=1
	fi

	if [ -z "${AGENT_UPDATEMANAGERIP}" ]
	then
		f_echo_me ""
		f_echo_me "missing argument: --update_uri=http://HOST[:PORT]"
		f_echo_me ""
		f_echo_me "See doc/INSTALL for more information."
		f_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 [ -z "${AGENT_EVENTMANAGERIP}" ]
	then
		AGENT_EVENTMANAGERIP="${AGENT_SERVERIP}"
	fi

	f_check_ip_exit ${AGENT_SERVERIP}
	f_check_ip_exit ${AGENT_EVENTMANAGERIP}
	f_check_ip_exit `echo ${AGENT_UPDATEMANAGERIP}`
}


f_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
		f_echo_me " "
		f_echo_me "invalid address: ${1}"
		f_error_message "error: invalid address ${1}"
		exit 1
	fi
}


f_switch_to_package_root_dir()
{
	echo ${0} | grep "^/" > /dev/null 2>&1

	if [ "${?}" -eq "0" ]
	then
		CHECKROOTDIR=${0}
	else
		CHECKROOTDIR=`pwd`/${0}
	fi
	
	ROOTDIR=`dirname ${CHECKROOTDIR} 2> /dev/null`
	
	if [ ! -z "${ROOTDIR}" ]
	then
		cd "${ROOTDIR}"
	fi
}


f_parse_iface_for_ip_port()
{
	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
}


f_root_check()
{
	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
			f_echo_me " "
			f_echo_me "This script must be run as ${DEFAULT_USER}."
			f_echo_me " "
			exit 0
		fi
	fi
}

f_set_commands()
{
	case "${OS}" in
		darwin)
			GROUPADD="dscl"
			;;
	esac
}


f_check_for_systeminfo()
{
	if [ ! -f "script/getsysteminfo" ]
	then
		f_echo_me "Installation aborted."
		f_echo_me "The script script/getsysteminfo is not available in this package."
		f_error_message "The script script/getsysteminfo is not available in this package."
		exit 1
	fi

	CLASSIFICATION=`sh script/getsysteminfo --classification`
}


f_set_product_variables()
{
	case ${PRODUCT} in
		smcagent)
			INSTALL_SUBDIR="agent"
			AVDIR="${AVDIR_BASE}/${INSTALL_SUBDIR}"
			ETCDIR="${ETCDIR_BASE}"
			FULLPRODUCTNAME="Avira Management Console Agent (MacOS)"

			SUPPORTED_PLATFORMS="macosx_x86_64"
			MODULE_LIST="core smcagent"
			;;

		*)
			f_echo_me "Invalid product specified: ${PRODUCT}"
			f_error_message "Invalid product specified: ${PRODUCT}"
			exit 1
			;;
	esac
}


f_check_platform_support()
{
	if [ "${CLASSIFICATION}" = "macosx_x86_32" -o "${CLASSIFICATION}" = "macosx_x86_64" ]
	then
		CLASSIFICATION="macosx_x86_64"
	fi

	echo "${SUPPORTED_PLATFORMS}" | grep ${CLASSIFICATION} > /dev/null 2>&1
	if [ "${?}" -ne "0" ]
	then
		f_echo_me ""
		f_echo_me "Installation aborted."
		f_echo_me "It is not possible to install "${FULLPRODUCTNAME}", because your system platform is not supported."
		f_error_message "error: It is not possible to install "${FULLPRODUCTNAME}", because your system platform is not supported."
		exit 1
	fi
}


f_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
		f_echo_me ""
		f_echo_me "Installation aborted."
		f_echo_me "Not all the required tools were found. Please install"
		f_echo_me "the following tools:"
		for EXEITEM in ${MISSING_EXELIST}
		do
			f_echo_me "    ${EXEITEM}"
			f_error_message "error: missing required tool $EXEITEM"
		done
		exit 1
	fi
}


f_create_antivir_group()
{
	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

	$GROUPADD . create /groups/${DEFAULT_GROUP} > /dev/null 2>&1
	$GROUPADD . create /groups/${DEFAULT_GROUP} name ${DEFAULT_GROUP} > /dev/null 2>&1
	$GROUPADD . create /groups/${DEFAULT_GROUP} passwd "*" > /dev/null 2>&1
	$GROUPADD . create /groups/${DEFAULT_GROUP} gid ${GID} > /dev/null 2>&1
}


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

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

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

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


f_install_core()
{
# 	- this function creates the ${AVDIR_BASE}, ${AVDIR} and "${ETCDIR}" main directories
# 	- also copies the *.key to ${AVDIR}

	f_echo_me ""
	f_echo_me "Starting ${FULLPRODUCTNAME} ${PRODUCTVERSION} installation..."
	f_echo_me ""
	f_echo_me "Before installing this software, you must agree to the terms"
	f_echo_me "of the license."
	f_echo_me ""
	f_echo_me "Use the arrow keys to scroll through the license. When you"
	f_echo_me "are finished reading, press 'q' to exit the viewer."
	f_echo_me ""
	f_echo_me "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} ./avira/agent/LICENSE-smcagent
	f_echo_me " "
	
	f_answer_me "Do you agree to the license terms? [n] " ${LICENSE_AGREEMENT}
	if [ "${?}" -eq "0" -o "${?}" -eq "2" ]
	then
		exit 1
	fi

	f_create_antivir_group

	if [ ! -d "/opt" ]
	then
		mkdir /opt > /dev/null 2>&1
	fi

	if [ -d "${AVDIR_BASE}" -a -d "${AVDIR}" ]
	then
		f_echo_me ""
		f_echo_me "INFO: previous installation of ${FULLPRODUCTNAME} found."
	else
		avinstall -T "${AVDIR_BASE}" -u "${DEFAULT_USER}" -g "${DEFAULT_GROUP}" -m 755 > /dev/null 2>&1
		avinstall -T "${AVDIR}" -u "${DEFAULT_USER}" -g "${DEFAULT_GROUP}" -m 755 > /dev/null 2>&1
	fi

	if [ ! -d "${ETCDIR_BASE}" -o ! -d "${ETCDIR}" ]
	then
		avinstall -T "${ETCDIR_BASE}" -u "${DEFAULT_USER}" -g "${DEFAULT_GROUP}" -m 755 > /dev/null 2>&1
		avinstall -T "${ETCDIR}" -u "${DEFAULT_USER}" -g "${DEFAULT_GROUP}" -m 755 > /dev/null 2>&1
	fi
}


f_disable_avira_launchd_jobs()
{
# 	unload and remove the guard plist launchd files
	LAUNCHDDIR="/Library/LaunchAgents"
	PLIST="com.avira.antivirus.update.default \
	       com.avira.antivirus.odscan.default"
	
	for PLIST_ITEM in ${PLIST}
	do
# 		check for the user which is currently logged on on the gui and unload those jobs
		LOGGED_ON_USERS=$(stat -f%Su /dev/console)

# 		check if the PLIST_ITEM does exist and load it
		if [ -f "${LAUNCHDDIR}/${PLIST_ITEM}.plist" ]
		then
			sudo su - ${LOGGED_ON_USERS} -c 'launchctl unload '${LAUNCHDDIR}'/'${PLIST_ITEM}'.plist' > /dev/null 2>&1
			rm ${LAUNCHDDIR}/${PLIST_ITEM}.plist > /dev/null 2>&1
		fi
	done
}


f_disable_agent_launchd_job()
{
# 	load available agent plist launchd files
	LAUNCHDDIR="/Library/LaunchDaemons"
	PLIST="com.avira.amc.agent.plist"

	for PLIST_ITEM in ${PLIST}
	do
	# 	check if the PLIST_ITEM does exist and load it
		if [ -f "${LAUNCHDDIR}/${PLIST_ITEM}" ]
		then
			if launchctl list | grep `echo ${PLIST_ITEM} | sed -e 's,\.plist,,' ` > /dev/null 2>&1
			then
				launchctl unload ${LAUNCHDDIR}/${PLIST_ITEM} > /dev/null 2>&1
			fi
		fi
	done
}


f_enable_agent_launchd_job()
{
# 	load available agent plist launchd files
	LAUNCHDDIR="/Library/LaunchDaemons"
	PLIST="com.avira.amc.agent.plist"

	cp ${AVDIR}/${PLIST}.default ${LAUNCHDDIR}/${PLIST} > /dev/null 2>&1
	
	for PLIST_ITEM in ${PLIST}
	do
	# 	check if the PLIST_ITEM does exist and load it
		if [ -f "${LAUNCHDDIR}/${PLIST_ITEM}" ]
		then
			if launchctl list | grep `echo ${PLIST_ITEM} | sed -e 's,\.plist,,' ` > /dev/null 2>&1
			then
				launchctl unload ${LAUNCHDDIR}/${PLIST_ITEM} > /dev/null 2>&1
				launchctl load ${LAUNCHDDIR}/${PLIST_ITEM} > /dev/null 2>&1
			else
				launchctl load ${LAUNCHDDIR}/${PLIST_ITEM} > /dev/null 2>&1
			fi
	
			case ${PLIST_ITEM} in
				com.avira.amc.agent.plist)
					launchctl start `echo ${PLIST_ITEM} | sed -e 's,\.plist,,'` > /dev/null 2>&1
					;;
			esac
		fi
	done

# 	give the agent time to start
	sleep 3
}


f_register_smcplugins()
{
	f_echo_me ""
	f_echo_me "registering existing AMC plugins ... "

	for KNOWN_SMC_PLUGINS in osxsrv osxwks
	do
		f_echo_me -n "check for existing AMC plugins (lib${KNOWN_SMC_PLUGINS}) ... "
		if [ -f "${AVGAURDDIR_BASE}/guard/agent/lib${KNOWN_SMC_PLUGINS}.dylib" ]
		then
			f_echo_me "found"
			${AVDIR}/agent --install-plugin ${KNOWN_SMC_PLUGINS} \
				       ${AVGAURDDIR_BASE}/guard/agent/lib${KNOWN_SMC_PLUGINS}.dylib > /dev/null 2>&1
		else
			f_echo_me "${KNOWN_SMC_PLUGINS} not found"
		fi
	done
}


f_install_smcagent()
{
# 	- this function installes the smc agent files in ${AVDIR}

# 	check if there is a running agent, if yes stop it
	f_disable_agent_launchd_job

	if [ -x "${AVDIR}/agent" ]
	then
		${AVDIR}/agent --status > /dev/null 2>&1
		if [ "${?}" -eq "0" ]
		then
			f_echo_me ""
			f_echo_me -n "stop running ${FULLPRODUCTNAME} processes ... "
			if ${AVDIR}/agent --stop > /dev/null 2>&1
			then
				AGENT_PID=""
# 				give the processes a chance to shutdown
				while [ "${SHUTDOWN_TIMEOUT}" -gt 0 ]
				do
					AGENT_PID="`ps ax | grep -v grep | grep "${AVDIR}/agent" | awk -F' ' '{ print $1 }'`"
					if [ -z "${AGENT_PID}" ]
					then
						break
					else
						sleep 1
					fi
					SHUTDOWN_TIMEOUT=`expr ${SHUTDOWN_TIMEOUT} - 1`
				done
				f_echo_me "done"
			else
				f_echo_me "fail"
			fi
		fi

		f_echo_me "remove current AMC node ... "
		${AVDIR}/agent -u
	fi

	f_echo_me ""
	STEP=`expr ${STEP} + 1`
	f_echo_me "${STEP}) installing ${FULLPRODUCTNAME} Components"

	f_echo_me -n "installing ${FULLPRODUCTNAME} main components ... "
	if cp -r avira /opt > /dev/null 2>&1
	then
		f_echo_me "done"
	else
		f_echo_me "fail"
	fi

#	- check if the conf files already exist. if no, copy the .default
	for CONF_FILE_COPY in agent.ini avupdate.conf
	do
		if [ ! -f "${ETCDIR}/${CONF_FILE_COPY}" ]
		then
			f_echo_me -n "copying ${CONF_FILE_COPY}.default to ${ETCDIR}/${CONF_FILE_COPY} ... "
			if cp avira/etc/${CONF_FILE_COPY}.default ${ETCDIR}/${CONF_FILE_COPY} > /dev/null 2>&1
			then
				f_echo_me "done"
			else
				f_echo_me "fail"
			fi
		fi
	done

#	- try to setup the agent conf file with the collected informations
	f_echo_me -n  "setup ${FULLPRODUCTNAME} configuration file ... "
	if AGENT_ERR=`${AVDIR}/agent --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_NETWORKNAME} \
						      ${AGENT_GUID} \
						      ${AGENT_PRODUCT_CONFIG} > /dev/null 2>&1`
	then
		f_echo_me "done"
	else
		f_echo_me "fail"
		f_error_message "It was not possible to setup Avira AMC Agent registration config."
		exit 1
	fi
	
#	check if there is any active avira launchd job. if yes, disable these jobs
	f_disable_avira_launchd_jobs

#	- create an smc agent launchd job, so agent ist started during system startup
	f_enable_agent_launchd_job

# 	register existing smc plugins
	f_register_smcplugins

	return 0
}


# main()
	for PARAMETER in "${@}"
	do
		case "${PARAMETER}" in

			--silence)
				SILENCE="1"
				;;
	
			--no-interaction)
# 				no interaction variables
				LICENSE_AGREEMENT="y"
				UPDATE_LINK="y"
				SETUP_BOOT_SCRIPT="=y"
				MAILGATE_LINK="y"
				SMC_SUPPORT="y"
				OVERWRITE_BOOT_SCRIPT="y"
				REMOVE_BOOT_SCRIPT="y"
				;;
	
			--inf=*)
				TEMP="`echo "${PARAMETER}" | sed -e 's,^--inf=,,'`"
				INF_FILE="${TEMP}"
				. ${INF_FILE}
				HAS_INF="1"
				;;
	
			--version | -v)
				f_display_version
				exit 0
				;;

			--fast)
				DO_SOMETHING="QWE123"
				;;


# 			START agent specific install paramter
			--agent_port=*)
				AGENT_AGENTPORT="`echo ${PARAMETER} | sed -e 's/^--agent_port=//'`"
				;;

			--server_uri=http://*)
				IFACE="`echo ${PARAMETER} | sed -e 's/^--server_uri=http:\/\///'`"
				f_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 ${PARAMETER} | sed -e 's/^--evmgr_uri=http:\/\///'`"
				f_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 ${PARAMETER} | sed -e 's/^--update_uri=http:\/\///'`"
				f_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 ${PARAMETER} | sed -e 's/^--display_name=//'`"
				AGENT_DISPLAYNAME="${TEMP}"
				;;

			--network_name=*)
				TEMP="`echo ${PARAMETER} | sed -e 's/^--network_name=//'`"
				AGENT_NETWORKNAME="--network_name=${TEMP}"
				;;

			--guid=*)
				TEMP="`echo ${PARAMETER} | sed -e 's/^--guid=//'`"
				AGENT_GUID="--guid=${TEMP}"
				;;

			--product_config=*)
				TEMP="`echo ${PARAMETER} | sed -e 's/^--product_config=//'`"
				AGENT_PRODUCT_CONFIG="--product_config=${TEMP}"
				;;
# 			agent specific install paramter END


			*)
				f_echo_me "${PARAMETER} unknown option, please use --help"
				f_error_message "${PARAMETER} unknown option, please use --help"
				exit 1
				;;
		esac
	done

# 	the script will check if the needed parameter were used
	f_check_smc_parameters

# 	if your current position is not the package ${DEFAULT_USER}-directory, the script will switch to the ${DEFAULT_USER}-directory
	f_switch_to_package_root_dir

# 	if there is an .installrc file, the file will be sourced
	if [ -f ".installrc" ]
	then
		. ./.installrc
	fi

	sw_vers | grep -i server > /dev/null 2>&1
	if [ "${?}" -eq "0" ]
	then
		f_echo_me ""
		f_echo_me "Installation aborted."
		f_echo_me "It is not possible to install "${FULLPRODUCTNAME}", because your operatingsystem is not supported."
		f_error_message "It is not possible to install "${FULLPRODUCTNAME}", because your operatingsystem is not supported."
		exit 1
	fi

# 	set product specific variables
	f_set_product_variables

# 	set some default command for specific os
	f_set_commands

# 	check if the user is ${DEFAULT_USER}
	f_root_check

# 	check for the system classification
	f_check_for_systeminfo

# 	check if the current platform is supported by the product
	f_check_platform_support

# 	check if all needed executables are available on this system
	f_check_executables

# 	load avinstall
	. script/sh.avinstall

# 	from here on the real installation starts
	for INSTALL_MODULE in ${MODULE_LIST}
	do
		f_install_${INSTALL_MODULE}
	done

	f_echo_me " "
	f_echo_me "${FULLPRODUCTNAME} successfully installed"

# AVCS4F3A4200C37O030000000203000002A4010000000000000000000000000303000000650300000200P000000000000000024C1EBDED0CB9E0A1DF604419EF1EC7265CF2D4E975A39DD876F1964F06692861F208F7279728B967B521382F423F1EDB5D0EF4B0D5670BC35C06F968CBDC9573654F8087B54C1343B7D9255E976640150AD69D05E24A752F0EB6E74EE0187A46C7C8EE8021A1F79ECF46C29A5446F023CC23647E5743A67BA2D8EEFDCCC7A72407CAE33B34EB9FB0BEAC8B86D26D1F2A57D056FAFDBCAEBD180D32C33B15D520F3EA7BCBC3529DF4C413361B0DEA8966A5450CC07D566C582F609C2226F82CC6C5DFD06A892404EB23E9FABEDC0B34DD419A75C5309265036833FBC7F7967426531A1DCAAA9844EF693FF2A5E8CAB4E9F9F43B13053D5F673F0EC163132191F00000000000000000000000000000292030000000003T62F3AB0132FAVCSE