Looks like all my scripts start with update something or end with something upgrade. lol!
It might not be necessary to update the VirtualBox Extension Pack. However I noticed that the files are different between versions. You can not install the Extension Pack if there is already one installed. You have to delete it first. This script 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
If the** vboxdrv** kernel module is not loaded (for some reason), updating the Extension Pack would work, but getting the VirtualBox version from vboxmanage -v output will fail because of the warning displayed. Appending | tail -1 to the command fixes the problem.
This script has been renamed VBoxExtensionPack and is included in the vmscripts package. You can install this package from my repo:
su -l
zypper ar [noparse]http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_11.4/[/noparse] PTA
zypper refresh
zypper in vmscripts
su -l
zypper ar [noparse]http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_12.1/[/noparse] PTA
zypper refresh
zypper in vmscripts
Here’s an updated VBoxExtensionPack for the latest OpenSuse Leap and Virtual Box 5.x version (i just set “cut -c -5” for “ver” and removed the “pkg_bit” lines):
pkg_sit="http://download.virtualbox.org/virtualbox/"
pkg_dwl="http://www.virtualbox.org/wiki/Downloads"
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 | cut -c -5)
pkg_nam="${ext_nam// /_}"
pkg_tgz="${pkg_nam}.tgz"
pkg_ver="${ver%%r*}"
pkg_url="${pkg_sit}${pkg_ver}/${pkg_nam}-${pkg_ver}.${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"
# download VirtualBox Extension Pack
echo "- Downloading $pkg_url ..."
wget $pkg_url -O $pkg_tgz
# Not Extension Pack found for this version, try latest version on the download page.
-s $pkg_tgz ] || {
rpm -qa | grep -q curl || exec echo "Please install curl"
p=$(echo $pkg_sit | sed 's|^.*//\(^/]*\).*|\1|')
pkg_url=$(curl $pkg_dwl | grep $p | sed -n "/$p/s|^.*\(${pkg_sit}${pkg_ver}.*${pkg_ext}\).*|\1|p" | sort -u)
wget $pkg_url -O $pkg_tgz
}
if -s $pkg_tgz ] ; then
# 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"
}
echo "- installing $ext_nam $ver"
VBoxManage extpack install $pkg_tgz
else
echo "No extension pack found"
fi
Thanks for this script. Unfortunately though, it didn’t work for me. To resolved my problem I had to manually locate, download, and install the extension pack.
I had extension pack 4.3.20r96996 and everything was fine; then an update to the VirtualBox software broke this and I needed to update the extension pack to extension pack 4.3.36-105129. The new extension pack wasn’t listed at virtualbox.org/wiki/Downloads so I tried your script to do my update.
The first issue I encountered when running the script was that the command vboxmanage was not found; I found that this command needed to be changed to VBoxManage as the case is sensitive, so I did this and the script ran.
The next issue was that the extension pack was not found. The script output follows;
linux:/home/michael # sh updateVboxExt.sh
- Downloading http://download.virtualbox.org/virtualbox/4.3.36_SUSE/Oracle_VM_VirtualBox_Extension_Pack-4.3.36_SUSE-105129.vbox-extpack ...
--2016-02-12 09:45:30-- http://download.virtualbox.org/virtualbox/4.3.36_SUSE/Oracle_VM_VirtualBox_Extension_Pack-4.3.36_SUSE-105129.vbox-extpack
Resolving download.virtualbox.org (download.virtualbox.org)... 23.215.61.81, 23.215.61.90
Connecting to download.virtualbox.org (download.virtualbox.org)|23.215.61.81|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2016-02-12 09:45:32 ERROR 404: Not Found.
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 276 100 276 0 0 910 0 --:--:-- --:--:-- --:--:-- 910
wget: missing URL
Usage: wget [OPTION]... ...
Try `wget --help' for more options.
No extension pack found
I did a little more digging about and found the extension I needed at the following location https://www.virtualbox.org/wiki/Download_Old_Builds_4_3 . The old extension was removed, and the new one installed using the VirtualBox Manager GUI, by going to File - Preferences - Extensions and using the ‘remove package’ and ‘add package’ buttons to update as necessary.