--- /tmp/dellomsaesm.orig	Tue Nov 20 16:01:37 2001
+++ dellomsaesm	Tue Nov 20 17:05:10 2001
@@ -26,6 +26,8 @@
 # Source script functions
 . /etc/rc.d/init.d/functions
 
+set -x
+
 OMSA_NAME="Dell OpenManage Server Agent"
 OMSADD_NAME="${OMSA_NAME} Device Drivers"
 OMSADD_ROOT_DIR="/usr/lib/dell/openmanage/omsa/drivers"
@@ -247,23 +249,46 @@
 	GENERIC_VER=`uname -r | sed "s/-.*//"`
 	GENERIC_VER_DIR="${OMSADD_OPEN_DIR}/${GENERIC_VER}-generic"
 
-	CURRENT_VER=`uname -r | sed "s/[a-z].*//"`
+	# There are various formats for uname -r
+	# 2.4.3-6smp 2.4.3-6 2.4.3-6enterprise (for Red Hat kernels)
+	# 2.4.15-pre7  (for Linus pre kernels)
+	# 2.4.15       (for Linus released kernels)
+	# 2.4.14-ac8   (for Alan Cox kernels)
+	# 2.4.14ac8    (for Alan Cox kernels built from 'make rpm')
+
+	CURRENT_VER=`uname -r`
 	CURRENT_VER_DIR="${OMSADD_OPEN_DIR}/${CURRENT_VER}"
+	KERNEL_SOURCE_DIR="/usr/src/linux"
+
+	# The canonical location for the kernel
+	if [ -e /lib/modules/${CURRENT_VER}/build ]; then
+	    KERNEL_SOURCE_DIR="/lib/modules/${CURRENT_VER}/build"
+	elif [ -e /usr/src/linux ]; then
+	    KERNEL_SOURCE_DIR="/usr/src/linux"
+	elif [ -e /usr/src/linux-2.4 ]; then
+	    KERNEL_SOURCE_DIR="/usr/src/linux-2.4"
+	fi
 
 	# Create generic version directory
 	mkdir -p ${GENERIC_VER_DIR}
-	ln -sf /usr/src/linux*/arch ${GENERIC_VER_DIR}
-	ln -sf /usr/src/linux*/scripts ${GENERIC_VER_DIR}
-
+	ln -sf ${KERNEL_SOURCE_DIR}/arch ${GENERIC_VER_DIR}
+	ln -sf ${KERNEL_SOURCE_DIR}/scripts ${GENERIC_VER_DIR}
 	# Create current version directory
 	mkdir -p ${CURRENT_VER_DIR}
-	cp -rf /usr/src/linux*/configs/* ${CURRENT_VER_DIR} 2>>${OMSADD_LOG_FILE}
+	# Copy the .config file or configs/* if necessary
+	if [ -e ${KERNEL_SOURCE_DIR}/.config ]; then
+	    cp -f ${KERNEL_SOURCE_DIR}/.config ${CURRENT_VER_DIR} 2>>${OMSADD_LOG_FILE}
+	else
+	
+	    cp -rf ${KERNEL_SOURCE_DIR}/configs/* ${CURRENT_VER_DIR} 2>>${OMSADD_LOG_FILE}
+	fi
+
 	if [ $? != 0 ];
 	then
 		echo "The kernel headers and source are not installed." >>${OMSADD_LOG_FILE}
 		return 41
 	fi
-	ln -sf /usr/src/linux*/include ${CURRENT_VER_DIR}
+	ln -sf ${KERNEL_SOURCE_DIR}/include ${CURRENT_VER_DIR}
 
 	# Copy the rules for compiling
 	cp -sf ${OMSADD_OPEN_DIR}/install/Rules.make ${GENERIC_VER_DIR}
