Skip to content

Instantly share code, notes, and snippets.

@brahmlower
Last active November 8, 2017 06:52
Show Gist options
  • Save brahmlower/b7e193fc3861e964c367 to your computer and use it in GitHub Desktop.
Save brahmlower/b7e193fc3861e964c367 to your computer and use it in GitHub Desktop.
This is a script to install VirtualBox and phpVirtualBox on a headless Debian 8 machine.
#!/bin/bash
# Author: Brahm Lower
# Name: phpVirtualBox Debian 8 Install Script
# Source: https://gist.github.com/bplower/b7e193fc3861e964c367/
# Prerequisite Packages:
# bash, openssl, cat, grep, echo, wget, apt-key, apt-get, useradd, usermod, passwd, mv, cp, sed, systemctl
# Installed Packages:
# build-essential, dkms, unzip, apache2, php5, php5-mysql, libapache2-mod-php5, php-soap, virtualbox-5.0
# Description:
# This is a script to install VirtualBox and php VirtualBox on a headless Debian 8 machine.
# To make installation easier, curl the raw file content from github directly into bash
# curl -s https://gist.githubusercontent.com/bplower/b7e193fc3861e964c367/raw/ | bash
#
# Set up variables
#
VB_USERNAME=vbuser
VB_PASSWORD=`openssl rand -base64 16`
VB_EXTPACK_URL="http://download.virtualbox.org/virtualbox/4.3.36/Oracle_VM_VirtualBox_Extension_Pack-4.3.36-105129.vbox-extpack"
VB_EXTPACK_NAME="Oracle_VM_VirtualBox_Extension_Pack-4.3.36-105129.vbox-extpack"
VB_PHPVBZIP_URL="http://sourceforge.net/projects/phpvirtualbox/files/phpvirtualbox-4.3-3.zip"
VB_PHPVBZIP_NAME="phpvirtualbox.zip"
VB_PACKAGES="build-essential dkms unzip apache2 php5 php5-mysql libapache2-mod-php5 php-soap virtualbox-4.3"
#
# Add VirtualBox repository
#
cat /etc/apt/sources.list | grep virtualbox
if [ $? -eq 1 ]
then
echo "deb http://download.virtualbox.org/virtualbox/debian jessie contrib" >> /etc/apt/sources.list
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | apt-key add -
fi
#
# Install OS packages
#
apt-get -qq update
apt-get -y -qq upgrade
apt-get -y -qq install $VB_PACKAGES || { echo '[ERROR] Package installation failed! Exiting!' ; exit 1; }
#
# Prepare the phpvirtualbox server user
#
cat /etc/passwd | grep $VB_USERNAME
if [ $? -eq 1 ]
then
useradd -m $VB_USERNAME
echo -e "$VB_PASSWORD\n$VB_PASSWORD" | passwd $VB_USERNAME
echo -e "Username: $VB_USERNAME\nPassword: $VB_PASSWORD"
usermod -aG vboxusers $VB_USERNAME
fi
#
# Wget the extension pack and phpvirtualbox resources
#
wget -q $VB_EXTPACK_URL
wget -q $VB_PHPVBZIP_URL -O $VB_PHPVBZIP_NAME
#
# Configure the virtualBox extension
#
vboxmanage extpack install --replace $VB_EXTPACK_NAME
if [ $? -eq 1 ]
then
echo "There was an error installing the extion pack: $VB_EXTPACK_NAME"
exit 1
fi
#
# Set up the phpvirtualbox web files
#
unzip -q $VB_PHPVBZIP_NAME
mv phpvirtualbox-4.3-3 /var/www/html/phpvirtualbox
cp /var/www/html/phpvirtualbox/config.php-example /var/www/html/phpvirtualbox/config.php
sed -i "12s/'vbox'/\'$VB_USERNAME\'/" /var/www/html/phpvirtualbox/config.php
sed -i "13s/'pass'/\'$VB_PASSWORD\'/" /var/www/html/phpvirtualbox/config.php
echo "VBOXWEB_USER=$VB_USERNAME" > /etc/default/virtualbox
#
# Starts the phpvirtualbox service
#
systemctl restart vboxweb-service
echo "Done!"
@dodoaska
Copy link

about line 18: VB_PASSWORD=openssl rand -base64 16
what should i do?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment