Files
proxmox/scripts/archive/consolidated/deploy/install-services-robust.sh
defiQUG fbda1b4beb
Some checks failed
Deploy to Phoenix / deploy (push) Has been cancelled
docs: Ledger Live integration, contract deploy learnings, NEXT_STEPS updates
- 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>
2026-02-12 15:46:57 -08:00

120 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
# Robust Service Installation Script
# Handles SSH connection issues and retries
set -uo pipefail
NODE_IP="${PROXMOX_HOST_R630_01}"
MAX_RETRIES=3
RETRY_DELAY=2
log_info() { echo -e "\033[0;32m[INFO]\033[0m $1"; }
log_error() { echo -e "\033[0;31m[ERROR]\033[0m $1"; }
log_success() { echo -e "\033[0;32m[✓]\033[0m $1"; }
# Robust SSH execution with retries
ssh_exec() {
local vmid="$1"
local command="$2"
local retry=0
while [ $retry -lt $MAX_RETRIES ]; do
if ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o ServerAliveInterval=5 root@${NODE_IP} "pct exec $vmid -- bash -c '$command'" 2>&1; then
return 0
fi
retry=$((retry + 1))
if [ $retry -lt $MAX_RETRIES ]; then
log_info "Retry $retry/$MAX_RETRIES for CT $vmid..."
sleep $RETRY_DELAY
fi
done
return 1
}
# Install PostgreSQL
install_postgresql() {
local vmid="$1"
log_info "Installing PostgreSQL on CT $vmid..."
ssh_exec "$vmid" "
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq postgresql-15 postgresql-contrib-15 || exit 1
# Configure PostgreSQL
sed -i \"s/#listen_addresses = .*/listen_addresses = '*'/\" /etc/postgresql/15/main/postgresql.conf 2>/dev/null || true
echo \"host all all 0.0.0.0/0 md5\" >> /etc/postgresql/15/main/pg_hba.conf 2>/dev/null || true
systemctl enable postgresql@15-main
systemctl start postgresql@15-main
sleep 3
systemctl is-active postgresql@15-main && echo 'PostgreSQL installed' || exit 1
" && log_success "PostgreSQL installed on CT $vmid" || log_error "Failed to install PostgreSQL on CT $vmid"
}
# Install Redis
install_redis() {
local vmid="$1"
log_info "Installing Redis on CT $vmid..."
ssh_exec "$vmid" "
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq redis-server || exit 1
sed -i \"s/^bind .*/bind 0.0.0.0/\" /etc/redis/redis.conf 2>/dev/null || true
systemctl enable redis-server
systemctl restart redis-server
sleep 2
systemctl is-active redis-server && echo 'Redis installed' || exit 1
" && log_success "Redis installed on CT $vmid" || log_error "Failed to install Redis on CT $vmid"
}
# Install Node.js
install_nodejs() {
local vmid="$1"
log_info "Installing Node.js on CT $vmid..."
ssh_exec "$vmid" "
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq curl ca-certificates gnupg || exit 1
curl -fsSL https://deb.nodesource.com/setup_18.x | bash - || exit 1
apt-get install -y -qq nodejs || exit 1
npm install -g pm2 || exit 1
node --version && npm --version && echo 'Node.js installed' || exit 1
" && log_success "Node.js installed on CT $vmid" || log_error "Failed to install Node.js on CT $vmid"
}
# Main execution
echo "═══════════════════════════════════════════════════════════"
echo "Robust Service Installation"
echo "═══════════════════════════════════════════════════════════"
echo ""
# Install PostgreSQL
log_info "Installing PostgreSQL on database containers..."
for vmid in 10000 10001 10100 10101; do
install_postgresql "$vmid"
sleep 1
done
# Install Redis
log_info "Installing Redis on cache containers..."
for vmid in 10020 10120; do
install_redis "$vmid"
sleep 1
done
# Install Node.js
log_info "Installing Node.js on application containers..."
for vmid in 10030 10040 10050 10060 10070 10080 10090 10091 10092 10130 10150 10151; do
install_nodejs "$vmid"
sleep 1
done
echo ""
log_info "Installation complete!"