more stuff

This commit is contained in:
nora 2024-07-13 18:14:41 +02:00
parent 64cb1dd6df
commit 0b4e5f1e27
15 changed files with 122 additions and 153 deletions

View file

@ -1,18 +1,34 @@
#!/usr/bin/bash
#!/usr/bin/env bash
set -eu
NAME="$1"
NAME="${1:?Must pass the name}"
if [ "$(whoami)" != "root" ]; then
echo "script must be run as root!"
fi
mkdir -p tmp
mkdir -p vm-state
# https://mop.koeln/blog/creating-a-local-debian-vm-using-cloud-init-and-libvirt/
# > DO NOT DOWNLOAD THE GENERICCLOUD IMAGE
IMG=debian-12-generic-amd64.qcow2
IMG_DOWNLOADED=debian-12-generic-amd64.qcow2
IMG=debian-12-generic-amd64-bigger.qcow2
if ! [ -f "tmp/$IMG_DOWNLOADED" ]; then
curl -L -o "tmp/$IMG_DOWNLOADED" https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
fi
if ! [ -f "tmp/$IMG" ]; then
curl -L -o "tmp/$IMG" https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.qcow2
cp "tmp/$IMG_DOWNLOADED" "tmp/$IMG"
echo "INCREASE THE SIZE OF THE IMAGE!!!"
echo "sudo qemu-img resize tmp/$IMG 30G"
echo "sudo modprobe nbd max_part=10"
echo "sudo qemu-nbd -c /dev/nbd0 tmp/$IMG_DOWNLOADED"
echo "sudo gparted /dev/nbd0"
echo "sudo qemu-nbd -d /dev/nbd0"
exit 1
fi
DISK="vm-state/$NAME.qcow2"
@ -47,4 +63,4 @@ ip=$(virsh domifaddr "$NAME" | grep ipv4 | awk '{print $4}' | cut -d/ -f1)
echo "IP: $ip"
echo "$ip" >> vm-state/inventory.ini
echo "$ip hostname=$NAME" >> vm-state/inventory.ini