File vmwareconfig.sh of Package vmware-host-modules

#!/bin/bash
#
# Script to build vmware host kernel modules
#
# This script is part of the openSUSE vmware-host-modules package
# (based on vboxconfig.sh from virtualbox package)
#

SOURCE="/usr/src/kernel-modules/vmware/src"
LOGFILE="/var/log/vmwareconfig.log"
INCLUDE="/lib/modules/$(uname -r)/build/include"

# Test if vmmon module is loaded. If it is, skip everything else
loaded=$(lsmod | grep vmmon)
[[ -n $loaded ]] && {
	echo "Kernel modules are loaded, unload them via"
	echo "'rmmod -v vmmon vmnet' if you wish to rebuild them."
	echo "Quitting .."
	exit 1
}

# Prerequisites are available, start build
pushd $SOURCE > /dev/null 2>&1
echo "Building kernel modules..."
make clean &>/dev/null
make > $LOGFILE 2>&1
[[ $? -ne 0 ]] && {
	echo ""
	echo "Build of vmware host kernel modules failed."
	echo "Look at '$LOGFILE' to find reasons."
	popd > /dev/null 2>&1
	exit 1
}
echo "Kernel modules built correctly. They will now be installed."

make install >> $LOGFILE 2>&1
[[ $? -ne 0 ]] && {
	echo ""
	echo "Installation of vmware host kernel modules failed."
	echo "Look at '$LOGFILE' to find reasons."
	popd > /dev/null 2>&1
	exit 1
}

depmod -a
modprobe -av vmmon vmnet
popd > /dev/null 2>&1
echo "Kernel modules are installed and loaded."
exit 0
openSUSE Build Service is sponsored by