Update VirtualBox-4.0 Extension Pack.

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

http://img21.imageshack.us/img21/3056/virtualboxext.th.png](http://img809.imageshack.us/img809/3056/virtualboxext.png)

Thanks!
This worked great for me - VirtualBox should include it as an option in their installer.

Cool…!! I shall give this a go when I get in tonight :slight_smile:

Thanks please_try_again

@please_try_again

Thanks so much. This works great

Revision numbers didn’t match with version 4.0-4.0.10:


# rpm -qa | grep VirtualBox
VirtualBox-4.0-4.0.10_72479_openSUSE114-1.x86_64

# vboxmanage list extpacks
Extension Packs: 1
Pack no. 0:   Oracle VM VirtualBox Extension Pack
Version:      4.0.10
Revision:     72436
Description:  USB 2.0 Host Controller, VirtualBox RDP, PXE ROM with E1000 support.
VRDE Module:  VBoxVRDP
Usable:       true 
Why unusable:

So I modified the script to also parse VirtualBox download page. Here’s the new version (Don’t use the previous version!):

#! /bin/bash
#
#: Title       : updateVboxExt
#: Date Created: Fri May 13 13:54:26 PDT 2011 
#: Last Edit   : Tue Jun 28 09:42:29 PDT 2011 
#: Author      : please_try_again 
#: Version     : 1.1
#: Description : Install or update VirtualBox Extension pack

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)

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"

# 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

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.

The patch below illustrates this change :

--- updateVboxExt.orig      2011-07-14 00:01:19.918858508 -0700
+++ updateVboxExt   2011-07-13 23:56:52.028762173 -0700
@@ -14,7 +14,7 @@
 #
 
 which vboxmanage > /dev/null 2>&1 || exec echo "vboxmanage not found"
-ver=$(vboxmanage -v)
+ver=$(vboxmanage -v | tail -1)
 
 pkg_nam="${ext_nam// /_}"
 pkg_tgz="${pkg_nam}.tgz"

You can apply the change either by using the patch or by editing the file manually, or copy/paste the patched version (1.2) below:

#! /bin/bash
#
#: Title       : updateVboxExt
#: Date Created: Fri May 13 13:54:26 PDT 2011 
#: Last Edit   : Thu Jul 14 00:08:43 PDT 2011
#: Author      : please_try_again 
#: Version     : 1.2
#: Description : Install or update VirtualBox Extension pack

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 | tail -1)

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"

# 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

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

Other scripts in this package include:

Also available in the 12.1 repo:

su -l
zypper ar [noparse]http://download.opensuse.org/repositories/home:/please_try_again/openSUSE_12.1/[/noparse]  PTA
zypper refresh
zypper in vmscripts

I made this script compatible with the OSE version of VirtualBox by replacing vboxmanage (which exists only in the Oracle version) with VBoxManage (which exists in both the PUEL and the OSE version). (See this post: http://forums.opensuse.org/english/get-technical-help-here/virtualization/477126-how-do-you-install-extension-pack-3.html#post2478003 ).

Here’s the new code:

#! /bin/bash
#
#: Title       : VBoxExtensionPack
#: Date Created: Fri May 13 13:54:26 PDT 2011 
#: Last Edit   : Sat Aug  4 01:39:53 PDT 2012
#: Author      : please_try_again 
#: Version     : 1.3
#: Description : Install or update VirtualBox Extension pack

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 | tail -1)

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"

# 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

I also updated this script in the package vmscripts (see post above) - among other changes.

Hi please_try_again and thanks for you scripts!

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.

Best Regards
Michael