#!/bin/sh

set -e

oci-wait-for-networking
SYSTEM_SERIAL=$(oci-system-serial)
PXE_SERVER_IP=$(cat /etc/oci/pxe-server-ip)

curl "http://${PXE_SERVER_IP}/oci/install-status.php?status=live&chassis-serial=${SYSTEM_SERIAL}"

if [ -e /etc/oci/live-image-dell-ipmi ] ; then
	DELL_IPMI_REPO=$(cat /etc/oci/setup-dell-ipmi-intarget-repo)

	# Note that "stretch" is always correct, in Buster as well.
	echo "deb ${DELL_IPMI_REPO} stretch main" >/etc/apt/sources.list.d/dell-ipmi.list
	apt-get update
	apt-get install -y srvadmin-idracadm8

	IDRAC_TYPE=$(ipmitool sdr elist mcloc | awk '{print $1}')
	if [ "${IDRAC_TYPE}" = "iDRAC6" ] || [ "${IDRAC_TYPE}" = "iDRAC7" ] ; then
		apt install -y syscfg libssl1.0.0 || true
	fi
fi
