forked from MariusCC/chef-bcpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvirtualbox_env.sh
37 lines (29 loc) · 1008 Bytes
/
virtualbox_env.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
# Source this file at the top of your script when needing VBoxManage
# e.g.,
# source ./virtualbox_env.sh
if [[ -z "$VBM" ]]; then
if ! command -v VBoxManage >& /dev/null; then
echo "VBoxManage not found!" >&2
echo " Please ensure VirtualBox is installed and VBoxManage is on your system PATH." >&2
exit 1
fi
function check_version {
local MIN_MAJOR=4
local MIN_MINOR=3
local IFS='.'
local version="$(VBoxManage --version)"
local version_array
read -a version_array <<< "$version"
if ! [[ "${version_array[0]}" -ge "$MIN_MAJOR" && \
"${version_array[1]}" -ge "$MIN_MINOR" ]]
then
echo "ERROR: VirtualBox $version is less than $MIN_MAJOR.$MIN_MINOR.x!" >&2
echo " Only VirtualBox >= $MIN_MAJOR.$MIN_MINOR.x is officially supported." >&2
exit 1
fi
}
check_version
unset -f check_version
export VBM=VBoxManage
fi