Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
167 lines
4.6 KiB
Bash
Executable File
167 lines
4.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Master Deployment Script - Complete All Tasks
|
|
# Run this on each Proxmox server
|
|
|
|
set -e
|
|
|
|
# Server configuration
|
|
PVE_IP="192.168.1.207"
|
|
PVE2_IP="192.168.1.55"
|
|
|
|
# Colors
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
CYAN='\033[0;36m'
|
|
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_header() { echo -e "${CYAN}========================================${NC}\n${CYAN}$1${NC}\n${CYAN}========================================${NC}"; }
|
|
|
|
# Detect server
|
|
HOSTNAME=$(hostname)
|
|
CURRENT_IP=$(ip addr show | grep "inet.*192.168.1" | head -1 | awk '{print $2}' | cut -d/ -f1)
|
|
|
|
if [[ "$HOSTNAME" == "pve2"* ]] || [[ "$CURRENT_IP" == "192.168.1.55" ]]; then
|
|
SERVER="pve2"
|
|
SERVER_IP="192.168.1.55"
|
|
OTHER_SERVER="pve"
|
|
OTHER_IP="192.168.1.207"
|
|
log_info "Detected: pve2 (R630)"
|
|
elif [[ "$HOSTNAME" == "pve"* ]] || [[ "$CURRENT_IP" == "192.168.1.207" ]]; then
|
|
SERVER="pve"
|
|
SERVER_IP="192.168.1.207"
|
|
OTHER_SERVER="pve2"
|
|
OTHER_IP="192.168.1.55"
|
|
log_info "Detected: pve (ML110)"
|
|
else
|
|
log_error "Cannot detect server. Run with SERVER=pve or SERVER=pve2"
|
|
exit 1
|
|
fi
|
|
|
|
log_header "Complete Deployment - $SERVER ($SERVER_IP)"
|
|
|
|
# Task 1: Network Configuration
|
|
log_header "Task 1: Network Configuration"
|
|
|
|
if [ "$SERVER" = "pve2" ]; then
|
|
log_info "Configuring pve2 network (nic3→vmbr0, nic2→vmbr1)..."
|
|
cp /etc/network/interfaces /etc/network/interfaces.backup.$(date +%Y%m%d_%H%M%S)
|
|
|
|
cat > /etc/network/interfaces <<'EOF'
|
|
# Proxmox VE Network Configuration
|
|
# pve2 (R630) - 192.168.1.55
|
|
# nic3: LAN (192.168.1.0/24)
|
|
# nic2: WAN (Public IP from Spectrum modem)
|
|
|
|
auto lo
|
|
iface lo inet loopback
|
|
|
|
auto nic3
|
|
iface nic3 inet manual
|
|
|
|
auto vmbr0
|
|
iface vmbr0 inet dhcp
|
|
bridge-ports nic3
|
|
bridge-stp off
|
|
bridge-fd 0
|
|
bridge-vlan-aware no
|
|
metric 200
|
|
|
|
auto nic2
|
|
iface nic2 inet manual
|
|
|
|
auto vmbr1
|
|
iface vmbr1 inet dhcp
|
|
bridge-ports nic2
|
|
bridge-stp off
|
|
bridge-fd 0
|
|
bridge-vlan-aware no
|
|
metric 100
|
|
EOF
|
|
|
|
log_info "Network configuration written for pve2"
|
|
else
|
|
log_info "Configuring pve network..."
|
|
log_warn "Please manually configure /etc/network/interfaces"
|
|
log_info "See interfaces.pve-ml110 for template"
|
|
log_info "You need to determine your NIC names first:"
|
|
log_info " ip link show | grep -E '^[0-9]+: (nic|eth|enp)'"
|
|
fi
|
|
|
|
# Task 2: Update /etc/hosts
|
|
log_header "Task 2: Update /etc/hosts"
|
|
|
|
cp /etc/hosts /etc/hosts.backup.$(date +%Y%m%d_%H%M%S)
|
|
|
|
if grep -q "$OTHER_SERVER" /etc/hosts; then
|
|
sed -i "s/.*$OTHER_SERVER.*/$OTHER_IP $OTHER_SERVER $OTHER_SERVER.local/" /etc/hosts
|
|
log_info "Updated $OTHER_SERVER entry"
|
|
else
|
|
echo "$OTHER_IP $OTHER_SERVER $OTHER_SERVER.local" >> /etc/hosts
|
|
log_info "Added $OTHER_SERVER entry"
|
|
fi
|
|
|
|
# Task 3: Update corosync.conf
|
|
log_header "Task 3: Update corosync.conf"
|
|
|
|
if [ -f /etc/pve/corosync.conf ]; then
|
|
cp /etc/pve/corosync.conf /etc/pve/corosync.conf.backup.$(date +%Y%m%d_%H%M%S)
|
|
|
|
sed -i "s/ring0_addr:.*pve$/ring0_addr: 192.168.1.207/" /etc/pve/corosync.conf
|
|
sed -i "s/ring0_addr:.*pve2$/ring0_addr: 192.168.1.55/" /etc/pve/corosync.conf
|
|
|
|
log_info "Updated corosync.conf"
|
|
log_info "Configuration:"
|
|
grep ring0_addr /etc/pve/corosync.conf | sed 's/^/ /'
|
|
else
|
|
log_warn "corosync.conf not found - cluster may not be configured yet"
|
|
fi
|
|
|
|
# Task 4: Apply network (if pve2)
|
|
if [ "$SERVER" = "pve2" ]; then
|
|
log_header "Task 4: Apply Network Configuration"
|
|
log_warn "This will restart networking and may disconnect you"
|
|
read -p "Apply network configuration now? (yes/no): " APPLY
|
|
|
|
if [ "$APPLY" = "yes" ]; then
|
|
log_info "Applying network configuration..."
|
|
ifreload -a || systemctl restart networking
|
|
sleep 5
|
|
log_info "Network applied"
|
|
fi
|
|
fi
|
|
|
|
# Task 5: Restart cluster services
|
|
log_header "Task 5: Restart Cluster Services"
|
|
|
|
if [ -f /etc/pve/corosync.conf ]; then
|
|
log_warn "This will restart cluster services"
|
|
read -p "Restart cluster services now? (yes/no): " RESTART
|
|
|
|
if [ "$RESTART" = "yes" ]; then
|
|
systemctl restart corosync
|
|
sleep 2
|
|
systemctl restart pve-cluster
|
|
log_info "Cluster services restarted"
|
|
fi
|
|
fi
|
|
|
|
# Verification
|
|
log_header "Verification"
|
|
|
|
log_info "Current IP addresses:"
|
|
ip addr show | grep -E "vmbr|inet " | head -10
|
|
|
|
if [ -f /etc/pve/corosync.conf ]; then
|
|
log_info "Cluster configuration:"
|
|
grep ring0_addr /etc/pve/corosync.conf | sed 's/^/ /'
|
|
fi
|
|
|
|
log_header "Deployment Complete for $SERVER!"
|
|
log_info "Next: Complete the same steps on $OTHER_SERVER"
|
|
|