blob: 7bc06641cd5b46ff99862dd6a029b701a9aea802 (
plain)
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
|
#! /bin/sh
# Auto-install OpenBSD/amd64 6.6 to a QEMU guest machine.
#
# Inspired by:
#
# - https://man.openbsd.org/autoinstall
#
# - https://eradman.com/posts/autoinstall-openbsd.html
#
# - https://drewdevault.com/2018/09/10/Getting-started-with-qemu.html
#
# Remove generated files with
#
# git clean -Xdf
#
# Copyright (c) 2020 Stefan Kreutz <mail@skreutz.com>
set -o errexit
set -o xtrace
# Download and verify OpenBSD/amd64 6.6 distribution.
#
# Note: rsync deletes superfluous files, e.g., the site66.tgz.
[ -e openbsd-66-base.pub ] || \
curl --output openbsd-66-base.pub --silent \
https://ftp.openbsd.org/pub/OpenBSD/6.6/openbsd-66-base.pub
mkdir -p http/pub/OpenBSD/6.6/amd64
rsync --recursive --delete --quiet \
rsync://ftp.halifax.rwth-aachen.de/openbsd/6.6/amd64/ \
http/pub/OpenBSD/6.6/amd64/
( cd http/pub/OpenBSD/6.6/amd64 && \
signify -C -q -p ../../../../../openbsd-66-base.pub -x SHA256.sig )
# Add a site-specific file set to patch the system at the end of the
# installation -- and optionally on the first boot.
#
# Note: Afterwards, signify will fail to verify the integrity of the
# distribution.
tar -czf http/pub/OpenBSD/6.6/amd64/site66.tgz install.site
( cd http/pub/OpenBSD/6.6/amd64 && ls -l > index.txt )
# Add public ssh key to install.conf.
grep -q -e "^Public ssh key for user =" http/install.conf || {
ssh_pub_key="$( cat ~/.ssh/id_rsa.pub )"
echo "Public ssh key for user = ${ssh_pub_key}" >> http/install.conf
}
# TODO: Start HTTP server automatically in the background.
# sudo python3 -m http.server --directory http --bind 127.0.0.1 80
# Create copy-on-write disk image.
[ -e openbsd-66-vm.qcow2 ] || qemu-img create -f qcow2 openbsd-66-vm.qcow2 16G
# Auto-install guest machine.
#
# Connect with
#
# ssh -o "StrictHostKeyChecking no" -o "UserKnownHostsFile /dev/null" -o "Port 2222" root@127.0.0.1
#
# Stop guest machine with C-a x
#
# Show help with C-a h
#
# network = 10.0.2.0/24
# host = 10.0.2.2
# nameserver = 10.0.2.3
# guest = 10.0.2.15-31
qemu-system-x86_64 \
-enable-kvm \
-m 4G \
-device e1000,netdev=n1 \
-netdev user,id=n1,hostname=openbsd-vm,tftp=tftp,bootfile=auto_install,hostfwd=tcp::2222-:22 \
-drive file=openbsd-66-vm.qcow2,media=disk,if=virtio \
-nographic
|
for my tech blog and contact information.