mirror of
https://github.com/myronblair/ProxMailcow
synced 2026-06-30 17:50:40 -05:00
65 lines
1.9 KiB
Bash
65 lines
1.9 KiB
Bash
#!/bin/bash
|
|
# Complete NPM VM 200 setup
|
|
# The cloud image disk was already imported as unused0 during initial VM creation.
|
|
# This script attaches the disk, configures cloud-init, resizes, and starts the VM.
|
|
#
|
|
# Run on Proxmox host: bash proxmox/01-complete-npm-vm.sh
|
|
|
|
set -euo pipefail
|
|
|
|
VMID=200
|
|
VMNAME="NginxProxyManager"
|
|
IP="10.48.200.80"
|
|
GW="10.48.200.1"
|
|
DNS="8.8.8.8,1.1.1.1"
|
|
DISK_SIZE="20G"
|
|
SNIPPETS_DIR="/var/lib/vz/snippets"
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
echo "=== Configuring VM ${VMID}: ${VMNAME} ==="
|
|
|
|
# Attach the imported disk as scsi0
|
|
echo "[1/7] Attaching disk..."
|
|
qm set ${VMID} --scsi0 local-lvm:vm-${VMID}-disk-0,discard=on,ssd=1
|
|
|
|
# Add cloud-init CD-ROM drive
|
|
echo "[2/7] Adding cloud-init drive..."
|
|
qm set ${VMID} --ide2 local-lvm:cloudinit
|
|
|
|
# Set boot order
|
|
echo "[3/7] Setting boot order..."
|
|
qm set ${VMID} --boot order=scsi0
|
|
|
|
# Upload cloud-init snippet
|
|
echo "[4/7] Uploading cloud-init snippet..."
|
|
mkdir -p ${SNIPPETS_DIR}
|
|
cp "${SCRIPT_DIR}/snippets/npm-cloud-init.yaml" "${SNIPPETS_DIR}/npm-cloud-init.yaml"
|
|
|
|
# Configure cloud-init parameters
|
|
# NOTE: Use space-separated nameservers (not comma) to avoid netplan bug
|
|
echo "[5/7] Configuring cloud-init..."
|
|
qm set ${VMID} \
|
|
--ciuser ubuntu \
|
|
--cipassword 'mailstack2024!' \
|
|
--ipconfig0 ip=${IP}/24,gw=${GW} \
|
|
--nameserver "8.8.8.8 1.1.1.1" \
|
|
--searchdomain web.orbishosting.com \
|
|
--cicustom "vendor=local:snippets/npm-cloud-init.yaml"
|
|
|
|
# Resize disk
|
|
echo "[6/7] Resizing disk to ${DISK_SIZE}..."
|
|
qm resize ${VMID} scsi0 ${DISK_SIZE}
|
|
|
|
# Start VM
|
|
echo "[7/7] Starting VM ${VMID}..."
|
|
qm start ${VMID}
|
|
|
|
echo ""
|
|
echo "=== VM ${VMID} started ==="
|
|
echo "IP: ${IP}"
|
|
echo "SSH: ssh ubuntu@${IP} (password: mailstack2024!)"
|
|
echo "NPM Admin UI: http://${IP}:81"
|
|
echo ""
|
|
echo "Cloud-init will run for ~3-5 minutes to install Docker and start NPM."
|
|
echo "Monitor with: ssh ubuntu@${IP} 'sudo tail -f /var/log/cloud-init-output.log'"
|