summaryrefslogtreecommitdiff
path: root/kpov_judge/scripts/make-student.sh
diff options
context:
space:
mode:
authorTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 02:31:43 +0100
committerTimotej Lazar <timotej.lazar@fri.uni-lj.si>2019-02-21 02:41:38 +0100
commit2da9d8c440cfb2097a05f6eb9edcc98bba6fca7d (patch)
tree8092910096d63ea37bcd74db4f26b204cac3e4e2 /kpov_judge/scripts/make-student.sh
parent7dd74ded5bfcd36b6a498c0dff71235c4bc764ca (diff)
Add scripts to generate virtual images with Debian
The script make-base downloads and installs Debian Buster in a backing image which is then used by make-arbiter and make-student to create derived images with specific configurations.
Diffstat (limited to 'kpov_judge/scripts/make-student.sh')
-rwxr-xr-xkpov_judge/scripts/make-student.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/kpov_judge/scripts/make-student.sh b/kpov_judge/scripts/make-student.sh
new file mode 100755
index 0000000..f072b47
--- /dev/null
+++ b/kpov_judge/scripts/make-student.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+
+# Create the disk image for a basic terminal computer with sshd.
+# Typical virtualā€machine network interfaces are configured for DHCP.
+
+set -e
+
+if [ $# -lt 1 ]; then
+ echo "usage: ${0} base"
+ exit 1
+fi
+
+base="${1}"
+name="student"
+format="qcow2"
+
+file_interfaces=\
+'# see interfaces(5)
+source /etc/network/interfaces.d/*
+
+# loopback interface
+auto lo
+iface lo inet loopback
+
+# first interface
+allow-hotplug ens3
+iface ens3 inet dhcp
+allow-hotplug enp0s3
+iface enp0s3 inet dhcp
+'
+
+qemu-img create -f qcow2 -b "${base}" "${name}.${format}"
+
+virt-customize -a "${name}.${format}" \
+ --hostname "${name}" \
+ --update \
+ --install openssh-server \
+ --write /etc/network/interfaces:"${file_interfaces}"
+
+#virt-sparsify "${name}.${format}" "${name}x.${format}"
+#qemu-img create -f "${format}" -b "${name}x.${format}" "${name}-diff.${format}"
+#qemu-img rebase -b "${base}" "${name}-diff.${format}"