aboutsummaryrefslogtreecommitdiffstats
path: root/static/misc/automated-alpine-setup
diff options
context:
space:
mode:
authorLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-03-18 10:38:06 +0100
committerLibravatarLarge Libravatar memdmp <memdmpestrogenzone>2025-03-18 10:38:06 +0100
commit5f8825bae500aef5a5350358c567c2d71bd5b1f1 (patch)
tree01b5cc5d6d9c9edc21226a6a963c00d48bf8930b /static/misc/automated-alpine-setup
parentf5c09c3d478d3b1be6c1fc53416649851bcc7fb4 (diff)
downloadmem-estrogen-zone-5f8825bae500aef5a5350358c567c2d71bd5b1f1.tar.gz
mem-estrogen-zone-5f8825bae500aef5a5350358c567c2d71bd5b1f1.tar.bz2
mem-estrogen-zone-5f8825bae500aef5a5350358c567c2d71bd5b1f1.tar.lz
mem-estrogen-zone-5f8825bae500aef5a5350358c567c2d71bd5b1f1.zip

feat: a backup of an automated alpine setup script

Diffstat (limited to 'static/misc/automated-alpine-setup')
-rw-r--r--static/misc/automated-alpine-setup118
1 files changed, 118 insertions, 0 deletions
diff --git a/static/misc/automated-alpine-setup b/static/misc/automated-alpine-setup
new file mode 100644
index 0000000..0d46253
--- /dev/null
+++ b/static/misc/automated-alpine-setup
@@ -0,0 +1,118 @@
+#!/usr/bin/expect -f
+# An IPv6-only-compatible automation routine around `setup-alpine` for building alpine vms
+# Replace `user=memdmp` with `user=<output of whoami>`
+# Replace `[SSHKEY]` with the desired SSH key
+# Replace `/tmp/vm.iso` with the Alpine ISO
+# Replace `/tmp/target.qcow2` with the desired qcow2 image to install on
+# Replace `-m 8G` with the amount of memory to use
+# After setup, change the disk encryption password (will be set to `pass`) via `cryptsetup luksAddKey /dev/sdb3` followed by `crypsetup luksRemoveKey /dev/sdb3`
+spawn qemu-system-x86_64 -smp 8 -run-with user=memdmp -drive file=/tmp/vm.iso,format=raw,index=0,media=disk -drive file=/tmp/target.qcow2,format=qcow2,index=1,media=disk -serial stdio -display none -m 8G
+
+set timeout 240
+expect "login: "
+send "root\n"
+set timeout 30
+
+expect "You may change this message by editing /etc/motd."
+sleep 1
+send "PS1=@@\n"
+expect "\n@@"
+send "echo 'Hi!' > /etc/motd\n"
+expect "\n@@"
+
+send "setup-alpine\n"
+expect "Enter system hostname"
+sleep 0.1
+send "replaceme.vms.crunchy.estrogen.zone\n"
+
+expect "eth0"
+sleep 0.1
+send "\n"
+expect "Ip address for eth0?"
+send "none\n"
+expect "manual"
+send "y\n"
+sleep 1
+send ":"
+sleep 0.1
+send ":%s/inet manual/inet6 auto/"
+sleep 0.1
+send "\n"
+sleep 0.3
+send ":wq\n"
+expect "DNS domain name"
+send "\n"
+expect "DNS nameserver"
+send "2620:fe::fe 2620:fe::9 9.9.9.9 149.112.112.112\n"
+
+expect "New password: "
+send "\n"
+sleep 0.1
+send "\n"
+
+expect "Which timezone are you in?"
+sleep 0.1
+send "Europe/Zurich\n"
+
+expect "HTTP/FTP proxy URL?"
+sleep 0.1
+send "\n"
+
+expect "Which NTP client to run?"
+sleep 0.1
+send "chrony\n"
+
+expect "Enter mirror number or URL:"
+sleep 0.1
+send "e\n"
+sleep 1
+send ":ggdG\n"
+sleep 1
+send "i"
+sleep 1
+send "https://mirror.init7.net/alpinelinux/latest-stable/main\nhttps://mirror.init7.net/alpinelinux/latest-stable/community\n@edge https://mirror.init7.net/alpinelinux/edge/main\n@edge https://mirror.init7.net/alpinelinux/edge/community\n@testing https://mirror.init7.net/alpinelinux/edge/testing\n# "
+sleep 1
+send "\x1b"
+sleep 1
+send ":wq\n"
+
+expect "Setup a user?"
+send "lain\n"
+expect "Full name for user lain"
+send "Lain\n"
+expect "New password: "
+send "\n"
+expect "Retype password: "
+send "\n"
+expect "Enter ssh key or URL for lain"
+send "[SSHKEY]\n"
+expect "Which ssh server?"
+send "\n"
+
+expect "Which disk(s) would you like to use?"
+send "sdb\n"
+
+expect "How would you like to use it?"
+send "cryptsys\n"
+
+expect "WARNING: Erase the above disk(s) and continue?"
+sleep 0.1
+send "y\n"
+
+expect "Enter passphrase for"
+sleep 0.1
+send "pass\n"
+expect "Verify passphrase"
+sleep 0.1
+send "pass\n"
+expect "Enter passphrase for"
+sleep 0.1
+send "pass\n"
+
+set timeout 600
+
+expect "Installation is complete. Please reboot."
+sleep 1
+set timeout 15
+send "poweroff\n"
+expect eof