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

# DELL server - install dell openmanage
if ( ! dpkg -l | grep dmidecode ); then
	apt-get install -y dmidecode
fi

if ( dmidecode | grep Dell ); then
	echo 'deb http://linux.dell.com/repo/community/ubuntu xenial openmanage' | sudo tee -a /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

	update-rc.d dsm_om_connsvc defaults
	echo "@reboot root /usr/sbin/service dsm_om_connsvc start" > /etc/cron.d/dell_openmanage

	sed -i "s@^root@root,admin@" /opt/dell/srvadmin/etc/omarolemap

	service dsm_om_connsvc start
fi
