#!/bin/sh
###############################################################################
#
#          Dell Inc. PROPRIETARY INFORMATION
# This software is supplied under the terms of a license agreement or
# nondisclosure agreement with Dell Inc. and may not be copied or disclosed
# except in accordance with the terms of that agreement.
#
# Copyright (c) 2006-2010 Dell Inc. All Rights Reserved.
#
# Module Name:
#
#   md_launcher.sh
#
#
# Abstract/Purpose:
#
#   Run the PowerVault Modular Disk launcher
#
#
# Environment:
#
#   Linux
#
###############################################################################

if [ -e /etc/redhat-release ]; then
	OS="rhel"
elif [ -e /etc/SuSE-release ]; then
	OS="sles"
	LINUX_REV_MAJOR=$(cat /etc/SuSE-release | tr '\n' ' ' | sed 's/.*VERSION = //' | sed 's/ .*//')
	LINUX_REV_MINOR=$(cat /etc/SuSE-release | tr '\n' ' ' | sed 's/.*PATCHLEVEL = //' | sed 's/ .*//')
	LINUX_REV=${LINUX_REV_MAJOR}.${LINUX_REV_MINOR}
fi

ARCH=$(uname -m)
if [ "${ARCH}" == "x86_64" ]; then
	LAUNCHER="md_launcher_${OS}_x86_64.bin"
else
	LAUNCHER="md_launcher_${OS}_x86.bin"
fi

if [ -e "${LAUNCHER}" ]; then
	if [ "${OS}" == "sles" -a "${LINUX_REV_MAJOR}" == "11" -a "${ARCH}" == "x86_64" ]; then
		INSTALLED_GLITZ_PKG=$(rpm -q glitz)
		if [ $? != 0 ]; then
			rpm -i launcher_data/libs/sles11/glitz-*.x86_64.rpm
		fi
		# Run linux_hostnameupdates.sh which contains checks to add entry in /etc/hosts for SLES 11
		./linux_hostnameupdates.sh
	fi
	if [ "${OS}" == "rhel" ]; then
		./md_prereq_install.sh
		./linux_hostnameupdates.sh
	fi
	./${LAUNCHER}
fi
