From 42fabf124bb1fa62e74f6738c7dac006c9e6f73f Mon Sep 17 00:00:00 2001 From: Greg Hellings Date: Sun, 30 Jun 2024 00:20:12 -0500 Subject: [PATCH] Init Alpine 3.20 at patch 1 --- distros/alpine/3.20/amd64.pkrvars.hcl | 19 ++++++++ distros/alpine/3.20/finalize.sh | 2 + distros/alpine/3.20/http/answers.cfg.sh | 61 +++++++++++++++++++++++++ distros/alpine/3.20/http/in-chroot.sh | 57 +++++++++++++++++++++++ distros/alpine/3.20/qemu.sh | 2 + distros/alpine/3.20/virtualbox.sh | 2 + distros/alpine/3.20/vmware.sh | 4 ++ distros/alpine/default.nix | 4 ++ 8 files changed, 151 insertions(+) create mode 100644 distros/alpine/3.20/amd64.pkrvars.hcl create mode 100644 distros/alpine/3.20/finalize.sh create mode 100644 distros/alpine/3.20/http/answers.cfg.sh create mode 100644 distros/alpine/3.20/http/in-chroot.sh create mode 100644 distros/alpine/3.20/qemu.sh create mode 100644 distros/alpine/3.20/virtualbox.sh create mode 100644 distros/alpine/3.20/vmware.sh diff --git a/distros/alpine/3.20/amd64.pkrvars.hcl b/distros/alpine/3.20/amd64.pkrvars.hcl new file mode 100644 index 0000000..42369d8 --- /dev/null +++ b/distros/alpine/3.20/amd64.pkrvars.hcl @@ -0,0 +1,19 @@ +distro = "alpine" +version = "3.20" +iso = { + url = "http://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-standard-3.20.1-x86_64.iso" + checksum = "c3043af6421b6e0ab22994b01d10785728888b37d976a754f12f23b42aecd95e" +} +boot_command = [ + "root", + "echo 'iface eth0 inet dhcp' > /etc/network/interfaces", + "ifup eth0", + "wget -O answers.cfg.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers.cfg.sh", + "", + "wget -O in-chroot.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/in-chroot.sh", + "", + "/bin/ash ./answers.cfg.sh 2>&1 | tee install.log", +] +http_directory = "distros/alpine/3.20/http/" +boot_wait = "20s" +shutdown_command = "sudo poweroff" diff --git a/distros/alpine/3.20/finalize.sh b/distros/alpine/3.20/finalize.sh new file mode 100644 index 0000000..5a01809 --- /dev/null +++ b/distros/alpine/3.20/finalize.sh @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +set -ex \ No newline at end of file diff --git a/distros/alpine/3.20/http/answers.cfg.sh b/distros/alpine/3.20/http/answers.cfg.sh new file mode 100644 index 0000000..a430023 --- /dev/null +++ b/distros/alpine/3.20/http/answers.cfg.sh @@ -0,0 +1,61 @@ +#!/bin/ash +# shellcheck shell=dash + +set -ex -o pipefail + +if [ -e /dev/vda ]; then + disk="/dev/vda" +else + disk="/dev/sda" +fi + +cat << EOF > answers.cfg +KEYMAPOPTS="us us" + +HOSTNAMEOPTS="vagrant" + +DEVDOPTS=mdev + +INTERFACESOPTS="auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +hostname vagrant.local" + +TIMEZONEOPTS="UTC" + +PROXYOPTS="none" + +# Add first CDN mirror +APKREPOSOPTS="-1" + +USEROPTS="-a -u -g audio,video,netdev vagrant" + +SSHDOPTS=openssh + +NTPOPTS=none + +DISKOPTS="-m sys ${disk}" + +LBUOPTS=none + +APKCACHEOPTS=none +EOF + +setup-alpine -e -f answers.cfg -q +yes y | setup-disk -m sys "${disk}" || true +# It isn't setting up disk in initial run, but +# it also can't setup disk before the rest of it +# is setup properly. There might be a better workaround +# but this is what I'm choosing to do +setup-alpine -e -f answers.cfg -q + +mount "${disk}3" /mnt +mount "${disk}1" /mnt/boot + +mv in-chroot.sh /mnt +for fs in proc sys dev sys/firmware/efi/efivars; do mount -o bind /${fs} /mnt/${fs}; done +chroot /mnt /bin/ash /in-chroot.sh +rm /mnt/in-chroot.sh +reboot \ No newline at end of file diff --git a/distros/alpine/3.20/http/in-chroot.sh b/distros/alpine/3.20/http/in-chroot.sh new file mode 100644 index 0000000..4300f7d --- /dev/null +++ b/distros/alpine/3.20/http/in-chroot.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env sh +set -ex + +# Enables packages like "sudo" +sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories + +# Install bare minimal packages +apk add curl efibootmgr openssh sudo virt-what + +rc-update add sshd default + +# Configure systems +echo 'vagrant ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/vagrant-nopasswd +echo 'Defaults !requiretty' >> /etc/sudoers +sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config +cat > /etc/ssh/sshd_config.d/10-vagrant-insecure-rsa-key.conf <