From 8081a5520a441b43a8a7a73f3a90c7aacfaa8e10 Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Sun, 24 Feb 2019 21:05:27 +0100 Subject: Move everything one level up --- scripts/make-base.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 scripts/make-base.sh (limited to 'scripts/make-base.sh') diff --git a/scripts/make-base.sh b/scripts/make-base.sh new file mode 100755 index 0000000..970acac --- /dev/null +++ b/scripts/make-base.sh @@ -0,0 +1,51 @@ +#!/bin/sh + +# Create the base disk image: a minimal Debian install with a user +# account student / vaje. Root password is kaboom. Serial console is +# enabled for grub and boot messages are displayed. Some useful +# additional packages are installed, and the image is sparsified +# (requires at least 30 GB free space). + +set -e + +if [ $# -lt 1 ]; then + echo "usage: ${0} image-name" + exit 1 +fi + +name="${1}" +format=qcow2 + +outfile="${name}.${format}" +fatfile="${name}-fat.${format}" + +tmpdir="$(mktemp -d kpov-tmp.XXXXXX)" +trap 'rm -rf "${tmpdir}"' EXIT + +for f in linux initrd.gz; do + wget "https://d-i.debian.org/daily-images/i386/daily/netboot/debian-installer/i386/${f}" -O "${tmpdir}/${f}" +done + +qemu-img create -f "${format}" -o size=30G "${fatfile}" + +qemu-system-i386 \ + -enable-kvm \ + -nographic \ + -m 1G -smp 2 \ + -kernel "${tmpdir}/linux" -initrd "${tmpdir}/initrd.gz" \ + -append "console=ttyS0,115200n8 serial auto=true url=http://10.0.2.10:8080/preseed.cfg hostname=${name} domain=" \ + -net user,guestfwd=:10.0.2.10:8080-cmd:"/bin/busybox httpd -i" -net nic \ + -hda "${fatfile}" + +virt-customize -a "${fatfile}" \ + --update \ + --install virtualbox-guest-utils,virtualbox-guest-modules \ + --install nftables \ + --install git,nano,net-tools,rsync,sudo,tmux,vim \ + --run-command 'apt clean' \ + --edit /etc/default/grub:'s/^GRUB_CMDLINE_LINUX_DEFAULT=.*$/GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0"/' \ + --edit /etc/default/grub:'s/^GRUB_TERMINAL=.*$/GRUB_TERMINAL=\"console serial\"/' \ + --run-command update-grub + +virt-sparsify "${fatfile}" "${outfile}" +rm -f "${fatfile}" -- cgit v1.2.1