summaryrefslogtreecommitdiff
path: root/kpov_judge/scripts/make-student.sh
blob: f072b47147770c056e93721ef0b0396e10c4d3ac (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
#!/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}"