Some checks failed
Test / test (push) Has been cancelled
Co-authored-by: Cursor <cursoragent@cursor.com>
127 lines
3.3 KiB
Bash
Executable File
127 lines
3.3 KiB
Bash
Executable File
#!/bin/bash
|
|
source ~/.bashrc
|
|
# Check VM Status and Verify Prerequisites Before Next Steps
|
|
|
|
set -e
|
|
|
|
# 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_step() {
|
|
echo -e "${BLUE}[STEP]${NC} $1"
|
|
}
|
|
|
|
log_header() {
|
|
echo -e "${CYAN}========================================${NC}"
|
|
echo -e "${CYAN}$1${NC}"
|
|
echo -e "${CYAN}========================================${NC}"
|
|
}
|
|
|
|
# Check VM connectivity
|
|
check_vm_connectivity() {
|
|
local ip=$1
|
|
local name=$2
|
|
|
|
log_info "Checking $name ($ip)..."
|
|
|
|
# Ping test
|
|
if ping -c 1 -W 2 "$ip" >/dev/null 2>&1; then
|
|
log_info "✓ $name is reachable"
|
|
|
|
# Check if SSH is available
|
|
if timeout 2 bash -c "echo >/dev/tcp/$ip/22" 2>/dev/null; then
|
|
log_info "✓ SSH port (22) is open"
|
|
|
|
# Try to check if Ubuntu is installed
|
|
if ssh -o ConnectTimeout=3 -o StrictHostKeyChecking=no "ubuntu@$ip" "lsb_release -d 2>/dev/null || echo 'OS check failed'" 2>/dev/null | grep -q "Ubuntu"; then
|
|
log_info "✓ Ubuntu is installed"
|
|
return 0
|
|
else
|
|
log_warn "✗ Ubuntu installation not verified (may need manual check)"
|
|
return 1
|
|
fi
|
|
else
|
|
log_warn "✗ SSH not available yet (OS may still be installing)"
|
|
return 1
|
|
fi
|
|
else
|
|
log_warn "✗ $name is not reachable"
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
# VM configurations
|
|
declare -A VMS=(
|
|
["100"]="cloudflare-tunnel:192.168.1.60:scripts/setup-cloudflare-tunnel.sh"
|
|
["101"]="k3s-master:192.168.1.188:scripts/setup-k3s.sh"
|
|
["102"]="git-server:192.168.1.121:scripts/setup-git-server.sh"
|
|
["103"]="observability:192.168.1.82:scripts/setup-observability.sh"
|
|
)
|
|
|
|
main() {
|
|
log_header "VM Status Check - Prerequisites Verification"
|
|
echo ""
|
|
|
|
log_step "Checking VM Connectivity and OS Installation"
|
|
echo ""
|
|
|
|
local all_ready=true
|
|
|
|
for vmid in "${!VMS[@]}"; do
|
|
IFS=':' read -r name ip script <<< "${VMS[$vmid]}"
|
|
echo "--- $name (ID: $vmid) ---"
|
|
|
|
if check_vm_connectivity "$ip" "$name"; then
|
|
log_info "✓ $name is ready for setup"
|
|
else
|
|
log_warn "✗ $name is not ready yet"
|
|
all_ready=false
|
|
fi
|
|
echo ""
|
|
done
|
|
|
|
log_header "Status Summary"
|
|
echo ""
|
|
|
|
if [ "$all_ready" = true ]; then
|
|
log_info "✅ All VMs are ready for setup scripts!"
|
|
echo ""
|
|
log_info "Next: Run setup scripts on each VM:"
|
|
for vmid in "${!VMS[@]}"; do
|
|
IFS=':' read -r name ip script <<< "${VMS[$vmid]}"
|
|
echo " - $name: ssh ubuntu@$ip 'sudo bash $script'"
|
|
done
|
|
else
|
|
log_warn "⚠️ Some VMs are not ready yet"
|
|
echo ""
|
|
log_info "Please complete Ubuntu installation on all VMs first:"
|
|
echo " 1. Access Proxmox Web UI: https://192.168.1.206:8006"
|
|
echo " 2. Open console for each VM"
|
|
echo " 3. Complete Ubuntu 24.04 installation"
|
|
echo " 4. Configure static IP addresses"
|
|
echo " 5. Run this script again to verify"
|
|
fi
|
|
|
|
echo ""
|
|
}
|
|
|
|
main "$@"
|
|
|