Vagrant: Updates for MacOS & Packer >1.6.0 (#1657)

This commit is contained in:
geco91
2020-10-13 22:25:35 +02:00
committed by rootzoll
parent 6fd28477b3
commit 4e0b4f1675
6 changed files with 93 additions and 75 deletions

10
Vagrantfile vendored
View File

@@ -1,24 +1,20 @@
# -*- mode: ruby -*- # -*- mode: ruby -*-
# vi: set ft=ruby : # vi: set ft=ruby :
# in order to attach a secondary disk we need to enable vagrant disk experimental feature
if ENV['VAGRANT_EXPERIMENTAL'] != 'disks'
ENV['VAGRANT_EXPERIMENTAL'] = 'disks'
end
Vagrant.configure('2') do |config| Vagrant.configure('2') do |config|
config.vm.box = 'raspiblitz' config.vm.box = 'raspiblitz'
config.vm.network "private_network", type: "dhcp"
config.ssh.username = 'admin' config.ssh.username = 'admin'
config.ssh.password = 'raspiblitz' config.ssh.password = 'raspiblitz'
config.ssh.insert_key = true config.ssh.insert_key = true
config.vm.disk :disk, size: '16GB', primary: true config.vm.disk :disk, size: '16GB', primary: true
config.vm.disk :disk, size: '500GB', name: 'external_disk'
config.vm.provider 'virtualbox' do |vb, override| config.vm.provider 'virtualbox' do |vb, override|
vb.memory = 2048 vb.memory = 2048
vb.customize ['modifyvm', :id, '--usbxhci', 'on']
end end
config.vm.provision 'shell', config.vm.provision 'shell',

View File

@@ -6,7 +6,13 @@ This guide was tested on vagrant
This feature is very experimental and not supported. This feature is very experimental and not supported.
In order to run raspiblitz on `vagrant` you need `packer` to build the base box. In order to run raspiblitz on `vagrant` you need `packer` (>=1.6.0) to build the base box.
On MacOS you need to install:
1. brew: `/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"`
2. packer: `brew install packer`
3. vagrant: `brew install vagrant`
4. virtualbox: `brew cask install virtualbox` (maybe re-run after you changed the requested secruity permission to be successfull)
```sha ```sha
cd alternative.platforms/amd64/packer cd alternative.platforms/amd64/packer
@@ -18,6 +24,12 @@ cd ../../..
With the base box built, you can start a development environment with `vagrant up` and login with `vagrant ssh`. With the base box built, you can start a development environment with `vagrant up` and login with `vagrant ssh`.
You will need to connect a virtual data drive to the RaspiBlitzVM ... todo so:
- make sure VM is stopped: use command `off` when within VM or from outside `vagrant halt`
- no open the VirtualBox Manager GUI and use `change` on the RaspiBlitzVM
- Go to the `mass storage` section and add a second disc as `primary slave` to the already existing controller
- create a new dynamic VDI with around 900GB .. choose as storage path for the VDI an external drive if you dont have that much space on your laptop.
- now start the VM again with `vagrant up` and `vagrangt ssh` to run thru the setup process
**Note** **Note**

View File

@@ -1,14 +1,6 @@
{ {
"variables": {
"iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.5.0-amd64-netinst.iso",
"iso_checksum_type": "sha256",
"iso_checksum": "93863e17ac24eeaa347dfb91dddac654f214c189e0379d7c28664a306e0301e7",
"branch": "dev",
"github_user": "rootzoll"
},
"builders": [ "builders": [
{ {
"type": "virtualbox-iso",
"boot_command": [ "boot_command": [
"<esc><wait>", "<esc><wait>",
"auto ", "auto ",
@@ -17,44 +9,64 @@
], ],
"boot_wait": "5s", "boot_wait": "5s",
"disk_size": "16384", "disk_size": "16384",
"headless": false,
"guest_os_type": "Debian_64", "guest_os_type": "Debian_64",
"headless": false,
"http_directory": "http", "http_directory": "http",
"iso_checksum_type": "{{ user `iso_checksum_type` }}", "iso_checksum": "{{ user `iso_checksum_type` }}:{{ user `iso_checksum` }}",
"iso_checksum": "{{ user `iso_checksum` }}",
"iso_url": "{{ user `iso_url` }}", "iso_url": "{{ user `iso_url` }}",
"shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now", "shutdown_command": "echo 'vagrant'|sudo -S shutdown -P now",
"ssh_password": "vagrant", "ssh_password": "vagrant",
"ssh_port": 22, "ssh_port": 22,
"ssh_username": "vagrant",
"ssh_timeout": "30m", "ssh_timeout": "30m",
"vm_name": "raspiblitz-amd64", "ssh_username": "vagrant",
"type": "virtualbox-iso",
"vboxmanage": [ "vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "1024"], [
["modifyvm", "{{.Name}}", "--cpus", "1"] "modifyvm",
"{{.Name}}",
"--memory",
"1024"
],
[
"modifyvm",
"{{.Name}}",
"--cpus",
"1"
] ]
],
"vm_name": "raspiblitz-amd64"
}
],
"post-processors": [
{
"compression_level": "8",
"output": "output/raspiblitz.box",
"type": "vagrant"
} }
], ],
"provisioners": [ "provisioners": [
{ {
"type": "shell", "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/init.sh", "script": "scripts/init.sh",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'" "type": "shell"
}, },
{ {
"type": "shell", "execute_command": "echo 'yes' | {{.Vars}} bash '{{.Path}}' {{ user `branch` }} {{ user `github_user` }} /dev/sda1 false false",
"script": "../../../build_sdcard.sh", "script": "../../../build_sdcard.sh",
"execute_command": "echo 'yes' | {{.Vars}} bash '{{.Path}}' {{ user `branch` }} {{ user `github_user` }} /dev/sda1 false false" "type": "shell"
}, },
{ {
"type": "shell", "execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'",
"script": "scripts/cleanup.sh", "script": "scripts/cleanup.sh",
"execute_command": "echo 'vagrant' | {{.Vars}} sudo -S -E bash '{{.Path}}'" "type": "shell"
} }
], ],
"post-processors": [{ "variables": {
"type": "vagrant", "branch": "dev",
"compression_level": "8", "github_user": "rootzoll",
"output": "output/raspiblitz.box" "iso_checksum": "2af8f43d4a7ab852151a7f630ba596572213e17d3579400b5648eba4cc974ed0",
}] "iso_checksum_type": "sha256",
"iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-10.6.0-amd64-netinst.iso"
}
} }

View File

@@ -4,14 +4,6 @@ set -e
echo "************* Vagrant provisioning ********************" echo "************* Vagrant provisioning ********************"
if ! [ -e /dev/sdb1 ]; then
echo 'Data drive partitioning'
echo 'type=83' | sudo sfdisk /dev/sdb
fi
echo 'linking development files' echo 'linking development files'
source_dir=/vagrant/home.admin source_dir=/vagrant/home.admin
dest_dir=$HOME dest_dir=$HOME

View File

@@ -28,9 +28,14 @@ esac
if [ "${setupStep}" = "100" ]; then if [ "${setupStep}" = "100" ]; then
# make sure services are not running # make sure services are not running
echo "stopping services ..." echo "stopping services ..."
sudo systemctl stop background
sudo systemctl stop lnd sudo systemctl stop lnd
sudo systemctl stop bitcoind sudo systemctl stop bitcoind
sudo cp -f /mnt/hdd/bitcoin/bitcoin.conf /home/admin/assets/bitcoin.conf sudo cp -f /mnt/hdd/bitcoin/bitcoin.conf /home/admin/assets/bitcoin.conf
else
# make sure bitcoind is not running
sudo systemctl stop background <2 /dev/null
sudo systemctl stop bitcoind <2 /dev/null
fi fi
# check if old blockchain data exists # check if old blockchain data exists

View File

@@ -81,7 +81,8 @@ if [ "$1" = "status" ]; then
# find the HDD (biggest single partition) # find the HDD (biggest single partition)
hdd="" hdd=""
sizeDataPartition=0 sizeDataPartition=0
OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1) OSPartition=$(sudo df /usr | grep dev | cut -d " " -f 1 | sed "s/\/dev\///g")
#echo "# OSPartition(${OSPartition})"
lsblk -o NAME,SIZE -b | grep -P "[s|v]d[a-z][0-9]?" > .lsblk.tmp lsblk -o NAME,SIZE -b | grep -P "[s|v]d[a-z][0-9]?" > .lsblk.tmp
while read line; do while read line; do
@@ -104,8 +105,8 @@ if [ "$1" = "status" ]; then
testpartitioncount=$((testpartitioncount-1)) testpartitioncount=$((testpartitioncount-1))
if [ $testpartitioncount -gt 0 ]; then if [ $testpartitioncount -gt 0 ]; then
# if a partition was found - make sure to skip OS partition # if a partition was found - make sure to skip OS partition & if <=32gb
if [ "$testpartition" != "$OSPartition" ]; then if [ "$testpartition" != "$OSPartition" ] && [ ${testsize} -gt 32900000000 ]; then
# make sure to use the biggest # make sure to use the biggest
if [ ${testsize} -gt ${sizeDataPartition} ]; then if [ ${testsize} -gt ${sizeDataPartition} ]; then