Skip to content

Instantly share code, notes, and snippets.

@Starefossen
Last active March 19, 2019 12:18
Show Gist options
  • Save Starefossen/9353638 to your computer and use it in GitHub Desktop.
Save Starefossen/9353638 to your computer and use it in GitHub Desktop.
Run Octave using Vagrant

Install

  1. Download and install Vagrant
  2. Download and install Virtual Box
  3. Download the file bellow; name must be "Vagrantfile"

Run

Go to the folder where your "Vagrantfile" in your terminal/shell. Run the following commands:

vagrant up
vagrant ssh
octave
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Boostrap Script
$script = <<SCRIPT
# Update & Install
apt-get update
apt-get install -y octave gnuplot
echo "cd /vagrant" >> /home/vagrant/.bashrc
SCRIPT
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "precise32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://files.vagrantup.com/precise32.box"
# A Vagrant plugin that helps you reduce the amount of coffee you drink while
# waiting for boxes to be provisioned by sharing a common package cache among
# similiar VM instances. Kinda like vagrant-apt_cache or this magical snippet
# but targetting multiple package managers and Linux distros.
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.auto_detect = true
# For VirtualBox, we want to enable NFS for shared folders
# config.cache.enable_nfs = true
end
# The shell provisioner allows you to upload and execute a script as the root
# user within the guest machine.
config.vm.provision :shell, :inline => $script
# 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|
vb.customize ["modifyvm", :id, "--memory", "256", "--cpus", "2"]
end
end
@dpsutton
Copy link

dpsutton commented Sep 9, 2014

Hi. this looks perfect. Can i ask you two questions though? Why did you go the 32bit route? And also, how does this handle plots. For class I must generate some plots and I was wondering how this handled generating plots and windows.

@zanders3
Copy link

zanders3 commented Mar 1, 2017

Great script! I suggest adding config.ssh.forward_x11 = true to enable X11 forwarding which allows GNU Plot to work correctly

@TiBag93
Copy link

TiBag93 commented Mar 19, 2019

Hi,

I just tried your Vagrantfile. They changed their url to:
config.vm.box_url = "https://vagrantcloud.com/hashicorp/precise64" // I'm using 64 bit

Have fun using octave :)

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