Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
- ADD_CHAIN138_TO_LEDGER_LIVE: Ledger form done; public code review repo bis-innovations/LedgerLive; init/push commands - CONTRACT_DEPLOYMENT_RUNBOOK: Chain 138 gas price 1 gwei, 36-addr check, TransactionMirror workaround - CONTRACT_*: AddressMapper, MirrorManager deployed 2026-02-12; 36-address on-chain check - NEXT_STEPS_FOR_YOU: Ledger done; steps completable now (no LAN); run-completable-tasks-from-anywhere - MASTER_INDEX, OPERATOR_OPTIONAL, SMART_CONTRACTS_INVENTORY_SIMPLE: updates - LEDGER_BLOCKCHAIN_INTEGRATION_COMPLETE: bis-innovations/LedgerLive reference Co-authored-by: Cursor <cursoragent@cursor.com>
176 lines
7.0 KiB
Bash
Executable File
176 lines
7.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Install nginx on VMID 7810 (mim-web-1) for mim4u.org
|
|
# This script works around network connectivity issues by using local installation
|
|
|
|
set -euo pipefail
|
|
|
|
# Load IP configuration
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
source "${PROJECT_ROOT}/config/ip-addresses.conf" 2>/dev/null || true
|
|
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
log_info() { echo -e "${BLUE}[INFO]${NC} $1"; }
|
|
log_success() { echo -e "${GREEN}[✓]${NC} $1"; }
|
|
log_warn() { echo -e "${YELLOW}[⚠]${NC} $1"; }
|
|
log_error() { echo -e "${RED}[✗]${NC} $1"; }
|
|
|
|
PROXMOX_HOST="${1:-192.168.11.12}"
|
|
VMID="${2:-7810}"
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo "🔧 Installing nginx on VMID $VMID (mim-web-1)"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
|
|
# Step 1: Clear apt locks
|
|
log_info "Clearing apt locks..."
|
|
ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- bash -c 'killall -9 apt-get apt 2>/dev/null || true; rm -f /var/lib/apt/lists/lock /var/cache/apt/archives/lock /var/lib/dpkg/lock* 2>/dev/null; dpkg --configure -a 2>/dev/null || true'"
|
|
|
|
# Step 2: Check if nginx is already installed
|
|
log_info "Checking if nginx is installed..."
|
|
if ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- which nginx 2>/dev/null" >/dev/null 2>&1; then
|
|
log_success "nginx is already installed"
|
|
INSTALLED=true
|
|
else
|
|
log_info "nginx not installed, proceeding with installation..."
|
|
INSTALLED=false
|
|
fi
|
|
|
|
# Step 3: Try installation with timeout and offline-first approach
|
|
if [ "$INSTALLED" = false ]; then
|
|
log_info "Attempting nginx installation (this may take a while)..."
|
|
|
|
# Try installing with very short timeouts to fail fast if network is unavailable
|
|
INSTALL_OUTPUT=$(ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} \
|
|
"timeout 120 pct exec ${VMID} -- bash -c '
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
export APT_LISTCHANGES_FRONTEND=none
|
|
|
|
# Update package lists with short timeout
|
|
apt-get update -o Acquire::http::Timeout=3 -o Acquire::https::Timeout=3 2>&1 || true
|
|
|
|
# Install nginx (will use cached packages if available)
|
|
apt-get install -y -o Acquire::http::Timeout=3 -o Acquire::https::Timeout=3 nginx 2>&1
|
|
'" 2>&1)
|
|
|
|
# Check if installation succeeded
|
|
if echo "$INSTALL_OUTPUT" | grep -q "Setting up nginx"; then
|
|
log_success "nginx installed successfully"
|
|
elif ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- which nginx 2>/dev/null" >/dev/null 2>&1; then
|
|
log_success "nginx is installed (verified)"
|
|
else
|
|
log_error "nginx installation failed due to network issues"
|
|
log_info "Installation output:"
|
|
echo "$INSTALL_OUTPUT" | tail -20
|
|
log_warn "Manual installation required:"
|
|
log_info " 1. Fix network connectivity on VM 7810, OR"
|
|
log_info " 2. Download nginx .deb packages and install manually"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
# Step 4: Verify nginx installation
|
|
log_info "Verifying nginx installation..."
|
|
if ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- nginx -v 2>&1" >/dev/null 2>&1; then
|
|
NGINX_VERSION=$(ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- nginx -v 2>&1" | cut -d'/' -f2)
|
|
log_success "nginx version: $NGINX_VERSION"
|
|
else
|
|
log_error "nginx installation verification failed"
|
|
exit 1
|
|
fi
|
|
|
|
# Step 5: Configure basic nginx for mim4u.org
|
|
log_info "Configuring nginx for mim4u.org..."
|
|
ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- bash -c '
|
|
# Create basic nginx config
|
|
cat > /etc/nginx/sites-available/mim4u <<EOF
|
|
server {
|
|
listen 80;
|
|
server_name mim4u.org www.mim4u.org;
|
|
|
|
root /var/www/html;
|
|
index index.html index.htm;
|
|
|
|
location / {
|
|
try_files \$uri \$uri/ =404;
|
|
}
|
|
|
|
# Health check endpoint
|
|
location /health {
|
|
access_log off;
|
|
return 200 \"healthy\\n\";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|
|
EOF
|
|
|
|
# Create web root if it doesn'\''t exist
|
|
mkdir -p /var/www/html
|
|
echo \"<h1>mim4u.org</h1><p>Site is under construction</p>\" > /var/www/html/index.html
|
|
|
|
# Enable site
|
|
rm -f /etc/nginx/sites-enabled/default
|
|
ln -sf /etc/nginx/sites-available/mim4u /etc/nginx/sites-enabled/mim4u
|
|
|
|
# Test configuration
|
|
nginx -t
|
|
'"
|
|
|
|
# Step 6: Start and enable nginx
|
|
log_info "Starting nginx service..."
|
|
ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- systemctl enable nginx"
|
|
ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- systemctl start nginx"
|
|
|
|
# Step 7: Verify nginx is running and listening
|
|
log_info "Verifying nginx is listening on port 80..."
|
|
sleep 2
|
|
if ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- ss -tlnp 2>/dev/null | grep -q ':80 '"; then
|
|
log_success "nginx is listening on port 80"
|
|
else
|
|
log_warn "nginx may not be listening on port 80, checking status..."
|
|
ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} "pct exec ${VMID} -- systemctl status nginx | head -10" || true
|
|
fi
|
|
|
|
# Step 8: Test local connectivity
|
|
log_info "Testing local HTTP response..."
|
|
HTTP_CODE=$(ssh -o ConnectTimeout=10 root@${PROXMOX_HOST} \
|
|
"pct exec ${VMID} -- bash -c 'curl -s -o /dev/null -w \"%{http_code}\" --connect-timeout 3 http://127.0.0.1/ 2>/dev/null || echo \"000\"'" 2>/dev/null || echo "000")
|
|
|
|
if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "404" ]; then
|
|
log_success "nginx is responding (HTTP $HTTP_CODE)"
|
|
else
|
|
log_warn "nginx may not be responding correctly (HTTP $HTTP_CODE)"
|
|
fi
|
|
|
|
# Step 9: Test from NPMplus
|
|
log_info "Testing connectivity from NPMplus..."
|
|
NPMPLUS_HOST="${PROXMOX_HOST_R630_01}"
|
|
NPMPLUS_VMID="10233"
|
|
NPM_TEST=$(ssh -o ConnectTimeout=10 root@${NPMPLUS_HOST} \
|
|
"pct exec ${NPMPLUS_VMID} -- curl -s -o /dev/null -w \"%{http_code}\" --connect-timeout 5 http://${IP_MIM_WEB:-192.168.11.37}/ 2>/dev/null || echo \"000\"" 2>/dev/null || echo "000")
|
|
|
|
if [ "$NPM_TEST" = "200" ] || [ "$NPM_TEST" = "404" ]; then
|
|
log_success "NPMplus can reach backend (HTTP $NPM_TEST)"
|
|
else
|
|
log_warn "NPMplus connectivity test returned: $NPM_TEST"
|
|
fi
|
|
|
|
echo ""
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
log_success "Installation complete!"
|
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
echo ""
|
|
log_info "Next steps:"
|
|
log_info " 1. Verify: curl -I http://${IP_MIM_WEB:-192.168.11.37}/"
|
|
log_info " 2. Test public domain: curl -I https://mim4u.org/"
|
|
log_info " 3. Deploy actual MIM4U application files to /var/www/html"
|
|
echo ""
|