Files
Sankofa/scripts/create-template-from-image.sh
defiQUG 33d50fb91e
Some checks failed
API CI / API Lint (push) Successful in 47s
API CI / API Type Check (push) Failing after 47s
API CI / API Test (push) Successful in 1m0s
API CI / API Build (push) Failing after 50s
API CI / Build Docker Image (push) Has been skipped
Build Crossplane Provider / build (push) Failing after 5m51s
CD Pipeline / Deploy to Staging (push) Failing after 29s
CI Pipeline / Lint and Type Check (push) Failing after 36s
CI Pipeline / Build (push) Has been skipped
CI Pipeline / Test Backend (push) Failing after 1m33s
CI Pipeline / Test Frontend (push) Failing after 30s
CI Pipeline / Security Scan (push) Failing after 1m16s
Crossplane Provider CI / Go Test (push) Failing after 3m23s
Crossplane Provider CI / Go Lint (push) Failing after 7m27s
Crossplane Provider CI / Go Build (push) Failing after 3m27s
Deploy to Staging / Deploy to Staging (push) Failing after 30s
Portal CI / Portal Lint (push) Failing after 21s
Portal CI / Portal Type Check (push) Failing after 21s
Portal CI / Portal Test (push) Failing after 21s
Portal CI / Portal Build (push) Failing after 22s
Test Suite / frontend-tests (push) Failing after 30s
Test Suite / api-tests (push) Failing after 49s
Test Suite / blockchain-tests (push) Failing after 30s
Type Check / type-check (map[directory:. name:root]) (push) Failing after 23s
Type Check / type-check (map[directory:api name:api]) (push) Failing after 21s
Type Check / type-check (map[directory:portal name:portal]) (push) Failing after 19s
Validate Configuration Files / validate (push) Failing after 1m52s
CD Pipeline / Deploy to Production (push) Has been skipped
chore: consolidate local WIP (repo cleanup 20260707)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 09:41:34 -07:00

83 lines
3.1 KiB
Bash
Executable File

#!/bin/bash
# Create a Proxmox template from the cloud image in local:iso/
set -euo pipefail
echo "═══════════════════════════════════════════════════════════════════════════════"
echo " CREATE TEMPLATE FROM CLOUD IMAGE"
echo "═══════════════════════════════════════════════════════════════════════════════"
echo ""
SOURCE_IMAGE="/var/lib/vz/template/iso/ubuntu-22.04-cloud.img"
TEMPLATE_VMID=9000
TEMPLATE_NAME="ubuntu-22.04-cloud-template"
TARGET_STORAGE="local-lvm"
# Check if source exists
echo "Step 1: Checking if source image exists..."
if [ ! -f "$SOURCE_IMAGE" ]; then
echo "❌ Source image not found: $SOURCE_IMAGE"
exit 1
fi
IMAGE_SIZE=$(du -h "$SOURCE_IMAGE" | cut -f1)
echo "✅ Source image found: $SOURCE_IMAGE ($IMAGE_SIZE)"
echo ""
# Check if template already exists
echo "Step 2: Checking if template already exists..."
if qm list | grep -q "^${TEMPLATE_VMID}"; then
echo "⚠️ Template VM $TEMPLATE_VMID already exists"
read -p "Delete and recreate? (y/N) " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]; then
qm destroy "$TEMPLATE_VMID" 2>/dev/null || true
echo "✅ Old template removed"
else
echo "Using existing template"
exit 0
fi
fi
echo ""
# Create template VM
echo "Step 3: Creating template VM..."
qm create "$TEMPLATE_VMID" \
--name "$TEMPLATE_NAME" \
--memory 512 \
--net0 virtio,bridge=vmbr0 \
--agent enabled=1 \
--template 1 2>/dev/null || true
# Import the cloud image
echo "Step 4: Importing cloud image to template..."
echo " This will convert qcow2 to raw format for local-lvm..."
if qm disk import "$TEMPLATE_VMID" "$SOURCE_IMAGE" "$TARGET_STORAGE" --format raw 2>&1; then
echo "✅ Image imported successfully"
else
echo "❌ Import failed"
qm destroy "$TEMPLATE_VMID" 2>/dev/null || true
exit 1
fi
# Convert to template
echo ""
echo "Step 5: Converting VM to template..."
qm template "$TEMPLATE_VMID" 2>&1 || {
echo "⚠️ Template conversion failed, but VM is ready"
}
echo ""
echo "═══════════════════════════════════════════════════════════════════════════════"
echo " VERIFICATION"
echo "═══════════════════════════════════════════════════════════════════════════════"
echo ""
echo "Template VM status:"
qm list | grep "^${TEMPLATE_VMID}" || echo "Template not found"
echo ""
echo "✅ Template created! VMs can now clone from VMID $TEMPLATE_VMID"
echo ""
echo "📝 Note: Update VM image spec to use VMID: $TEMPLATE_VMID"
echo " Example: image: \"$TEMPLATE_VMID\""