2023-01-31 21:18:59 -08:00
|
|
|
{{- if ne .host.distro.family "windows" -}}
|
|
|
|
#!/usr/bin/env bash
|
2023-04-11 20:26:25 -07:00
|
|
|
# @file VirtualBox Extension Pack
|
|
|
|
# @brief Ensures the VirtualBox extension pack is installed.
|
|
|
|
# @description
|
|
|
|
# This script ensures the VirtualBox extension pack that corresponds with VirtualBox's version is properly installed.
|
2023-01-31 21:18:59 -08:00
|
|
|
|
|
|
|
{{ includeTemplate "universal/profile" }}
|
|
|
|
{{ includeTemplate "universal/logg" }}
|
|
|
|
|
2023-01-31 23:04:55 -08:00
|
|
|
### Run logic if VirtualBox is installed
|
2023-01-31 21:18:59 -08:00
|
|
|
if command -v VirtualBox > /dev/null; then
|
2023-02-01 14:30:02 -08:00
|
|
|
### Install VirtualBox extension pack if it is not installed already
|
2023-02-04 20:18:07 -08:00
|
|
|
if [ ! -d /usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack ]; then
|
2023-01-31 23:04:55 -08:00
|
|
|
logg info 'Acquiring VirtualBox version information'
|
|
|
|
VBOX_VERSION="$(VirtualBox --help | head -n 1 | cut -f 6 -d' ')"
|
|
|
|
VBOX_VERSION="${VBOX_VERSION//v}"
|
|
|
|
|
|
|
|
### Set up folders
|
2023-02-15 19:59:26 -08:00
|
|
|
sudo mkdir -p /usr/lib/virtualbox/ExtensionPacks
|
2023-01-31 23:04:55 -08:00
|
|
|
mkdir -p /tmp/vbox
|
2023-01-31 21:18:59 -08:00
|
|
|
cd /tmp/vbox
|
2023-01-31 23:04:55 -08:00
|
|
|
|
|
|
|
### Download extension pack
|
|
|
|
logg info 'Downloading VirtualBox extension pack'
|
|
|
|
curl -sSL https://download.virtualbox.org/virtualbox/$VBOX_VERSION/Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VERSION.vbox-extpack \
|
2023-01-31 21:18:59 -08:00
|
|
|
-o /tmp/vbox/Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VERSION.vbox-extpack
|
2023-01-31 23:04:55 -08:00
|
|
|
|
|
|
|
### Install extension pack
|
|
|
|
logg info 'Installing VirtualBox extension pack'
|
2023-02-15 19:57:35 -08:00
|
|
|
echo 'y' | sudo VBoxManage extpack install --replace /tmp/vbox/Oracle_VM_VirtualBox_Extension_Pack-$VBOX_VERSION.vbox-extpack
|
2023-01-31 23:04:55 -08:00
|
|
|
logg success 'Successfully installed VirtualBox extension pack'
|
2023-02-01 14:30:02 -08:00
|
|
|
else
|
|
|
|
logg info 'VirtualBox Extension pack is already installed'
|
|
|
|
fi
|
2023-01-31 21:18:59 -08:00
|
|
|
else
|
2023-02-01 14:30:02 -08:00
|
|
|
logg warn 'VirtualBox is not installed so VirtualBox Extension pack will not be installed'
|
2023-01-31 21:18:59 -08:00
|
|
|
fi
|
|
|
|
|
|
|
|
{{ end -}}
|