blob: 0d46253b2daa7be91138a447dc67c6fce6b722d7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
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
|