Add Alpine
This commit is contained in:
@@ -0,0 +1,19 @@
|
|||||||
|
distro = "alpine"
|
||||||
|
version = "3.19.0"
|
||||||
|
iso = {
|
||||||
|
url = "https://dl-cdn.alpinelinux.org/alpine/v3.19/releases/x86_64/alpine-standard-3.19.0-x86_64.iso"
|
||||||
|
checksum = "4cf7cd3bad64122a8a2423e78369a486a02334d4d88645aab9d08120bb76b0f9"
|
||||||
|
}
|
||||||
|
boot_command = [
|
||||||
|
"root<enter><wait1>",
|
||||||
|
"echo 'iface eth0 inet dhcp' > /etc/network/interfaces<enter>",
|
||||||
|
"ifup eth0<enter><wait8>",
|
||||||
|
"wget -O answers.cfg.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/answers.cfg.sh<enter>",
|
||||||
|
"<wait3>",
|
||||||
|
"wget -O in-chroot.sh http://{{ .HTTPIP }}:{{ .HTTPPort }}/in-chroot.sh<enter>",
|
||||||
|
"<wait3>",
|
||||||
|
"/bin/ash ./answers.cfg.sh 2>&1 | tee install.log<enter>",
|
||||||
|
]
|
||||||
|
http_directory = "distros/alpine/3.19.0/http/"
|
||||||
|
boot_wait = "20s"
|
||||||
|
shutdown_command = "sudo poweroff"
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -ex
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/ash
|
||||||
|
|
||||||
|
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
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -ex -o pipefail
|
||||||
|
|
||||||
|
# Enables packages like "sudo"
|
||||||
|
sed -i 's/#\(.*\/community\)/\1/' /etc/apk/repositories
|
||||||
|
|
||||||
|
# Install bare minimal packages
|
||||||
|
apk add curl efibootmgr openssh sudo virt-what
|
||||||
|
efibootmgr --bootnext "$(efibootmgr | grep 'Misc' | awk '{print $1}' | sed -E 's/[^0-9]//g')"
|
||||||
|
|
||||||
|
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 <<EOF
|
||||||
|
# For now the vagrant insecure key is an rsa key
|
||||||
|
# https://github.com/hashicorp/vagrant/issues/11783
|
||||||
|
PubkeyAcceptedKeyTypes=+ssh-rsa
|
||||||
|
EOF
|
||||||
|
ssh-keygen -A
|
||||||
|
|
||||||
|
# Create and configure the vagrant user
|
||||||
|
adduser vagrant -D
|
||||||
|
# Add the vagrant user to the `wheel` group
|
||||||
|
addgroup vagrant wheel
|
||||||
|
[ -d /home/vagrant ] || exit 1
|
||||||
|
echo "vagrant:vagrant" | chpasswd
|
||||||
|
echo "root:vagrant" | chpasswd
|
||||||
|
|
||||||
|
# Do host-specific things
|
||||||
|
virt="$(virt-what)"
|
||||||
|
# Values I've found so far
|
||||||
|
# "microsoft" == Hyper-V
|
||||||
|
# "oracle" == VirtualBox
|
||||||
|
# "KVM" == KVM/Qemu
|
||||||
|
if [ "${virt}" == "microsoft" ]; then
|
||||||
|
apk add hvtools
|
||||||
|
rc-update add hv_fcopy_daemon
|
||||||
|
rc-update add hv_kvp_daemon
|
||||||
|
rc-update add hv_vss_daemon
|
||||||
|
elif [ "${virt}" == "kvm" -o "${virt}" == "qemu" ]; then
|
||||||
|
apk add qemu-guest-agent
|
||||||
|
rc-update add qemu-guest-agent
|
||||||
|
elif [ "${virt}" == "virtualbox" ]; then
|
||||||
|
apk add virtualbox-guest-additions
|
||||||
|
rc-update add virtualbox-guest-additions boot
|
||||||
|
fi
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -ex
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -ex
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env sh
|
||||||
|
set -ex
|
||||||
|
|
||||||
|
pacman -Sy --noconfirm open-vm-tools
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
"3.19.0":
|
||||||
|
- arch: amd64
|
||||||
|
provider: qemu
|
||||||
|
- arch: amd64
|
||||||
|
provider: virtualbox-iso
|
||||||
|
- arch: amd64
|
||||||
|
provider: hyperv-iso
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env sh
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
# Configure vagrant user's SSH key
|
# Configure vagrant user's SSH key
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
Vagrant.configure('2') do |c|
|
Vagrant.configure('2') do |c|
|
||||||
|
c.ssh.shell = "/bin/sh"
|
||||||
# Set some basic overrides
|
# Set some basic overrides
|
||||||
c.vm.provider :libvirt do |v, override|
|
c.vm.provider :libvirt do |v, override|
|
||||||
v.driver = 'kvm'
|
v.driver = 'kvm'
|
||||||
|
|||||||
Reference in New Issue
Block a user