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>
178 lines
6.2 KiB
Bash
Executable File
178 lines
6.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# Fix Container Permissions and Install Services
|
|
# Fixes unprivileged container permission issues and installs all services
|
|
|
|
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
|
|
|
|
NODE_IP="${PROXMOX_HOST_R630_01:-192.168.11.11}"
|
|
|
|
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"; }
|
|
|
|
# Fix permissions from host side
|
|
fix_container_permissions() {
|
|
local vmid="$1"
|
|
log_info "Fixing permissions for CT $vmid from host..."
|
|
|
|
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${NODE_IP} "
|
|
# Fix ownership from host
|
|
chown -R root:root /var/lib/vz/private/$vmid/var/lib/apt 2>/dev/null || true
|
|
chown -R root:root /var/lib/vz/private/$vmid/var/cache/apt 2>/dev/null || true
|
|
chown -R root:root /var/lib/vz/private/$vmid/var/lib/dpkg 2>/dev/null || true
|
|
|
|
# Remove lock files
|
|
rm -f /var/lib/vz/private/$vmid/var/lib/apt/lists/lock
|
|
rm -f /var/lib/vz/private/$vmid/var/lib/dpkg/lock*
|
|
rm -f /var/lib/vz/private/$vmid/var/cache/apt/archives/lock
|
|
|
|
echo 'Permissions fixed'
|
|
" && log_success "Permissions fixed for CT $vmid" || log_error "Failed to fix permissions for CT $vmid"
|
|
}
|
|
|
|
# Install PostgreSQL
|
|
install_postgresql() {
|
|
local vmid="$1"
|
|
log_info "Installing PostgreSQL on CT $vmid..."
|
|
|
|
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${NODE_IP} "pct enter $vmid <<'INSTALL_EOF'
|
|
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
|
|
INSTALL_EOF
|
|
" && 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 -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${NODE_IP} "pct enter $vmid <<'INSTALL_EOF'
|
|
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
|
|
INSTALL_EOF
|
|
" && 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 -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${NODE_IP} "pct enter $vmid <<'INSTALL_EOF'
|
|
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
|
|
INSTALL_EOF
|
|
" && log_success "Node.js installed on CT $vmid" || log_error "Failed to install Node.js on CT $vmid"
|
|
}
|
|
|
|
# Configure PostgreSQL databases
|
|
configure_postgresql_order() {
|
|
local vmid="$1"
|
|
log_info "Configuring Order database on CT $vmid..."
|
|
|
|
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${NODE_IP} "pct enter $vmid <<'CONFIG_EOF'
|
|
sudo -u postgres psql << 'SQL_EOF'
|
|
CREATE DATABASE order_db;
|
|
CREATE USER order_user WITH PASSWORD 'order_password';
|
|
GRANT ALL PRIVILEGES ON DATABASE order_db TO order_user;
|
|
ALTER DATABASE order_db OWNER TO order_user;
|
|
SQL_EOF
|
|
echo 'Order DB configured'
|
|
CONFIG_EOF
|
|
" && log_success "Order DB configured on CT $vmid" || log_error "Failed to configure Order DB on CT $vmid"
|
|
}
|
|
|
|
configure_postgresql_dbis() {
|
|
local vmid="$1"
|
|
log_info "Configuring DBIS database on CT $vmid..."
|
|
|
|
ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no root@${NODE_IP} "pct enter $vmid <<'CONFIG_EOF'
|
|
sudo -u postgres psql << 'SQL_EOF'
|
|
CREATE DATABASE dbis_core;
|
|
CREATE USER dbis WITH PASSWORD '8cba649443f97436db43b34ab2c0e75b5cf15611bef9c099cee6fb22cc3d7771';
|
|
GRANT ALL PRIVILEGES ON DATABASE dbis_core TO dbis;
|
|
ALTER DATABASE dbis_core OWNER TO dbis;
|
|
SQL_EOF
|
|
echo 'DBIS DB configured'
|
|
CONFIG_EOF
|
|
" && log_success "DBIS DB configured on CT $vmid" || log_error "Failed to configure DBIS DB on CT $vmid"
|
|
}
|
|
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
echo "Fix Permissions and Install All Services"
|
|
echo "═══════════════════════════════════════════════════════════"
|
|
echo ""
|
|
|
|
# Fix permissions for all containers
|
|
log_info "Fixing permissions for all containers..."
|
|
for vmid in 10000 10001 10020 10030 10040 10050 10060 10070 10080 10090 10091 10092 10100 10101 10120 10130 10150 10151; do
|
|
fix_container_permissions "$vmid"
|
|
sleep 1
|
|
done
|
|
|
|
# Install PostgreSQL
|
|
log_info "Installing PostgreSQL on database containers..."
|
|
for vmid in 10000 10001 10100 10101; do
|
|
install_postgresql "$vmid"
|
|
sleep 2
|
|
done
|
|
|
|
# Configure PostgreSQL databases
|
|
log_info "Configuring PostgreSQL databases..."
|
|
for vmid in 10000 10001; do
|
|
configure_postgresql_order "$vmid"
|
|
sleep 1
|
|
done
|
|
|
|
for vmid in 10100 10101; do
|
|
configure_postgresql_dbis "$vmid"
|
|
sleep 1
|
|
done
|
|
|
|
# Install Redis
|
|
log_info "Installing Redis on cache containers..."
|
|
for vmid in 10020 10120; do
|
|
install_redis "$vmid"
|
|
sleep 2
|
|
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 2
|
|
done
|
|
|
|
echo ""
|
|
log_info "Installation complete!"
|