Last active
August 29, 2015 14:23
Virtualbox guest setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh -e | |
# | |
# wget -O virtualbox-guest.sh https://goo.gl/BYGYEx | |
# chmod +x virtualbox-guest.sh | |
# sudo ./virtualbox-guest.sh | |
# | |
if [ $(id -u) != 0 ]; then | |
echo "sudo, remember?" 1>&2 | |
exit 1 | |
fi | |
. /etc/os-release | |
DISTRO="$NAME" | |
case "$DISTRO" in | |
"Ubuntu") | |
echo "Ubuntu supports virtualbox guest additions natively" | |
exit 0 | |
;; | |
"Fedora") | |
dnf install -y gcc kernel kernel-devel kernel-headers dkms make bzip2 perl | |
dnf update -y gcc kernel kernel-devel kernel-headers dkms make bzip2 perl | |
kpkg=$(rpm -q kernel-devel | sort | tail -n 1) | |
kver=$(uname -r) | |
dver=${kpkg#kernel-devel-} | |
if [ "$kver" != "$dver" ]; then | |
echo | |
echo $kpkg does not match: | |
echo running kernel $kver | |
echo | |
echo Reboot? | |
exit 1 | |
fi | |
KERN_DIR=/usr/src/kernels/$kver | |
export KERN_DIR | |
echo KERN_DIR=$KERN_DIR | |
mkdir -p /media/VirtualBoxGuestAdditions | |
mount -o ro /dev/cdrom /media/VirtualBoxGuestAdditions || \ | |
mount -o remount,ro /dev/cdrom /media/VirtualBoxGuestAdditions | |
cd /media/VirtualBoxGuestAdditions | |
./VBoxLinuxAdditions.run | |
exit $? | |
;; | |
*) | |
echo "unsupported distro $DISTRO" 1>&2 | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment