Eh even I had issues and I am not entirely new to Fedora, the only other distro that I had this much trouble with virtualbox is Arch.
Insane in the membrane
is not that hard, the problem is that the virtualbox from fedora repository got broken when they update the kernel to 3.17.8-300.fc21.i686. using the previous kernel, it works okay!
the problem with this script is that it would have to be updated once the oracle release a new build of virtualbox.
also, this thread would be good to be pinned.
It also happened on my 64bit build too, still an odd issue.
Insane in the membrane
Script updated. Now Fedora 18 and 19 friendly. Of course, that wasn't too difficult
PHP Code:
#!/bin/bash
# 21_oracle_virtualbox.sh
# Install and configure the Oracle version of VirtualBox for Fedora 19 and later.
# Install the Oracle VirtualBox Extension Pack.
# Glenn A. Johnson
# Started January 18, 2015
# Updated January 25, 2015
# A tip of the fedora to Fedora Forum members Sea, Skull One, marko, Dangermouse
<< COMMENT
The idea behind this script is to install Oracle VirtualBox and the Oracle VirtualBox Extension Pack for Fedora systems.
The script will detect and remove any installed version of Fedora VirtualBox.
It will clean up when finished by removing downloaded source files.
It will use DNF for Fedora 21 and up, yum otherwise.
Supports color / no color.
Does this script handle PAE kernel? Not yet.
Guest additions need kernel-devel-$(uname -r) and gcc
COMMENT
# Variables
# Additional packages usually needed for a successful install of VirtualBox
packfiles="kernel-devel-$(uname -r) gcc qt qt-x11 libpng15 dkms wget SDL"
# At some point, when Oracle releases an updated RPM, these variables will need to be changed.
vbox_src_file="VirtualBox-4.3-4.3.20_96996_fedora18-1.`uname -m`.rpm"
vbox_ext_src="Oracle_VM_VirtualBox_Extension_Pack-4.3.20-96996.vbox-extpack"
# Color definitions; the variables are null if the option NOCOLOR is set
# Thanks Skull One!
if [ -z "$NOCOLOR" ]; then
OKB=$(tput bold;tput setaf 2)
OK=$(tput setaf 2)
ERR=$(tput bold;tput setaf 1)
RST=$(tput sgr0)
else
OKB=
OK=
ERR=
RST=
fi
# Need root permissions at some point, might as well do it now.
if [[ $EUID -ne 0 ]] ; then
clear
echo -e "You're going to need root permissions at some point. Let's get that out of the way now.\nUse \"sudo\" or \"su -c\""
exit 0
fi
# Release 19 and later only
function get_release()
{
printf $OK"Checking Fedora release version... "$RST
relnum=$(rpm -qa --queryformat '%{version}\n' fedora-release)
if [[ $relnum < "18" ]] ; then
printf $ERR"\nThis script is for Fedora release 18 and later only.\nThis appears to be Fedora release $relnum.\n"$RST
exit 0
else printf $OKB" ✓"$RST
# Determine if we're going to use dnf or yum.
if [[ $relnum < "21" ]] ; then
install_with="yum"
else
install_with="dnf"
fi
fi
echo
}
# Clear screen and print a banner
function banner()
{
clear
printf $OKB"==> VirtualBox installation script for Fedora 18 and up.\n"$RST
printf $OKB"==> Oracle VirtualBox and Oracle VirtualBox Extension Pack will be installed.\n"$RST
}
# Remove Oracle VirtualBox source files if they exist
function remove_source()
{
for i in $vbox_src_file $vbox_ext_src ; do
rm -f $i
done
}
# Remove any installed version of VirtualBox
function remove_fed_vbox()
{
vbox_installed=$(rpm -qa | grep VirtualBox)
if [[ $vbox_installed ]] ; then
printf $OK"Removing previously installed instance of VirtualBox. Please wait..."$RST
$install_with -y -q erase $vbox_installed 2>/dev/null
printf $OK"\nDone.\n"$RST
fi
}
# Install the downloaded source RPM from Oracle
function install_source()
{
if [[ -f $vbox_src_file ]] ; then
printf $OK"Installing Oracle VirtualBox\n"$RST
rpm -Uvh $vbox_src_file
else
echo $ERR"Source file missing."$RST
exit 0
fi
}
# Get any necessary packages needed to complete the VirtualBox installation without errors
function get_packages()
{
echo -e -n $OK"Checking for necessary packages..."$RST
echo
newpkgs=""
for i in $packfiles ; do
echo -e -n $OK"==> $i: "
rpm -q $i > /dev/null
if [ $? -eq 0 ] ; then
echo $OKB"✓"$RST
else
echo $ERR"✗"$RST
newpkgs="${newpkgs} $i"
fi
done
if [ -n "${newpkgs}" ]; then
echo -e -n $OK"==> Installing ${newpkgs}... "$RST
$install_with -y -q install ${newpkgs} 2>/dev/null
echo -e $OKB"\nDone installing packages.\n"$RST
else
echo $OKB"==> Nothing new to install."$RST
fi
}
# Get the VirtualBox source RPM from Oracle
function get_source()
{
echo -e -n $OK"Getting VirtualBox source from the Oracle download site..."$RST
remove_source
wget -q http://download.virtualbox.org/virtualbox/4.3.20/$vbox_src_file
echo -e $OKB" ✓"$RST
echo -e -n $OK"Getting the VirtualBox Extension Pack source file..."$RST
wget -q http://download.virtualbox.org/virtualbox/4.3.20/$vbox_ext_src
echo -e $OKB" ✓"$RST
echo
}
function install_extpack()
{
if [[ -f $vbox_ext_src ]] ; then
echo $OK"Installing Oracle VirtualBox extension pack"$RST
VBoxManage extpack install --replace $vbox_ext_src
else
echo $OK"Trying to install the Oracle VirtualBox extension pack but can't find the source file!"$RST
fi
}
function script_complete()
{
remove_source
printf $OKB"Oracle VirtualBox is now installed.\n"
printf $OKB"Script run complete.\n"$RST
}
function script_cancel()
{
tput cuu1
tput el
printf $OK"Script cancelled.\n"$RST
}
function menu()
{
clear
banner
printf $OK"\nFor this script to succeed you need to be running the newest available and installed kernel.\n\nIf you aren't running the newest available and installed kernel please exit this script\nand update your system. Then boot into to newest kernel and run this script again.\n"$RST
printf $OKB"\nShall we continue? <y/n> "$RST
read yn
case $yn in
y) get_release
remove_source
remove_fed_vbox
get_packages
get_source
install_source
install_extpack
script_complete
;;
n) script_cancel
exit 0
;;
*) script_cancel
exit 0
;;
esac
}
menu
Glenn
The Bassinator © ®
I'm open to suggestions if anyone feels that the script can be improved.
So far it has proven useful to a couple Fedora users. Hope it helps a few more.
Glenn
The Bassinator © ®
Well...Originally Posted by glennzo
In that case, let me ask, did you like (visualy) my efi-helper script, vhs or alike?
They all use TUI.
Have a preview of what it (or the single commands) could look like: Screenshots/
The installation is 2 lines: https://github.com/sri-arjuna/tui/wiki/Installation.
I've been asked what TUI is about, its about to help others with the task of making a script with an interface.
For example: tui-download would show how much it already downloaded (eg: 5mb, 1gb) (remember my 'game' script with zak mckracken? you pointed that out)
Hope this helps
EFI Cheatsheet :: http://forums.fedoraforum.org/showthread.php?t=298546
Video Handler Script (VHS) (mass re-encode videos, screenrecorder, console music/webradio player, ...) :: http://forums.fedoraforum.org/showthread.php?t=299182
Windows 8+ & Fedora 20+ Dualboot :: http://forums.fedoraforum.org/showthread.php?t=298161
The latest version of my script. Works for Fedora 18 and up, I686, I686+PAE and x86_64.
PHP Code:
#!/bin/bash
# 21_oracle_virtualbox.sh
# Install and configure the Oracle version of VirtualBox for Fedora 20 and later.
# Install the Oracle VirtualBox Extension Pack.
# Handle all platforms, i686, PAE and x86_64 .
# Clean up when finished.
# Use DNF for Fedora 21 and up, YUM for Fedora 20 and earlier.
# Remove previously installed VirtualBox.
# Support color / no color (sudo NOCOLOR=1 21_oracle_virtualbox.sh)
# Glenn A. Johnson
# Started January 18, 2015
# Updated February 27, 2015
# 02.25.15 - Betterer code to discover kernel arch.
# 02.23.15 - New code to discover kernel arch
# 02.22.15 - Seems that kernel arch discovery is not working.
# 02.21.15 - New version of VirtualBox
# A tip of the fedora to Fedora Forum members Sea, Skull One, marko, Dangermouse
# for help with code
# Variables - Additional packages usually needed for a successful install of VirtualBox
# over the different platforms, x86_64, i686 and i686+PAE
#PACKFILES="kernel-devel-$(uname -r) gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
# Determine OS platform and install correct packages.
getvers=$(uname -r | grep "PAE")
if [[ $getvers ]] ; then
PACKFILES="kernel-PAE-devel gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
else
PACKFILES="kernel-devel-$(uname -r) gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
fi
# We can easily make changes to the source file versions by changing
# a few variables below.
VB_REL_VER="4.3-4.3.22_98236"
VB_EXT_VER="4.3.22-98236"
VB_REL_DIST="fedora18-1"
VBOX_SRC_FILE="VirtualBox-${VB_REL_VER}_${VB_REL_DIST}."`uname -m`".rpm"
VBOX_EXT_SRC="Oracle_VM_VirtualBox_Extension_Pack-${VB_EXT_VER}.vbox-extpack"
SRC_PATH="http://download.virtualbox.org/virtualbox/4.3.22"
#http://download.virtualbox.org/virtualbox/4.3.22/VirtualBox-4.3-4.3.22_98236_fedora18-1.i686.rpm
# Color definitions; the variables are null if the option NOCOLOR is set.
# Thanks Skull One!
if [ -z "$NOCOLOR" ]; then
OKB=$(tput bold;tput setaf 6)
OK=$(tput setaf 6)
ERRB=$(tput bold;tput setaf 1)
ERR=$(tput setaf 1)
RST=$(tput sgr0)
else
OKB=
OK=
ERRB=
ERR=
RST=
fi
# Need root permissions at some point, might as well do it now.
if [[ $EUID -ne 0 ]] ; then
clear
printf $OK"You're going to need root permissions at some point. Let's get that out of the way now.\nUse \"sudo\" or \"su -c\"\n"$RST
exit 0
fi
# Release 20 and later only
function get_release()
{
printf $OK"Checking Fedora release version... "$RST
RELNUM=$(rpm -qa --queryformat '%{version}\n' fedora-release)
if [[ $RELNUM < "20" ]] ; then
printf $ERR"\nThis script is for Fedora release 20 and later only.\n"$RST
exit 0
else printf $OKB"Fedora $RELNUM ✓"$RST
# Determine if we're going to use dnf or yum.
if [[ $RELNUM < "21" ]] ; then
install_with="yum"
else
install_with="dnf"
fi
fi
echo
}
# Clear screen and print a headline.
function headline()
{
clear
printf $OKB"==> VirtualBox installation script for Fedora 20 and up.\n"$RST
printf $OKB"==> Oracle VirtualBox and Oracle VirtualBox Extension Pack will be installed.\n"$RST
}
# Remove Oracle VirtualBox source files if they exist in the current working directory.
function remove_source()
{
for i in $VBOX_SRC_FILE $VBOX_EXT_SRC ; do
rm -f $i
done
}
# Remove any installed version of VirtualBox.
function remove_fed_vbox()
{
VBOX_INSTALLED=$(rpm -qa | grep VirtualBox)
if [[ $VBOX_INSTALLED ]] ; then
printf $OK"Removing previously installed instance of VirtualBox. Please wait..."$RST
$install_with -y -q erase $VBOX_INSTALLED 2>/dev/null
printf $OKB" ✓\n\n"$RST
fi
}
# Install Oracle VirtualBox from the downloaded source RPM.
function install_source()
{
if [[ -f $VBOX_SRC_FILE ]] ; then
printf $OK"Installing Oracle VirtualBox\n"$RST
rpm -Uvh $VBOX_SRC_FILE
else
printf $ERR"The source file missing.\nThere was an error downloading the file.\n"$RST
exit 0
fi
}
# Install the Oracle VirtualBox Extension Pack.
function install_extpack()
{
if [[ -f $VBOX_EXT_SRC ]] ; then
echo $OK"Installing Oracle VirtualBox extension pack."$RST
VBoxManage extpack install --replace $VBOX_EXT_SRC
else
printf $ERR"Oracle VirtualBox extension pack source file missing!\n"$RST
fi
}
# Get any Fedora packages typically needed to complete the VirtualBox installation without errors.
function get_packages()
{
printf $OK"Checking for necessary packages..."$RST
echo
NEWPKGS=""
for i in $PACKFILES ; do
printf $OK"==> $i: "
rpm -q $i > /dev/null
if [ $? -eq 0 ] ; then
printf $OKB"✓\n"$RST
else
printf $ERR"✗\n"$RST
NEWPKGS="${NEWPKGS} $i"
fi
done
if [ -n "${NEWPKGS}" ]; then
echo -e -n $OK"==> Installing necessary packages$OKB "${NEWPKGS}"... "$RST
#echo "Installing ${NEWPKGS}"
$install_with -y -q install ${NEWPKGS} 2>/dev/null
echo -e $OKB"\nDone installing packages.\n"$RST
else
printf $OK"==>$OKB Nothing new to install.\n"$RST
fi
}
# Get the VirtualBox source files from Oracle
function get_source()
{
printf $OK"Getting VirtualBox source from the Oracle download site..."$RST
remove_source
wget -q $SRC_PATH/$VBOX_SRC_FILE
printf $OKB" ✓\n"$RST
printf $OK"Getting the VirtualBox Extension Pack source file..."$RST
wget -q $SRC_PATH/$VBOX_EXT_SRC
printf $OKB" ✓\n"$RST
echo
}
# The script run has completed. Print a short message stating same.
function script_complete()
{
remove_source
printf $OKB"Oracle VirtualBox is now installed.\n"
printf $OKB"Script run complete.\n"$RST
}
# Script execution has been cancelled by the user.
function script_cancel()
{
tput cuu1
tput el
printf $OK"Script cancelled.\n"$RST
}
# Main script flow
function menu()
{
clear
headline
printf $OK"\nFor this script to succeed you need to be running the newest available and installed kernel.\n\nIf you aren't running the newest available and installed kernel please exit this script\nand update your system. Then boot into the newest kernel and run this script again.\n"$RST
printf $OKB"\nShall we continue? <y/n/t> "$RST
read yn
case $yn in
y) get_release
remove_fed_vbox
get_packages
get_source
install_source
install_extpack
script_complete
;;
n) script_cancel
exit 0
;;
# Test menu entry
t) get_release
get_packages
get_source
script_complete
;;
*) script_cancel
exit 0
;;
esac
}
menu
Glenn
The Bassinator © ®
Has anyone else tried this script? How well did it work? I've tested it fairly extensively on virtual machines, Fedora 21 and 20, x86_64, i686 and i686+PAE. Feedback would be awesome.
Updated code in post #23 as of today.
Disregard the "test" menu option. I needed something that would do some quick testing without doing the full installation.
Glenn
The Bassinator © ®
Minor code updates and tested for Fedora 22 Workstation Alpha x86_64.
PHP Code:
#!/bin/bash
# 21_oracle_virtualbox.sh
# Install and configure the Oracle version of VirtualBox for Fedora 20 and later.
# Install the Oracle VirtualBox Extension Pack.
# Handle all platforms, i686, PAE and x86_64 .
# Clean up when finished.
# Use DNF for Fedora 21 and up, YUM for Fedora 20 and earlier.
# Remove previously installed VirtualBox.
# Support color / no color (sudo NOCOLOR=1 21_oracle_virtualbox.sh)
# Glenn A. Johnson
# Started January 18, 2015
# Updated March 15, 2015
# 03.15.15 - Tested under Fedora 22 Workstation Alpha (x86_64).
# 03.14.15 - New VirtualBox version
# 02.25.15 - Betterer code to discover kernel arch.
# 02.23.15 - New code to discover kernel arch
# 02.22.15 - Seems that kernel arch discovery is not working.
# 02.21.15 - New version of VirtualBox
# A tip of the fedora to Fedora Forum members Sea, Skull One, marko, Dangermouse
# for help with code
# Variables - Additional packages usually needed for a successful install of VirtualBox
# over the different platforms, x86_64, i686 and i686+PAE
#PACKFILES="kernel-devel-$(uname -r) gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
# Determine OS platform and install correct packages.
GETVERS=$(uname -r | grep "PAE")
if [[ $GETVERS ]] ; then
PACKFILES="kernel-PAE-devel gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
else
PACKFILES="kernel-devel-$(uname -r) gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
fi
# We can easily make changes to the source file versions by changing
# a few variables below.
VB_REL_VER="4.3-4.3.24_98716"
VB_EXT_VER="4.3.24-98716"
VB_REL_DIST="fedora18-1"
VBOX_SRC_FILE="VirtualBox-${VB_REL_VER}_${VB_REL_DIST}."`uname -m`".rpm"
VBOX_EXT_SRC="Oracle_VM_VirtualBox_Extension_Pack-${VB_EXT_VER}.vbox-extpack"
SRC_PATH="http://download.virtualbox.org/virtualbox/4.3.24"
# Color definitions; the variables are null if the option NOCOLOR is set.
# Thanks Skull One!
if [ -z "$NOCOLOR" ]; then
OKB=$(tput bold;tput setaf 6)
OK=$(tput setaf 6)
ERRB=$(tput bold;tput setaf 1)
ERR=$(tput setaf 1)
RST=$(tput sgr0)
else
OKB=
OK=
ERRB=
ERR=
RST=
fi
# Need root permissions at some point, might as well do it now.
if [[ $EUID -ne 0 ]] ; then
clear
printf $OK"You're going to need root permissions at some point. Let's get that out of the way now.\nUse \"sudo\" or \"su -c\"\n"$RST
exit 0
fi
# Release 20 and later only
function get_release()
{
printf $OK"Checking Fedora release version... "$RST
RELNUM=$(rpm -qa --queryformat '%{version}\n' fedora-release)
if [[ $RELNUM < "20" ]] ; then
printf $ERR"\nThis script is for Fedora release 20 and later only.\n"$RST
exit 0
else printf $OKB"Fedora $RELNUM ✓"$RST
# Determine if we're going to use dnf or yum.
if [[ $RELNUM < "21" ]] ; then
install_with="yum"
else
install_with="dnf"
fi
fi
echo
}
# Clear screen and print a headline.
function headline()
{
clear
printf $OK"==>$OKB VirtualBox installation script for Fedora 20 and up.\n"$RST
printf $OK"==>$OKB Oracle VirtualBox and Oracle VirtualBox Extension Pack will be installed.\n"$RST
}
# Remove Oracle VirtualBox source files if they exist in the current working directory.
function remove_source()
{
for i in $VBOX_SRC_FILE $VBOX_EXT_SRC ; do
rm -f $i
done
}
# Remove any installed version of VirtualBox.
function remove_fed_vbox()
{
VBOX_INSTALLED=$(rpm -qa | grep VirtualBox)
if [[ $VBOX_INSTALLED ]] ; then
printf $OK"Removing previously installed instance of VirtualBox. Please wait..."$RST
$install_with -y -q erase $VBOX_INSTALLED 2>/dev/null
printf $OKB" ✓\n\n"$RST
fi
}
# Install Oracle VirtualBox from the downloaded source RPM.
function install_source()
{
if [[ -f $VBOX_SRC_FILE ]] ; then
printf $OK"Installing Oracle VirtualBox\n"$RST
rpm -Uvh $VBOX_SRC_FILE
else
printf $ERR"The source file missing.\nThere was an error downloading the file.\n"$RST
exit 0
fi
}
# Install the Oracle VirtualBox Extension Pack.
function install_extpack()
{
if [[ -f $VBOX_EXT_SRC ]] ; then
echo $OK"Installing Oracle VirtualBox extension pack."$RST
VBoxManage extpack install --replace $VBOX_EXT_SRC
else
printf $ERR"Oracle VirtualBox extension pack source file missing!\n"$RST
fi
}
# Get any Fedora packages typically needed to complete the VirtualBox installation without errors.
function get_packages()
{
printf $OK"Checking for necessary packages..."$RST
echo
NEWPKGS=""
for i in $PACKFILES ; do
printf $OK"==> $i: "
rpm -q $i > /dev/null
if [ $? -eq 0 ] ; then
printf $OKB"✓\n"$RST
else
printf $ERR"✗\n"$RST
NEWPKGS="${NEWPKGS} $i"
fi
done
if [ -n "${NEWPKGS}" ]; then
echo -e -n $OK"==> Installing necessary packages$OKB "${NEWPKGS}"... "$RST
$install_with -y -q install ${NEWPKGS} 2>/dev/null
echo -e $OKB"\nDone installing packages.\n"$RST
else
printf $OK"==>$OKB Nothing new to install.\n"$RST
fi
}
# Get the VirtualBox source files from Oracle
function get_source()
{
printf $OK"Getting VirtualBox source from the Oracle download site..."$RST
remove_source
wget -q $SRC_PATH/$VBOX_SRC_FILE
printf $OKB" ✓\n"$RST
printf $OK"Getting the VirtualBox Extension Pack source file..."$RST
wget -q $SRC_PATH/$VBOX_EXT_SRC
printf $OKB" ✓\n"$RST
echo
}
# The script run has completed. Print a short message stating same.
function script_complete()
{
remove_source
printf $OKB"Oracle VirtualBox is now installed.\n"
printf $OKB"Script run complete.\n"$RST
}
# The test script run has completed.
function script_test_complete()
{
remove_source
printf $OKB"This script test is now complete.\n"
printf $OKB"All necessary Fedora packages are installed.\n"$RST
}
# Script execution has been cancelled by the user.
function script_cancel()
{
tput cuu1
tput el
printf $OK"Script cancelled.\n"$RST
}
# Main script flow
function menu()
{
clear
headline
printf $OK"\nFor this script to succeed you need to be running the newest available and installed kernel.\n\nIf you aren't running the newest available and installed kernel please exit this script\nand update your system. Then boot into the newest kernel and run this script again.\n"$RST
printf $OKB"\nShall we continue? <y/n/t> "$RST
read yn
case $yn in
y) get_release
remove_fed_vbox
get_packages
get_source
install_source
install_extpack
script_complete
;;
n) script_cancel
exit 0
;;
# Test menu entry
t) get_release
get_packages
get_source
script_test_complete
;;
*) script_cancel
exit 0
;;
esac
}
menu
Glenn
The Bassinator © ®
Hello, if I could make this work then it would be great. Something in your code would likely correct my install issues. I do not understand at what point I'd use your script though. I am very new to fedora and have limited experience with VMBox. I've DL the latest VMBox (4.3.26) and am on a host Windows 7 64-bit Dell Inspiron laptop. I need to get some version of fedora (my text book uses fedora 13 to show how far behind our professors are) on my VMBox. I've tried already with fedora 21 (worstation) x86 version. I'd like to try with an iso of fedora 13 but don't know where to find that archived file.
Where or how does your script come into play-- and could you tell me generally what I've done incorrectly? I'd appreciate any help at all.
My script will be of no use to you. It is for a Fedora host.
You need the VirtualBox.exe file for a Windows host. http://download.virtualbox.org/virtu...-98988-Win.exe
Install that along with VirtualBox Extension Pack http://download.virtualbox.org/virtu...8.vbox-extpack. Click on the extension pack file and VirtualBox will open and offer to install it.
Then you need Fedora 13 32 Bit or 64 Bit.
Glenn
The Bassinator © ®
Has anyone else tried this script? It would be wonderful to get some feedback. Did it work well?
Tested under Fedora 22 Beta x86_64 (virtual machine). Worked well
Still can't upload attachments
Copy and paste. Save as anythingyoulike.sh
Run
PHP Code:
sudo ./anythingyoulike.sh
PHP Code:
#!/bin/bash
# 21_oracle_virtualbox.sh
# Install and configure the Oracle version of VirtualBox for Fedora 20 and later.
# Install the Oracle VirtualBox Extension Pack.
# Handle all platforms, i686, PAE and x86_64 .
# Clean up when finished.
# Use DNF for Fedora 21 and up, YUM for Fedora 20 and earlier.
# Remove previously installed VirtualBox.
# Support color / no color (sudo NOCOLOR=1 21_oracle_virtualbox.sh)
# Glenn A. Johnson
# Started January 18, 2015
# Updated April 26, 2015
# 04.26.15 - Can I add an uninstall (safely) feature?
# 04.26.15 - Testing... 1,2,3
# 03.26.15 - Cosmetic changes and version update
# 03.15.15 - Tested under Fedora 22 Workstation Alpha (x86_64).
# 03.14.15 - New VirtualBox version
# 02.25.15 - Betterer code to discover kernel arch.
# 02.23.15 - New code to discover kernel arch
# 02.22.15 - Seems that kernel arch discovery is not working.
# 02.21.15 - New version of VirtualBox
# A tip of the fedora to Fedora Forum members Sea, Skull One, marko, Dangermouse
# for help with code
# Variables - Additional packages usually needed for a successful install of VirtualBox
# over the different platforms, x86_64, i686 and i686+PAE
#PACKFILES="kernel-devel-$(uname -r) gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
# Determine OS platform and install correct packages.
# PAE or no?
GETVERS=$(uname -r | grep "PAE")
if [[ $GETVERS ]] ; then
PACKFILES="kernel-PAE-devel gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
else
PACKFILES="kernel-devel-$(uname -r) gcc qt qt-x11 libpng15 libXmu libXt libvpx dkms wget SDL"
fi
# We can easily make changes to the source file versions by changing a few variables below.
# Most recent is http://download.virtualbox.org/virtualbox/4.3.26/VirtualBox-4.3-4.3.26_98988_fedora18-1.x86_64.rpm
VB_REL_VER="4.3-4.3.26_98988"
VB_EXT_VER="4.3.26-98988"
VB_REL_DIST="fedora18-1"
VBOX_SRC_FILE="VirtualBox-${VB_REL_VER}_${VB_REL_DIST}."`uname -m`".rpm"
VBOX_EXT_SRC="Oracle_VM_VirtualBox_Extension_Pack-${VB_EXT_VER}.vbox-extpack"
SRC_PATH="http://download.virtualbox.org/virtualbox/4.3.26"
# Color definitions; the variables are null if the option NOCOLOR is set.
# Thanks Skull One!
if [ -z "$NOCOLOR" ]; then
OKB=$(tput bold;tput setaf 6)
OK=$(tput setaf 6)
ERRB=$(tput bold;tput setaf 1)
ERR=$(tput setaf 1)
RST=$(tput sgr0)
else
OKB=
OK=
ERRB=
ERR=
RST=
fi
# Need root permissions at some point, might as well do it now.
if [[ $EUID -ne 0 ]] ; then
clear
printf $OK"You're going to need root permissions at some point. Let's get that out of the way now.\nUse \"sudo\" or \"su -c\"\n"$RST
exit 0
fi
# Release 20 and later only
function get_release()
{
printf $OK"Checking Fedora release version... "$RST
RELNUM=$(rpm -qa --queryformat '%{version}\n' fedora-release)
if [[ $RELNUM < "20" ]] ; then
printf $ERR"\nThis script is for Fedora release 20 and later only.\n"$RST
exit 0
else printf $OKB"Fedora $RELNUM ✓"$RST
# Determine if we're going to use dnf or yum.
if [[ $RELNUM < "21" ]] ; then
install_with="yum"
else
install_with="dnf"
fi
fi
echo
}
# Clear screen and print a headline.
function headline()
{
clear
printf $OK"==>$OKB VirtualBox installation script for Fedora 20 and up.\n"$RST
printf $OK"==>$OKB Oracle VirtualBox and Oracle VirtualBox Extension Pack will be installed.\n"$RST
printf $OK"==>$OKB VirtualBox release $VB_REL_VER\n"$RST
}
# Remove Oracle VirtualBox source files if they exist in the current working directory.
function remove_source()
{
for i in $VBOX_SRC_FILE $VBOX_EXT_SRC ; do
rm -f $i
done
}
# Remove any installed version of VirtualBox.
function remove_fed_vbox()
{
VBOX_INSTALLED=$(rpm -qa | grep VirtualBox)
if [[ $VBOX_INSTALLED ]] ; then
printf $OK"Removing previously installed instance of VirtualBox. Please wait..."$RST
$install_with -y -q erase $VBOX_INSTALLED 2>/dev/null
printf $OKB" ✓\n\n"$RST
fi
}
# Install Oracle VirtualBox from the downloaded source RPM.
function install_source()
{
if [[ -f $VBOX_SRC_FILE ]] ; then
printf $OK"Installing Oracle VirtualBox\n"$RST
rpm -Uvh $VBOX_SRC_FILE
else
printf $ERR"The source file missing.\nThere was an error downloading the file.\n"$RST
exit 0
fi
}
# Install the Oracle VirtualBox Extension Pack.
function install_extpack()
{
if [[ -f $VBOX_EXT_SRC ]] ; then
echo $OK"Installing Oracle VirtualBox extension pack."$RST
VBoxManage extpack install --replace $VBOX_EXT_SRC
else
printf $ERR"Oracle VirtualBox extension pack source file missing!\n"$RST
fi
}
# Get any Fedora packages typically needed to complete the VirtualBox installation without errors.
function get_packages()
{
printf $OK"Checking for necessary packages..."$RST
echo
NEWPKGS=""
for i in $PACKFILES ; do
printf $OK"==> $i: "
rpm -q $i > /dev/null
if [ $? -eq 0 ] ; then
printf $OKB"✓\n"$RST
else
printf $ERR"✗\n"$RST
NEWPKGS="${NEWPKGS} $i"
fi
done
if [ -n "${NEWPKGS}" ]; then
echo -e -n $OK"==> Installing necessary packages$OKB "${NEWPKGS}"... "$RST
$install_with -y -q install ${NEWPKGS} 2>/dev/null
echo -e $OKB"\nDone installing packages.\n"$RST
else
printf $OK"==>$OKB Nothing new to install.\n"$RST
fi
}
# Get the VirtualBox source files from Oracle
function get_source()
{
printf $OK"Getting the VirtualBox source RPM from the Oracle download site..."$RST
remove_source
wget -q $SRC_PATH/$VBOX_SRC_FILE
printf $OKB" ✓\n"$RST
printf $OK"Getting the VirtualBox Extension Pack source file..."$RST
wget -q $SRC_PATH/$VBOX_EXT_SRC
printf $OKB" ✓\n"$RST
echo
}
# The script run has completed. Print a short message stating same.
function script_complete()
{
remove_source
printf $OKB"Oracle VirtualBox is now installed.\n"
printf $OKB"Script run complete.\n"$RST
}
# The test script run has completed.
function script_test_complete()
{
remove_source
printf $OKB"This script test is now complete.\n"
printf $OKB"All necessary Fedora packages are installed.\n"$RST
}
# Script execution has been cancelled by the user.
function script_cancel()
{
tput cuu1
tput el
printf $OK"Script cancelled.\n"$RST
}
# Main script flow
function menu()
{
clear
headline
printf $OK"\nFor this script to succeed you need to be running the newest available and installed kernel.\n\nIf you aren't running the newest available and installed kernel please exit this script\nand update your system. Then boot into the newest kernel and run this script again.\n"$RST
printf $OKB"\nShall we continue? <y/n/t> "$RST
read yn
case $yn in
y) get_release
remove_fed_vbox
get_packages
get_source
install_source
install_extpack
script_complete
;;
n) script_cancel
exit 0
;;
# Test menu entry used for development. End user should ignore this menu option.
# All this does is install missing packages. It also downloads VirtualBox and the Extension Pack.
t) get_release
get_packages
get_source
script_test_complete
;;
*) script_cancel
exit 0
;;
esac
}
menu
Glenn
The Bassinator © ®
glennzo:
Thanks again for this. After several upgrades in both kernel and VirtualBox, script continues to work flawlessly. Staying current is sooooo easy.
You're welcome.
Oddly enough, there is a new version of VirtualBox. I've updated the script for that version but haven't had time to update here. (At work at the moment). I believe, and correct me if I'm wrong, that there is an extremely serious vulnerability with virtual machines run under VirtualBox. Here's an example of what I've read somewhere else.
http://www.zdnet.com/article/venom-s...s-datacenters/
Glenn
The Bassinator © ®