Skip to content

Instantly share code, notes, and snippets.

@vroetman
Last active August 29, 2015 14:14
Show Gist options
  • Save vroetman/4876eb6f0d52d3a221e3 to your computer and use it in GitHub Desktop.
Save vroetman/4876eb6f0d52d3a221e3 to your computer and use it in GitHub Desktop.
Install Virtualbox Guest Additions
#! /bin/bash
#########################################################################
# Install VirtualBox Guest Additions
# Install yum dependencies gcc, curl, kernel-devel, kernel headers
# Install DKMS from source
# Install Guest Additions (they should be copied up by packer, if not
# then download from virtualbox.org)
# When DKMS is installed first, the guest additions should be rebuilt
# when the kernel is upgraded.
#########################################################################
echo install virtualbox guest additions
echo vboxguestadditions: check if guest additions are installed
if modprobe -q vboxguest
then
echo vboxguestadditions: guest additions already installed
exit 0
fi
# dependencies for guest additions
echo vboxguestadditions: install gcc, curl, and kernel-devel
yum install -y gcc kernel-devel curl kernel-devel-$(uname -r)
# dkms is needed so that guest additions are rebuilt when the kernel is upgraded
echo vboxguestadditions: download and install dkms
yum install -y http://linux.dell.com/dkms/permalink/dkms-2.2.0.3-1.noarch.rpm
ISONAME=/root/VBoxGuestAdditions.iso
echo vboxguestadditions: check if $ISONAME exists
if ! [ -f $ISONAME ]; then
echo vboxguestadditions: $ISONAME does not exist, downloading
latest=`curl -L http://download.virtualbox.org/virtualbox/LATEST.TXT`
curl -L http://download.virtualbox.org/virtualbox/$latest/VBoxGuestAdditions_$latest.iso -o $ISONAME
fi
GUESTMOUNT=/mnt/guestadditions
mkdir $GUESTMOUNT
mount -t iso9660 $ISONAME $GUESTMOUNT -o loop
echo vboxguestadditions: installing guest additions
$GUESTMOUNT/VBoxLinuxAdditions.run
umount $GUESTMOUNT
rmdir $GUESTMOUNT
rm $ISONAME
echo vboxguestadditions: finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment