Created
December 20, 2012 17:42
-
-
Save seraphyn/4347126 to your computer and use it in GitHub Desktop.
Checks if the Extension Pack version matches the installed VirtualBox version and if not, delete the Extension Pack, downloads and installs the new one.
This file contains hidden or 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/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