Compare commits

...
2 Commits
8 changed files with 130 additions and 108 deletions

No files matched your search

Regular → Executable
+9 -21
View File
@@ -1,26 +1,14 @@
#!/usr/bin/env bash
cd "$(dirname "$0")" && source ./lib.sh
VM_ID=9998 VM_ID=9998
VM_NAME="Debian-12-Large-Docker" VM_NAME="Debian-13-Large-Docker"
CPU_CORE=4 CPU_CORE=4
CPU_SOCKET=2 CPU_SOCKET=2
RAM=8192 RAM=8192
DISK=100 DISK=100
#getting latest image" IMAGE_URL="https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2"
wget https://cdimage.debian.org/images/cloud/bookworm/20250210-2019/debian-12-generic-amd64-20250210-2019.qcow2 PACKAGES=""
#installing qemu guest agent and remove HW ID DOCKER=1
virt-customize -a debian-12-generic-amd64-20250210-2019.qcow2 --install qemu-guest-agent,neofetch
virt-customize -a debian-12-generic-amd64-20250210-2019.qcow2 --run-command "curl -fsSL https://get.docker.com -o get-docker.sh build_template
sh get-docker.sh"
virt-customize -a debian-12-generic-amd64-20250210-2019.qcow2 --run-command "echo -n > /etc/machine-id"
qm create $VM_ID --name $VM_NAME --net0 virtio,bridge=vmbr0
qm set $VM_ID --cores "$CPU_CORE" --sockets "$CPU_SOCKET" --memory "$RAM"
qm importdisk "$VM_ID" debian-12-generic-amd64-20250210-2019.qcow2 local-lvm
qm set "$VM_ID" --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-"$VM_ID"-disk-0
qm set "$VM_ID" --ide2 local-lvm:cloudinit
qm set "$VM_ID" --boot c --bootdisk scsi0
qm set "$VM_ID" --serial0 socket --vga serial0
qm resize $VM_ID scsi0 "$DISK"G
qm set "$VM_ID" --ipconfig0 ip=dhcp
qm set "$VM_ID" --agent enabled=1
qm template "$VM_ID"
rm debian-12-generic-amd64-20250210-2019.qcow2 #clean iso
echo "Template er ferdig med id "$VM_ID""
+28 -6
View File
@@ -1,18 +1,40 @@
# To run the image maker make all the script able to run # Run the image maker
Open the console or ssh in to your Proxmox node. Open the console or ssh in to your Proxmox node.
```sh ```sh
apt install git apt install git
git clone https://gitlab.skui.io/Hawolex/prox-mal git clone https://git.skui.io/steffen/prox-mal.git
cd prox-mal/ cd prox-mal/
chmod +x all.sh
./all.sh ./all.sh
``` ```
## Image Medium and Large Or build a single template: `./Ubuntu-LTS-Small.sh`
Docker and Docker Compose comes pre installed from the Docker github repo. \
If not wanted, you can comment out line 12 in Large and Medium.sh ## Templates
| Script | VM ID | Docker |
|---|---|---|
| Ubuntu-LTS-Small.sh | 2000 | no |
| Ubuntu-LTS-Medium.sh | 3000 | yes |
| Ubuntu-LTS-Large.sh | 4000 | yes |
| Debian.sh (Debian 13) | 9998 | yes |
| Ubuntu-22-04-LTS.sh | 9999 | yes |
Each script only sets its sizes and image; the build itself is in `lib.sh`. Set `DOCKER=0`
in a script to skip Docker. The image is cached in `/var/lib/vz/template/cloud` and each
script works on its own copy, so they can run in any order.
## Where the templates land
Defaults fit pvebox: storage `ssd`, network `vmbr1` (VM-Ekstern). Override per run:
```sh
STORAGE=tank BRIDGE=intern ./Ubuntu-LTS-Large.sh
```
A script stops if its VM ID already exists. Remove the old template first:
`qm destroy 2000 --purge`
<details> <details>
<summary>Source Doc </summary> <summary>Source Doc </summary>
Regular → Executable
+8 -20
View File
@@ -1,26 +1,14 @@
#!/usr/bin/env bash
cd "$(dirname "$0")" && source ./lib.sh
VM_ID=9999 VM_ID=9999
VM_NAME="Ubuntu-22-04-LTS-Large-Docker" VM_NAME="Ubuntu-22-04-LTS-Large-Docker"
CPU_CORE=4 CPU_CORE=4
CPU_SOCKET=2 CPU_SOCKET=2
RAM=8192 RAM=8192
DISK=100 DISK=100
#getting latest image" IMAGE_URL="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img PACKAGES="neofetch"
#installing qemu guest agent and remove HW ID DOCKER=1
virt-customize -a jammy-server-cloudimg-amd64.img --install qemu-guest-agent,neofetch
virt-customize -a jammy-server-cloudimg-amd64.img --run-command "curl -fsSL https://get.docker.com -o get-docker.sh build_template
sh get-docker.sh"
virt-customize -a jammy-server-cloudimg-amd64.img --run-command "echo -n > /etc/machine-id"
qm create $VM_ID --name $VM_NAME --net0 virtio,bridge=vmbr0
qm set $VM_ID --cores "$CPU_CORE" --sockets "$CPU_SOCKET" --memory "$RAM"
qm importdisk "$VM_ID" jammy-server-cloudimg-amd64.img local-lvm
qm set "$VM_ID" --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-"$VM_ID"-disk-0
qm set "$VM_ID" --ide2 local-lvm:cloudinit
qm set "$VM_ID" --boot c --bootdisk scsi0
qm set "$VM_ID" --serial0 socket --vga serial0
qm resize $VM_ID scsi0 "$DISK"G
qm set "$VM_ID" --ipconfig0 ip=dhcp
qm set "$VM_ID" --agent enabled=1
qm template "$VM_ID"
rm jammy-server-cloudimg-amd64.img #clean iso
echo "Template er ferdig med id "$VM_ID""
Regular → Executable
+8 -20
View File
@@ -1,26 +1,14 @@
#!/usr/bin/env bash
cd "$(dirname "$0")" && source ./lib.sh
VM_ID=4000 VM_ID=4000
VM_NAME="Ubuntu-24-04-LTS-Large-Docker" VM_NAME="Ubuntu-24-04-LTS-Large-Docker"
CPU_CORE=4 CPU_CORE=4
CPU_SOCKET=2 CPU_SOCKET=2
RAM=8192 RAM=8192
DISK=100 DISK=100
#getting latest image" IMAGE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
#wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img PACKAGES=""
#installing qemu guest agent and remove HW ID DOCKER=1
virt-customize -a noble-server-cloudimg-amd64.img --install qemu-guest-agent
virt-customize -a noble-server-cloudimg-amd64.img --run-command "curl -fsSL https://get.docker.com -o get-docker.sh build_template
sh get-docker.sh"
virt-customize -a noble-server-cloudimg-amd64.img --run-command "echo -n > /etc/machine-id"
qm create $VM_ID --name $VM_NAME --net0 virtio,bridge=vmbr0
qm set $VM_ID --cores "$CPU_CORE" --sockets "$CPU_SOCKET" --memory "$RAM"
qm importdisk "$VM_ID" noble-server-cloudimg-amd64.img rust
qm set "$VM_ID" --scsihw virtio-scsi-pci --scsi0 rust:vm-"$VM_ID"-disk-0
qm set "$VM_ID" --ide2 rust:cloudinit
qm set "$VM_ID" --boot c --bootdisk scsi0
qm set "$VM_ID" --serial0 socket --vga serial0
qm resize $VM_ID scsi0 "$DISK"G
qm set "$VM_ID" --ipconfig0 ip=dhcp
qm set "$VM_ID" --agent enabled=1
qm template "$VM_ID"
rm noble-server-cloudimg-amd64.img clean iso
echo "Template er ferdig med id "$VM_ID""
Regular → Executable
+8 -20
View File
@@ -1,26 +1,14 @@
#!/usr/bin/env bash
cd "$(dirname "$0")" && source ./lib.sh
VM_ID=3000 VM_ID=3000
VM_NAME="Ubuntu-24-04-LTS-Medium-Docker" VM_NAME="Ubuntu-24-04-LTS-Medium-Docker"
CPU_CORE=2 CPU_CORE=2
CPU_SOCKET=2 CPU_SOCKET=2
RAM=4096 RAM=4096
DISK=50 DISK=50
#getting latest image" IMAGE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
#wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img PACKAGES=""
#installing qemu guest agent and remove HW ID DOCKER=1
virt-customize -a noble-server-cloudimg-amd64.img --install qemu-guest-agent
virt-customize -a noble-server-cloudimg-amd64.img --run-command "curl -fsSL https://get.docker.com -o get-docker.sh build_template
sh get-docker.sh"
virt-customize -a noble-server-cloudimg-amd64.img --run-command "echo -n > /etc/machine-id"
qm create $VM_ID --name $VM_NAME --net0 virtio,bridge=vmbr0
qm set $VM_ID --cores "$CPU_CORE" --sockets "$CPU_SOCKET" --memory "$RAM"
qm importdisk "$VM_ID" noble-server-cloudimg-amd64.img rust
qm set "$VM_ID" --scsihw virtio-scsi-pci --scsi0 rust:vm-"$VM_ID"-disk-0
qm set "$VM_ID" --ide2 rust:cloudinit
qm set "$VM_ID" --boot c --bootdisk scsi0
qm set "$VM_ID" --serial0 socket --vga serial0
qm resize $VM_ID scsi0 "$DISK"G
qm set "$VM_ID" --ipconfig0 ip=dhcp
qm set "$VM_ID" --agent enabled=1
qm template "$VM_ID"
#rm noble-server-cloudimg-amd64.img clean iso
echo "Template er ferdig med id "$VM_ID""
Regular → Executable
+8 -20
View File
@@ -1,26 +1,14 @@
#!/usr/bin/env bash
cd "$(dirname "$0")" && source ./lib.sh
VM_ID=2000 VM_ID=2000
VM_NAME="Ubuntu-24-04-LTS-Small" VM_NAME="Ubuntu-24-04-LTS-Small"
CPU_CORE=2 CPU_CORE=2
CPU_SOCKET=2 CPU_SOCKET=2
RAM=2048 RAM=2048
DISK=50 DISK=50
#getting latest image" IMAGE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img PACKAGES=""
#installing qemu guest agent and remove HW ID DOCKER=0
virt-customize -a noble-server-cloudimg-amd64.img --install qemu-guest-agent
virt-customize -a noble-server-cloudimg-amd64.img --run-command "curl -fsSL https://get.docker.com -o get-docker.sh build_template
sh get-docker.sh"
virt-customize -a noble-server-cloudimg-amd64.img --run-command "echo -n > /etc/machine-id"
qm create $VM_ID --name $VM_NAME --net0 virtio,bridge=vmbr0
qm set $VM_ID --cores "$CPU_CORE" --sockets "$CPU_SOCKET" --memory "$RAM"
qm importdisk "$VM_ID" noble-server-cloudimg-amd64.img rust
qm set "$VM_ID" --scsihw virtio-scsi-pci --scsi0 rust:vm-"$VM_ID"-disk-0
qm set "$VM_ID" --ide2 rust:cloudinit
qm set "$VM_ID" --boot c --bootdisk scsi0
qm set "$VM_ID" --serial0 socket --vga serial0
qm resize $VM_ID scsi0 "$DISK"G
qm set "$VM_ID" --ipconfig0 ip=dhcp
qm set "$VM_ID" --agent enabled=1
qm template "$VM_ID"
#rm noble-server-cloudimg-amd64.img clean iso
echo "Template er ferdig med id "$VM_ID""
Regular → Executable
+9 -1
View File
@@ -1 +1,9 @@
apt install -y libguestfs-tools && chmod +x Ubuntu-L* && chmod +x Debian.sh && ./Debian.sh && ./Ubuntu-LTS-Small.sh && ./Ubuntu-LTS-Medium.sh && ./Ubuntu-LTS-Large.sh #&& ./Ubuntu-22-04-LTS.sh #!/usr/bin/env bash
# Builds every template. Stops at the first failure.
set -e
cd "$(dirname "$0")"
./Debian.sh
./Ubuntu-LTS-Small.sh
./Ubuntu-LTS-Medium.sh
./Ubuntu-LTS-Large.sh
#./Ubuntu-22-04-LTS.sh
Executable
+52
View File
@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# Shared template builder. Each <distro>.sh sets the variables below and calls build_template.
#
# VM_ID VM_NAME CPU_CORE CPU_SOCKET RAM DISK - template hardware (DISK in GB)
# IMAGE_URL - cloud image to start from
# PACKAGES - extra apt packages, comma separated
# DOCKER=1 - install Docker from get.docker.com
#
# Override where it lands with environment variables:
# STORAGE=ssd BRIDGE=vmbr1 ./Ubuntu-LTS-Small.sh
set -euo pipefail
STORAGE="${STORAGE:-ssd}" # pvebox: ssd (SSD raidz1) or tank (SAS raidz1)
BRIDGE="${BRIDGE:-vmbr1}" # vmbr1 = VM-Ekstern (VLAN 4), intern = Proxmox NAT, vmbr0 = Lab
IMAGE_DIR="${IMAGE_DIR:-/var/lib/vz/template/cloud}"
build_template() {
if qm status "$VM_ID" >/dev/null 2>&1; then
echo "VM $VM_ID finnes allerede - slett den først: qm destroy $VM_ID --purge" >&2
exit 1
fi
command -v virt-customize >/dev/null || apt install -y libguestfs-tools
# Download once into a cache (only again when the image changed upstream);
# customize a copy so every script starts from a clean image.
mkdir -p "$IMAGE_DIR"
wget -q --show-progress -N -P "$IMAGE_DIR" "$IMAGE_URL"
local work; work=$(mktemp -d)
local disk="$work/disk.qcow2"
cp "$IMAGE_DIR/$(basename "$IMAGE_URL")" "$disk"
# Guest agent, extra packages, optional Docker, and an empty machine-id so clones get their own DHCP lease
virt-customize -a "$disk" --install "qemu-guest-agent${PACKAGES:+,$PACKAGES}"
if [ "${DOCKER:-0}" = 1 ]; then
virt-customize -a "$disk" --run-command "curl -fsSL https://get.docker.com | sh"
fi
virt-customize -a "$disk" --truncate /etc/machine-id
qm create "$VM_ID" --name "$VM_NAME" --net0 "virtio,bridge=$BRIDGE"
qm set "$VM_ID" --cores "$CPU_CORE" --sockets "$CPU_SOCKET" --memory "$RAM"
qm set "$VM_ID" --scsihw virtio-scsi-pci --scsi0 "$STORAGE:0,import-from=$disk,discard=on"
qm set "$VM_ID" --ide2 "$STORAGE:cloudinit"
qm set "$VM_ID" --boot order=scsi0
qm set "$VM_ID" --serial0 socket --vga serial0
qm resize "$VM_ID" scsi0 "${DISK}G"
qm set "$VM_ID" --ipconfig0 ip=dhcp
qm set "$VM_ID" --agent enabled=1
qm template "$VM_ID"
rm -rf "$work"
echo "Template er ferdig med id $VM_ID ($VM_NAME) på $STORAGE, nett $BRIDGE"
}