Switch from Docker to vagrant

This commit is contained in:
Micah Lee 2021-06-28 19:27:49 -07:00
parent c6bb676ce2
commit c25220a767
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
5 changed files with 35 additions and 49 deletions

View file

@ -1 +1,2 @@
vm
.vagrant

View file

@ -1,13 +1,12 @@
# Build the Dangerzone VM for running podman
## Build the podman container storage (with vagrant)
## Build the ISO
You need vagrant: `brew install vagrant`
## Build the ISO image (with docker)
```sh
docker run -v $(pwd):/build alpine:latest /build/build-iso.sh
vagrant up
vagrant ssh -- /vagrant/build-iso.sh
```
## Run the VM
@ -21,3 +20,5 @@ You can ssh in as the unprivileged user like this:
```sh
ssh -i ./ssh-key/id_ed25519 -o StrictHostKeyChecking=no user@192.168.65.3
```
(doesn't work yet)

View file

@ -4,7 +4,7 @@
Vagrant.configure("2") do |config|
config.vm.box = "generic/alpine313"
config.vm.synced_folder "../../dangerzone-converter", "/opt/dangerzone-converter"
config.vm.synced_folder ".", "/opt/build"
config.vm.synced_folder ".", "/vagrant"
config.vm.provision "shell", inline: <<-SHELL
apk update
apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso squashfs-tools sudo

View file

@ -1,60 +1,48 @@
#!/bin/sh
# Following: https://wiki.alpinelinux.org/wiki/How_to_make_a_custom_ISO_image_with_mkimage
cd ~/
# Install dependencies
apk update
apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso squashfs-tools sudo
apk add mtools dosfstools grub-efi
apk add p7zip
# Create a new user
adduser build -D -G abuild
echo "%abuild ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/abuild
cat << EOF > /home/build/go.sh
#!/bin/sh
cd /home/build
# Add build user
sudo adduser build -D -G abuild
sudo sh -c 'echo "%abuild ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/abuild'
# Create signing keys
abuild-keygen -i -a -n
sudo -u build abuild-keygen -i -a -n
# Setup aports
wget https://gitlab.alpinelinux.org/alpine/aports/-/archive/master/aports-master.tar.gz
tar -xf aports-master.tar.gz
mv aports-master aports
cp /build/mkimg.dangerzone.sh aports/scripts/
cp /build/genapkovl-dangerzone.sh aports/scripts/
chmod +x aports/scripts/mkimg.dangerzone.sh
chmod +x aports/scripts/genapkovl-dangerzone.sh
if [ -d aports ]; then
echo "already downloaded"
else
wget https://gitlab.alpinelinux.org/alpine/aports/-/archive/master/aports-master.tar.gz
tar -xf aports-master.tar.gz
mv aports-master aports
fi
cp /vagrant/mkimg.dangerzone.sh ~/aports/scripts/
cp /vagrant/genapkovl-dangerzone.sh ~/aports/scripts/
chmod +x ~/aports/scripts/mkimg.dangerzone.sh
chmod +x ~/aports/scripts/genapkovl-dangerzone.sh
# Set up the vm dir
rm -r /vagrant/vm
mkdir -p /vagrant/vm
chmod 777 /vagrant/vm
# Make the iso
cd aports/scripts
sh mkimage.sh --tag v3.14 \
--outdir /build/vm \
cd ~/aports/scripts
sudo -u build sh mkimage.sh --tag v3.14 \
--outdir /vagrant/vm \
--arch x86_64 \
--repository http://dl-cdn.alpinelinux.org/alpine/v3.14/main \
--repository http://dl-cdn.alpinelinux.org/alpine/v3.14/community \
--profile dangerzone
EOF
chmod +x /home/build/go.sh
# Set up the vm dir
rm -r /build/vm
mkdir -p /build/vm
chmod 777 /build/vm
# Start the build
sudo -u build /home/build/go.sh
# Fix permissions
chmod 755 /build/vm
chmod 644 /build/vm/*
chown root:root /build/vm/*
chown -R vagrant:vangrant /vagrant/vm
chmod 755 /vagrant/vm
chmod 644 /vagrant/vm/*
# Extract vmlinuz and initramfs
cd /build/vm
cd /vagrant/vm
7z x alpine-dangerzone-v3.14-x86_64.iso boot/vmlinuz-virt
7z x alpine-dangerzone-v3.14-x86_64.iso boot/initramfs-virt
mv boot/* .

View file

@ -1,4 +0,0 @@
#!/bin/sh
# TODO: create podman user
# TODO: set /home/podman/.ssh/authorized_keys