#!/bin/bash
source ../../global-conf.sh

# DELL server - install dell openmanage
# http://linux.dell.com/repo/community/openmanage/
if ( ! dpkg -l | grep dmidecode ); then
	apt-get install -y dmidecode
fi

if ( dmidecode | grep Dell ); then
	if ( grep -qa container=lxc /proc/1/environ ); then
		echo "The system is running in a LXC container, no Dell package will be installed."
		exit 0
	fi

	echo 'deb http://linux.dell.com/repo/community/openmanage/930/bionic bionic main' > /etc/apt/sources.list.d/linux.dell.com.sources.list
	gpg --keyserver pool.sks-keyservers.net --recv-key 1285491434D8786F
	gpg -a --export 1285491434D8786F | sudo apt-key add -

	apt-get update
	apt-get install -y srvadmin-all

	# dsm_om_connsvc is the service to start a web interface on https://<ip_address>:1311/
	# by default, the interface is only available to the root user
	# sed -i "s@^root@root,admin@" /opt/dell/srvadmin/etc/omarolemap
	systemctl enable dsm_om_connsvc
	systemctl start dsm_om_connsvc
fi
