Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Checks if the Extension Pack version matches the installed VirtualBox version and if not, delete the Extension Pack, downloads and installs the new one.
#! /bin/bash
#
#: Title : updateVboxExt
#: Date Created: Fri May 13 13:54:26 PDT 2011
#: Last Edit : Fri May 13 14:34:37 PDT 201
#: Author : please_try_again
#: Version : 1.0
#: Description : Install or update VirtualBox Extension pack
pkg_sit="http://download.virtualbox.org/virtualbox/"
ext_nam="Oracle VM VirtualBox Extension Pack"
pkg_ext="vbox-extpack"
#
which vboxmanage > /dev/null 2>&1 || exec echo "vboxmanage not found"
ver=$(vboxmanage -v)
pkg_nam="${ext_nam// /_}"
pkg_tgz="${pkg_nam}.tgz"
pkg_ver="${ver%%r*}"
pkg_blt="${ver##*r}"
pkg_url="${pkg_sit}${pkg_ver}/${pkg_nam}-${pkg_ver}-${pkg_blt}.${pkg_ext}"
# check if ExtensionPack for current VirtualBox version already install
N=$(vboxmanage list extpacks | grep -c -e "$pkg_ver" -e "$pkg_blt")
[ $N -ge 2 ] && exec echo "Extension Pack already installed"
# Deinstall older versions ExtensionPack if any
vboxmanage list extpacks | grep -q "$ext_nam" && {
oldver=$(vboxmanage list extpacks | awk 'BEGIN {ORS="r"} ; /Version:|Revision/ { print $2 }' | sed 's|r$||')
echo "- uninstalling $ext_nam $oldver"
vboxmanage extpack uninstall "$ext_nam"
}
# download VirtualBox Extension Pack
echo "- Downloading $pkg_url ..."
wget $pkg_url -O $pkg_tgz
# Install newer ExtensionPack version
if [ -f ./$pkg_tgz ] ; then
echo "- installing $ext_nam $ver"
vboxmanage extpack install $pkg_tgz
else
echo "No extension pack found"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment