diff --git a/build/armbian/Vagrantfile b/build/armbian/Vagrantfile new file mode 100644 index 00000000..cce68c3f --- /dev/null +++ b/build/armbian/Vagrantfile @@ -0,0 +1,43 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +# +# Vagrantfile for the NCP Debian VM +# +# Instructions: vagrant up; vagrant ssh +# +# Notes: User/Pass is ubnt/ubnt. +# $HOME is accessible as /external. CWD is accessible as /cwd +# + +Vagrant.configure("2") do |config| + + vmname = "NCP Ubuntu VM" + config.vm.box = "generic/ubuntu2204" + config.vm.box_check_update = true + config.vm.hostname = "ncp-vm" + config.vm.define "ncp-vm" + config.vm.provider :libvirt do |libvirt| + libvirt.default_prefix = "" + libvirt.cpus = 6 + libvirt.memory = 4096 + end + + config.vm.synced_folder '.', '/vagrant', disabled: true + + $script = <<-SHELL + sudo su + set -ex + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends git ca-certificates + cd /tmp/nextcloudpi + ./build/build-SD-armbian.sh "${BOARD_ID?}" "${BOARD_NAME?}" + mv /tmp/nextcloudpi/armbian/output/*.img /tmp/ncp-out/ + SHELL + + # Provision the VM + config.vm.provision "shell", inline: $script, env: {"BOARD_ID" => ENV['BOARD_ID'], "BOARD_NAME" => ENV['BOARD_NAME']} + config.vm.synced_folder ".", "/vagrant", disabled: true + config.vm.synced_folder "../..", "/tmp/nextcloudpi", type: "rsync", rsync_exclude: ["armbian", ".git", ".venv", "cache", "raspbian_root", "output", "tmp", ".idea"] + config.vm.synced_folder "./output", "/tmp/ncp-out", type: "sshfs" + +end diff --git a/build/build-SD-armbian-vagrant.sh b/build/build-SD-armbian-vagrant.sh new file mode 100755 index 00000000..86243fe0 --- /dev/null +++ b/build/build-SD-armbian-vagrant.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +# Batch creation of NextCloudPi Armbian based images +# +# Copyleft 2023 by Tobias Knöppler +# GPL licensed (see end of file) * Use at your own risk! +# +# Usage: sudo ./build-SD-armbian-vagrant.sh [] +# + +[[ "$UID" == 0 ]] || { + echo "This script needs to be run as root. Try sudo" + exit 1 +} + +set -ex +export BOARD_ID="${1?}" +export BOARD_NAME="${2:-$1}" +vagrant plugin list | grep vagrant-libvirt || vagrant plugin install vagrant-libvirt +vagrant plugin list | grep vagrant-sshfs || vagrant plugin install vagrant-sshfs +export VAGRANT_DEFAULT_PROVIDER=libvirt + +vagrant box list | grep generic/ubuntu2204 || vagrant box add --provider libvirt generic/ubuntu2204 + +cd "$(dirname "$0")/armbian" +mkdir -p "../../output" +trap 'echo "Cleaning up vagrant..."; vagrant halt; vagrant destroy -f' EXIT +BOARD_ID="$BOARD_ID" BOARD_NAME="$BOARD_NAME" vagrant up --provider=libvirt + +exit 0