Compare commits
3
Commits
dev
...
5a564aaa47
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a564aaa47 | ||
|
|
24e624234b | ||
|
|
3306959dcd |
No files matched your search
@@ -1,26 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
cd "$(dirname "$0")" && source ./lib.sh
|
||||
|
||||
VM_ID=9998
|
||||
VM_NAME="Debian-12-Large-Docker"
|
||||
VM_NAME="Debian-13-Large-Docker"
|
||||
CPU_CORE=4
|
||||
CPU_SOCKET=2
|
||||
RAM=8192
|
||||
DISK=100
|
||||
#getting latest image"
|
||||
wget https://cdimage.debian.org/images/cloud/bookworm/20250210-2019/debian-12-generic-amd64-20250210-2019.qcow2
|
||||
#installing qemu guest agent and remove HW ID
|
||||
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
|
||||
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""
|
||||
IMAGE_URL="https://cloud.debian.org/images/cloud/trixie/latest/debian-13-generic-amd64.qcow2"
|
||||
PACKAGES=""
|
||||
DOCKER=1
|
||||
|
||||
build_template
|
||||
@@ -37,6 +37,35 @@ qm set 200 --ciuser ubuntu --sshkeys ~/.ssh/id_rsa.pub
|
||||
## Legacy scripts
|
||||
`all.sh`, `Ubuntu-LTS-*.sh`, `Ubuntu-22-04-LTS.sh` and `Debian.sh` are the old fixed-size scripts (hard-coded storage `rust`/`local-lvm` and IDs). They are kept for reference. Use `install.sh` instead.
|
||||
|
||||
## Fixed templates (all.sh)
|
||||
|
||||
The older per-distro scripts are still here. `./all.sh` builds them all, or run one, e.g. `./Ubuntu-LTS-Small.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>
|
||||
<summary>Source Doc </summary>
|
||||
|
||||
|
||||
Regular → Executable
+8
-20
@@ -1,26 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
cd "$(dirname "$0")" && source ./lib.sh
|
||||
|
||||
VM_ID=9999
|
||||
VM_NAME="Ubuntu-22-04-LTS-Large-Docker"
|
||||
CPU_CORE=4
|
||||
CPU_SOCKET=2
|
||||
RAM=8192
|
||||
DISK=100
|
||||
#getting latest image"
|
||||
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img
|
||||
#installing qemu guest agent and remove HW ID
|
||||
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
|
||||
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""
|
||||
IMAGE_URL="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
|
||||
PACKAGES="neofetch"
|
||||
DOCKER=1
|
||||
|
||||
build_template
|
||||
Regular → Executable
+8
-20
@@ -1,26 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
cd "$(dirname "$0")" && source ./lib.sh
|
||||
|
||||
VM_ID=4000
|
||||
VM_NAME="Ubuntu-24-04-LTS-Large-Docker"
|
||||
CPU_CORE=4
|
||||
CPU_SOCKET=2
|
||||
RAM=8192
|
||||
DISK=100
|
||||
#getting latest image"
|
||||
#wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
|
||||
#installing qemu guest agent and remove HW ID
|
||||
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
|
||||
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""
|
||||
IMAGE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
|
||||
PACKAGES=""
|
||||
DOCKER=1
|
||||
|
||||
build_template
|
||||
Regular → Executable
+8
-20
@@ -1,26 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
cd "$(dirname "$0")" && source ./lib.sh
|
||||
|
||||
VM_ID=3000
|
||||
VM_NAME="Ubuntu-24-04-LTS-Medium-Docker"
|
||||
CPU_CORE=2
|
||||
CPU_SOCKET=2
|
||||
RAM=4096
|
||||
DISK=50
|
||||
#getting latest image"
|
||||
#wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
|
||||
#installing qemu guest agent and remove HW ID
|
||||
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
|
||||
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""
|
||||
IMAGE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
|
||||
PACKAGES=""
|
||||
DOCKER=1
|
||||
|
||||
build_template
|
||||
Regular → Executable
+8
-20
@@ -1,26 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
cd "$(dirname "$0")" && source ./lib.sh
|
||||
|
||||
VM_ID=2000
|
||||
VM_NAME="Ubuntu-24-04-LTS-Small"
|
||||
CPU_CORE=2
|
||||
CPU_SOCKET=2
|
||||
RAM=2048
|
||||
DISK=50
|
||||
#getting latest image"
|
||||
wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
|
||||
#installing qemu guest agent and remove HW ID
|
||||
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
|
||||
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""
|
||||
IMAGE_URL="https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
|
||||
PACKAGES=""
|
||||
DOCKER=0
|
||||
|
||||
build_template
|
||||
@@ -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
|
||||
@@ -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"
|
||||
}
|
||||
Reference in new issue
Block a user