Skip to content

Commit d1b69bb

Browse files
committed
Choose compatible Virtualbox version from phpvirtualbox version in installer.
1 parent 80e51e3 commit d1b69bb

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

packaging/install-scripts/install.bash

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ PHPVBOX_INSTALL_DIR=${PHPVBOX_INSTALL_DIR:='/usr/share/phpvirtualbox'}
2828
PHPVBOX_VERSION=${PHPVBOX_VERSION:='latest'}
2929
APT=${APT:='apt-get -y'}
3030
APT_KEY=${APT_KEY:='apt-key'}
31-
VBOX_VER=${VBOX_VER:='6.1'}
3231
ACCEPT_ORACLE_EXTPACK_LICENSE=${ACCEPT_ORACLE_EXTPACK_LICENSE:='n'}
3332
VBOX_USER=${VBOX_USER:='vbox'}
3433
VBOX_GROUP=${VBOX_GROUP:='vboxusers'}
@@ -42,6 +41,8 @@ AUTOSTART_CONF=${AUTOSTART_CONF:='/etc/vbox/autostart.conf'}
4241
WAIT_FOR_STOP=10s
4342

4443

44+
45+
4546
for i in "$@"
4647
do
4748
case $i in
@@ -100,11 +101,29 @@ fi
100101
########################
101102

102103
if [ "${INSTALL_VBOX}" = true ]; then
104+
# Virtualbox Version needs to match PHPVirtualBox version
105+
# unless pulling from "develop" or "master"
106+
if [ "${PHPVBOX_VERSION}" == 'latest' ]; then
107+
RELEASE_TAG_URL=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/phpvirtualbox/phpvirtualbox/releases/latest)
108+
PHPVBOX_VERSION=$(echo $RELEASE_TAG_URL | awk -F/ '{print $8}')
109+
fi
110+
if [ "${PHPVBOX_VERSION}" == "development" ]; then
111+
112+
VIRTUALBOX_VERSION=$(wget -O- https://raw.githubusercontent.com/phpvirtualbox/phpvirtualbox/develop/endpoints/lib/config.php | grep "define('PHPVBOX_VER'" | sed -n "s/^.*\([0-9]\+\.[0-9]\+\).*$/\1/p")
113+
else
114+
VIRTUALBOX_VERSION=`echo "$PHPVBOX_VERSION" | sed -n "s/^\([0-9]\+\.[0-9]\+\).*$/\1/p"`
115+
fi
116+
117+
if [[ $VIRTUALBOX_VERSION =~ ^[0-9]+.[0-9]+$ ]]; then
103118
cat << EOT
104-
###########################
105-
## INSTALLING VIRTUALBOX ##
106-
###########################
119+
###############################
120+
## INSTALLING VIRTUALBOX $VIRTUALBOX_VERSION ##
121+
###############################
107122
EOT
123+
else
124+
echo "ERROR: UNKNOWN VIRTUALBOX VERSION: $VIRTUALBOX_VERSION"
125+
exit -1
126+
fi
108127
set -u
109128
set -e
110129
set -o pipefail
@@ -127,7 +146,7 @@ EOT
127146
sleep "$WAIT_FOR_STOP"
128147

129148
echo ">>>> Installing VirtualBox on non-x11 system <<<<"
130-
${APT} install --reinstall virtualbox-${VBOX_VER} --no-install-recommends
149+
${APT} install --reinstall virtualbox-${VIRTUALBOX_VERSION} --no-install-recommends
131150

132151
echo ">>>> Adding vbox user <<<<"
133152
adduser --disabled-password --gecos "VirtualBox" vbox || true

0 commit comments

Comments
 (0)