Skip to content

Instantly share code, notes, and snippets.

@rkawajiri
Last active April 20, 2019 23:28
Show Gist options
  • Save rkawajiri/8ff18a810ef79f48dacebb9b9680fff7 to your computer and use it in GitHub Desktop.
Save rkawajiri/8ff18a810ef79f48dacebb9b9680fff7 to your computer and use it in GitHub Desktop.
Vagrantfile for daily development

Prerequisites

$ vagrant plugin install vagrant-vbguest
$ vagrant plugin install vagrant-disksize

Get or update files.

$ curl https://gist.githubusercontent.com/rkawajiri/8ff18a810ef79f48dacebb9b9680fff7/raw/update_vagrant.bash > update_vagrant.bash
$ chmod +x update_vagrant.bash
$ ./update_vagrant.bash

Apply files

$ vagrant up
or
$ vagrant provision

If necessary,

$ vagrant vbguest

Trouble shooting https://qiita.com/oieioi/items/d45d30d2622eca095a67

#! /usr/bin/env bash
set -eux
# apt base
apt-get update
apt-get upgrade -y
apt-get install -y \
emacs \
tmux
cat <<EOF | tee /home/vagrant/.tmux.conf
# prefix key
unbind C-b
set-option -g prefix C-t
EOF
chown vagrant:vagrant /home/vagrant/.tmux.conf
# RealSense
apt-key adv --keyserver keys.gnupg.net --recv-key C8B3A55A6F3EFCDE || apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key C8B3A55A6F3EFCDE
add-apt-repository -u "deb http://realsense-hw-public.s3.amazonaws.com/Debian/apt-repo $(lsb_release -cs) main"
apt-get install -y --allow-unauthenticated \
librealsense2-dkms \
librealsense2-utils \
libusb-1.0-0-dev \
build-essential \
cmake
rm -rf stlink
git clone https://github.com/texane/stlink.git
cd stlink
make release
cd build/Release
make install
udevadm control --reload-rules
udevadm trigger
cd
# USB Sereal
cat - << 'EOD' | tee /etc/udev/rules.d/50-usb-serial.rules
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6014", GROUP="dialout", MODE="0660"
SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", GROUP="dialout", MODE="0660"
EOD
udevadm control --reload-rules
usermod -aG dialout vagrant
# docker and docker-compose
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository -y \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install -y --no-install-recommends \
docker-ce
usermod -aG docker vagrant
systemctl enable docker
curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
# apt from dockerfile
perl -pi.bak -e 's|http://archive\.ubuntu\.com/ubuntu/|mirror://mirrors.ubuntu.com/mirrors.txt|g' /etc/apt/sources.listp
apt-get update
apt-get install -y --no-install-recommends \
apt-transport-https \
build-essential \
ca-certificates \
chrpath \
clang-format \
cpio \
curl \
diffstat \
file \
gawk \
gcc-multilib \
gdisk \
git-core \
gosu \
libsqlite3-dev \
libssl-dev \
locales \
openssh-client \
ovmf \
pkg-config \
python3 \
qemu \
software-properties-common \
subversion \
texinfo \
unzip \
wget \
xz-utils
# Rust from Dockerfile
cat <<EOF | tee /etc/profile.d/rust-path.sh
export RUSTUP_HOME=/usr/local/rustup
export CARGO_HOME=/usr/local/cargo
export CARGO_TARGET_DIR=/usr/local/cargo/target
export PATH=/usr/local/cargo/bin:$PATH
EOF
source /etc/profile.d/rust-path.sh
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=1.32.0
chmod -R a+w $RUSTUP_HOME $CARGO_HOME
rustup target add thumbv7em-none-eabihf --toolchain=1.32.0
rustup component add rustfmt clippy
# GCC
add-apt-repository ppa:team-gcc-arm-embedded/ppa
apt-get update
apt-get install -y \
gcc-arm-embedded \
openocd \
picocom \
screen
# mo
curl -sSL https://git.io/get-mo -o /usr/local/bin/mo
chmod +x /usr/local/bin/mo
# gcloud sdk
export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)"
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
apt-get update
apt-get install -y \
google-cloud-sdk
# Ubuntu Desktop
apt-get install -y ubuntu-desktop
#! /usr/bin/env bash
set -eux
curl https://gist.githubusercontent.com/rkawajiri/8ff18a810ef79f48dacebb9b9680fff7/raw/Vagrantfile > Vagrantfile
curl https://gist.githubusercontent.com/rkawajiri/8ff18a810ef79f48dacebb9b9680fff7/raw/provision.bash > provision.bash
# -*- 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://vagrantcloud.com/search.
config.vm.box = "ubuntu/bionic64"
config.vm.provision :shell, path: "provision.bash"
# 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.
# NOTE: This will enable public access to the opened port
# config.vm.network "forwarded_port", guest: 80, host: 8080
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine and only allow access
# via 127.0.0.1 to disable public access
# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"
# 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.10"
# 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 "../data", "/vagrant_data"
config.vm.synced_folder ".", "/vagrant", type: "rsync",
rsync__auto: true,
rsync__verbose: true,
rsync__exclude: ["**/.DS_Store"]
config.disksize.size = '100GB'
# 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|
# Customize the amount of memory on the VM:
vb.memory = 4098
vb.cpus = 3
# Display the VirtualBox GUI when booting the machine
vb.gui = false
vb.customize ["modifyvm", :id,
"--clipboard", "bidirectional",
"--draganddrop", "bidirectional",
"--vram", "256",
"--ioapic", "on",
"--accelerate3d", "on",
"--accelerate2dvideo", "on",
]
# USB
vb.customize ["modifyvm", :id,
"--usb", "on",
"--usbxhci", "on",
]
# vbguest
config.vbguest.auto_update = false
end
#
# View the documentation for the provider you are using for more
# information on available options.
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment