#!/bin/sh
#
# ovirt-engine-setup -- ovirt engine setup
# Copyright oVirt Authors
# SPDX-License-Identifier: Apache-2.0
#

usage() {
	cat << __EOF__
Usage: $0
    --log=file
        write log to this file.
    --config=file
        Load configuration files.
    --config-append=file
        Load extra configuration files or answer file.
    --generate-answer=file
        Generate answer file.

__EOF__
	exit 0
}

script="$(readlink -f "$0")"
scriptdir="$(dirname "${script}")"
. "${scriptdir}/ovirt-engine-setup.env"
baseenv="APPEND:BASE/pluginPath=str:${scriptdir}/../plugins APPEND:BASE/pluginGroups=str:ovirt-engine-common:ovirt-engine-remove"
otopienv=""
environment=""

environment="${environment} OVESETUP_CORE/offlinePackager=bool:True PACKAGER/yumpackagerEnabled=bool:False"

while [ -n "$1" ]; do
	x="$1"
	v="${x#*=}"
	shift
	case "${x}" in
		--otopi-environment=*)
			otopienv="${v}"
		;;
		--log=*)
			environment="${environment} CORE/logFileName=str:${v}"
		;;
		--config=*)
			environment="${environment} APPEND:CORE/configFileName=str:${v}"
		;;
		--config-append=*)
			environment="${environment} APPEND:CORE/configFileAppend=str:${v}"
		;;
		--generate-answer=*)
			environment="${environment} OVESETUP_CORE/answerFile=str:${v}"
		;;
		--help)
			usage
		;;
		*)
			die "Invalid option '${x}'"
		;;
	esac
done

otopi_exec
