netgescon-master/scripts/proxmox-netgescon-deploy.sh

167 lines
4.7 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# proxmox-netgescon-deploy.sh - Script per deployment rapido NetGescon su Proxmox
set -e
# Colori per output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1"; }
log_step() { echo -e "${BLUE}[STEP]${NC} $1"; }
# Configurazione
TEMPLATE_ID=9000
PROD_VM_ID=100
DEV_VM_ID=101
CLIENT_VM_ID=102
# Verifica se siamo su Proxmox
if ! command -v qm &> /dev/null; then
log_error "Questo script deve essere eseguito su un server Proxmox VE"
exit 1
fi
echo "🏗️ NetGescon Proxmox Deployment Script"
echo "========================================"
log_step "1/6 Verifica template base..."
if qm status $TEMPLATE_ID &>/dev/null; then
log_info "Template $TEMPLATE_ID trovato"
else
log_error "Template $TEMPLATE_ID non trovato. Creare prima il template base."
exit 1
fi
log_step "2/6 Creazione VM Production (ID: $PROD_VM_ID)..."
qm clone $TEMPLATE_ID $PROD_VM_ID \
--name netgescon-production \
--description "NetGescon Production Server - Master instance" \
--full
# Configurazione specifica Production
qm set $PROD_VM_ID \
--memory 6144 \
--cores 4 \
--onboot 1 \
--startup order=1 \
--protection 1
log_info "VM Production creata (ID: $PROD_VM_ID)"
log_step "3/6 Creazione VM Development (ID: $DEV_VM_ID)..."
qm clone $TEMPLATE_ID $DEV_VM_ID \
--name netgescon-development \
--description "NetGescon Development Server - Team workspace"
# Configurazione specifica Development
qm set $DEV_VM_ID \
--memory 4096 \
--cores 2 \
--onboot 0 \
--startup order=2
log_info "VM Development creata (ID: $DEV_VM_ID)"
log_step "4/6 Creazione VM Client Test (ID: $CLIENT_VM_ID)..."
qm clone $TEMPLATE_ID $CLIENT_VM_ID \
--name netgescon-client-test \
--description "NetGescon Client Test - Remote update testing"
# Configurazione specifica Client Test
qm set $CLIENT_VM_ID \
--memory 3072 \
--cores 2 \
--onboot 0 \
--startup order=3
log_info "VM Client Test creata (ID: $CLIENT_VM_ID)"
log_step "5/6 Configurazione network..."
# Assegnazione IP statici (opzionale)
# qm set $PROD_VM_ID --ipconfig0 ip=192.168.1.100/24,gw=192.168.1.1
# qm set $DEV_VM_ID --ipconfig0 ip=192.168.1.101/24,gw=192.168.1.1
# qm set $CLIENT_VM_ID --ipconfig0 ip=192.168.1.102/24,gw=192.168.1.1
log_step "6/6 Avvio VM..."
# Avvio sequenziale
qm start $PROD_VM_ID
sleep 30
qm start $DEV_VM_ID
sleep 30
qm start $CLIENT_VM_ID
log_info "Tutte le VM sono state create e avviate"
echo ""
echo "═══════════════════════════════════════════════════════"
echo "✅ DEPLOYMENT COMPLETATO!"
echo "═══════════════════════════════════════════════════════"
echo ""
echo "🏭 VM PRODUCTION (ID: $PROD_VM_ID)"
echo " Nome: netgescon-production"
echo " RAM: 6GB, CPU: 4 cores"
echo " Avvio automatico: SÌ"
echo " Ruolo: Master/Produzione"
echo ""
echo "🔧 VM DEVELOPMENT (ID: $DEV_VM_ID)"
echo " Nome: netgescon-development"
echo " RAM: 4GB, CPU: 2 cores"
echo " Avvio automatico: NO"
echo " Ruolo: Sviluppo Team"
echo ""
echo "🧪 VM CLIENT TEST (ID: $CLIENT_VM_ID)"
echo " Nome: netgescon-client-test"
echo " RAM: 3GB, CPU: 2 cores"
echo " Avvio automatico: NO"
echo " Ruolo: Test Cliente/Aggiornamenti"
echo ""
echo "═══════════════════════════════════════════════════════"
echo ""
echo "🔧 NEXT STEPS:"
echo ""
echo "1⃣ ACCEDI ALLE VM:"
echo " ssh netgescon@[IP_VM]"
echo ""
echo "2⃣ SETUP NETGESCON:"
echo " ./setup-netgescon.sh"
echo " ./setup-laravel.sh"
echo " ./nginx-config.sh"
echo ""
echo "3⃣ CONFIGURA GIT (DEV VM):"
echo " git remote add origin [repo]"
echo " git branch development"
echo ""
echo "4⃣ SETUP BACKUP SINCRONIZZATO:"
echo " rsync, git hooks, automated deployment"
echo ""
# Salva configurazione
cat > /tmp/netgescon-vm-config.txt <<EOF
NetGescon Proxmox Deployment
============================
Data: $(date)
Template ID: $TEMPLATE_ID
VM Production: $PROD_VM_ID (netgescon-production)
VM Development: $DEV_VM_ID (netgescon-development)
VM Client Test: $CLIENT_VM_ID (netgescon-client-test)
Configurazione Storage:
- Template: $(qm config $TEMPLATE_ID | grep -E "scsi0|ide0|sata0")
- Dischi clonati con thin provisioning
Network:
- Bridge: vmbr0
- DHCP attivo (configurare IP statici se necessario)
EOF
log_info "Configurazione salvata in: /tmp/netgescon-vm-config.txt"