Add initial version of disk generation scripts

master
LEdoian 2 years ago
parent ccc82015c8
commit a8e0e0a805

@ -0,0 +1,42 @@
# Alpine Linux installation answers
# Doc: https://docs.alpinelinux.org/user-handbook/0.1a/Installing/setup_alpine.html#_answer_files
# Serve e.g. with "ncat -e '/bin/cat alpine_install' -l -p 2222 -k"
# Get in alpine e.g. using "sleep 1 | nc … > file" and use with "setup-alpine -e -f file"
# After installation, boot the VM from the disk and run alpine_postinst script
# (serve similarly to this file). This script performs a few tweaks to the
# installation, like installing BIRD.
# Use US layout with US variant
KEYMAPOPTS="us us"
# Set hostname to alpine-test
HOSTNAMEOPTS="-n dummy-install"
# Contents of /etc/network/interfaces
# We will overwrite this later, so it does not matter much
# While preparing, network is useful to share files with VM.
INTERFACESOPTS="auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
"
DNSOPTS="-d whatever.invalid 1.1.1.1"
# Set timezone to UTC
TIMEZONEOPTS="-z UTC"
# This seems to work, somehow.
PROXYOPTS="none"
APKREPOSOPTS="-1"
# Install Openssh
SSHDOPTS="-c openssh"
NTPOPTS="-c busybox"
DISKOPTS="-m sys -s 0 /dev/sda"
BOOTLOADER=syslinux

@ -0,0 +1,10 @@
#!/bin/echo Run this in VM.
# TODO
# Add SSH keys
# Install bird and maybe other tools
# Run nameif at boot to set network names
# Doc: https://wiki.alpinelinux.org/wiki/Custom_network_interface_names

@ -0,0 +1,38 @@
#!/bin/sh
set -exu
disk_size=4G
dl_alpine() {
tmpdir="$(mktemp --directory)"
trap "rm $tmpdir" EXIT
pushd "$tmpdir"
# Setup GPG
wget 'https://alpinelinux.org/keys/ncopa.asc'
gpg --import ncopa.asc
wget 'https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-virt-3.15.4-x86_64.iso' 'https://dl-cdn.alpinelinux.org/alpine/v3.15/releases/x86_64/alpine-virt-3.15.4-x86_64.iso.asc'
gpg --verify alpine-virt-3.15.4-x86_64.iso.asc alpine-virt-3.15.4-x86_64.iso
# Cleanup
popd
mv "$tmpdir/alpine-virt-3.15.4-x86_64.iso" .
rm "$tmpdir/alpine-virt-3.15.4-x86_64.iso.asc" "$tmpdir/ncopa.asc"
rmdir "$tmpdir"
trap - EXIT
}
test -f alpine-virt-3.15.4-x86_64.iso || dl_alpine
# Clean old disk
test -f dummydisk.img && rm dummydisk.img
qemu-img create -f raw dummydisk.img "$disk_size"
# Launch installation
# Basic VM is sufficient
qemu-system-x86_64 -enable-kvm -m 2G -cdrom alpine-virt-3.15.4-x86_64.iso -drive media=disk,format=raw,file=dummydisk.img
# Now the user has to run installation from the VM. See ./alpine_install for details.
Loading…
Cancel
Save