2017-05-10 20:01:46 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Script to build VirtualBox guest kernel modules
|
|
|
|
# Copyright C 2017 by Larry Finger
|
|
|
|
#
|
|
|
|
# This script is part of the openSUSE VirtualBox package
|
|
|
|
#
|
2017-06-25 02:21:46 +02:00
|
|
|
SOURCE="/usr/src/kernel-modules"
|
2017-05-10 20:01:46 +02:00
|
|
|
LOGFILE="/var/log/virtualbox.log"
|
|
|
|
INCLUDE="/lib/modules/`uname -r`/build/include"
|
2017-06-25 19:11:33 +02:00
|
|
|
#
|
|
|
|
# Test if vboxsf module loaded. If it is, skip everything else
|
|
|
|
loaded=$(lsmod | grep vboxsf)
|
|
|
|
if [ -n "$loaded" ] ; then
|
|
|
|
echo "Kernel modules available - exiting..."
|
|
|
|
exit 0
|
|
|
|
fi
|
2017-05-10 20:01:46 +02:00
|
|
|
# Force installation of VB guest sources. Zypper will install all the prerequisies
|
|
|
|
echo "Installing all required packages..."
|
|
|
|
killproc PackageKit
|
|
|
|
zypper install -y virtualbox-guest-source > /dev/null 2>&1
|
2017-06-25 19:11:33 +02:00
|
|
|
if [ "$?" -ne 0 ] ; then
|
2017-05-10 20:01:46 +02:00
|
|
|
echo "Installation of required packages failed."
|
|
|
|
echo "Use 'sudo zypper install virtualbox-guest-source' to see the reason."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# Prerequisites are available, start build
|
|
|
|
pushd $SOURCE > /dev/null 2>&1
|
|
|
|
echo "Building kernel modules..."
|
2017-06-25 19:11:33 +02:00
|
|
|
tar jxf addition/guest_src.tar.bz2 > /dev/null 2>&1
|
2017-05-10 20:01:46 +02:00
|
|
|
cd additions/src
|
|
|
|
make > $LOGFILE 2>&1
|
2017-06-25 19:11:33 +02:00
|
|
|
if [ "$?" -ne 0 ] ; then
|
2017-05-10 20:01:46 +02:00
|
|
|
echo ""
|
|
|
|
echo "Build of VirtualBox guest kernel modules failed."
|
|
|
|
echo "Look at $LOGFILE to find reasons."
|
|
|
|
popd > /dev/null 2>&1
|
|
|
|
exit 1
|
|
|
|
else
|
|
|
|
echo "Kernel modules built correctly. They will now be installed."
|
|
|
|
fi
|
|
|
|
make install >> $LOGFILE 2>&1
|
2017-06-25 19:11:33 +02:00
|
|
|
if [ "$?" -ne 0 ] ; then
|
2017-05-10 20:01:46 +02:00
|
|
|
echo ""
|
|
|
|
echo "Installation of VirtualBox guest kernel modules failed."
|
|
|
|
echo "Look at $LOGFILE to find reasons."
|
|
|
|
popd > /dev/null 2>&1
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
depmod -a
|
|
|
|
modprobe -av vboxguest vboxvideo vboxsf
|
|
|
|
cd ../..
|
2017-06-25 19:11:33 +02:00
|
|
|
rm -rf additions
|
2017-05-10 20:01:46 +02:00
|
|
|
popd > /dev/null 2>&1
|
|
|
|
echo "Kernel modules are installed and loaded."
|
|
|
|
exit 0
|
|
|
|
|