Skip to content

Instantly share code, notes, and snippets.

@xaedes
Last active July 16, 2020 15:38
Show Gist options
  • Save xaedes/85990cd1d1cd8c7a16cb251f4cffe1f0 to your computer and use it in GitHub Desktop.
Save xaedes/85990cd1d1cd8c7a16cb251f4cffe1f0 to your computer and use it in GitHub Desktop.
Vagrant: Ubuntu XFCE4/SLiM CMake C++ Boost Qt OpenGL OpenCV
# -*- mode: ruby -*-
# vi: set ft=ruby :
# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
# The most common configuration options are documented and commented below.
# For a complete reference, please see the online documentation at
# https://docs.vagrantup.com.
# Every Vagrant development environment requires a box. You can search for
# boxes at https://atlas.hashicorp.com/search.
config.vm.box = "ubuntu/xenial64"
# Disable automatic box update checking. If you disable this, then
# boxes will only be checked for updates when the user runs
# `vagrant box outdated`. This is not recommended.
# config.vm.box_check_update = false
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a private network, which allows host-only access to the machine
# using a specific IP.
config.vm.network "private_network", ip: "192.168.33.1"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
# config.vm.network "public_network"
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
config.vm.synced_folder "C:/Users/xaedes/Dropbox", "/home/ubuntu/dropbox"
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
#
config.vm.provider "virtualbox" do |vb|
# Display the VirtualBox GUI when booting the machine
vb.gui = true
# Customize the amount of memory on the VM:
vb.memory = "1024"
end
#
# View the documentation for the provider you are using for more
# information on available options.
# Define a Vagrant Push strategy for pushing to Atlas. Other push strategies
# such as FTP and Heroku are also available. See the documentation at
# https://docs.vagrantup.com/v2/push/atlas.html for more information.
# config.push.define "atlas" do |push|
# push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME"
# end
# Enable provisioning with a shell script. Additional provisioners such as
# Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the
# documentation for more information about their specific syntax and use.
config.vm.provision "system", type: "shell", inline: <<-SHELL
# set passwd
sudo echo ubuntu:ubuntu | chpasswd
# german keyboard layout
echo setxkbmap -layout de >> /home/ubuntu/.profile
# gui
sudo apt-get update
sudo apt-get install -y xfce4 virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
sudo apt-get install -y slim
# enable auto_login
sudo sed -i -r 's/^#?auto_login.*$/auto_login yes/' /etc/slim.conf
sudo sed -i -r 's/^#?focus_password.*$/focus_password yes/' /etc/slim.conf
sudo sed -i -r 's/^#?default_user.*$/default_user ubuntu/' /etc/slim.conf
# sudo sed -i 's/allowed_users=.*$/allowed_users=anybody/' /etc/X11/Xwrapper.config
# echo "done"
SHELL
config.vm.provision "update", type: "shell", inline: <<-SHELL
sudo apt-get update
sudo apt-get -y upgrade
SHELL
# config.vm.provision "octave", type: "shell", inline: <<-SHELL
# sudo apt-get install -y octave
# SHELL
config.vm.provision "dev", type: "shell", inline: <<-SHELL
sudo apt-get update
# dev tools
sudo apt-get install -y git cmake htop binutils build-essential pkg-config
# for compiling qt stuff
sudo apt-get install -y qt5-default libqt4-opengl-dev libqt5opengl5-dev
# for compiling boost stuff
sudo apt-get install -y libboost-all-dev
# for compiling opengl stuff
sudo apt-get install -y freeglut3 freeglut3-dev libgl1-mesa-dev libglew-dev libglu1-mesa-dev mesa-common-dev libxmu-dev libxi-dev
echo "done"
SHELL
config.vm.provision "opencv", type: "shell", inline: <<-SHELL
sudo apt-get update
# install opencv from apt
# sudo apt-get install -y libopencv-dev libopencv-core-dev libopencv-contrib-dev
# install opencv from source
# http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/
sudo apt-get install -y libjpeg8-dev libtiff5-dev libjasper-dev libpng12-dev
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install -y libxvidcore-dev libx264-dev
sudo apt-get install -y libgtk-3-dev
sudo apt-get install -y libatlas-base-dev gfortran
sudo apt-get install -y unzip
cd ~
wget -q -O opencv.zip https://github.com/Itseez/opencv/archive/3.2.0.zip
wget -q -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.2.0.zip
unzip opencv.zip
unzip opencv_contrib.zip
cd ~/opencv-3.2.0/
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.2.0/modules \
-D BUILD_EXAMPLES=ON ..
make -j2
sudo make install
sudo ldconfig
SHELL
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment