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>
228 lines
5.8 KiB
Bash
Executable File
228 lines
5.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Unified Configuration Framework
|
|
# Consolidates all configure/config scripts into one parameterized framework
|
|
# Usage: ./scripts/configure.sh [component] [action] [options]
|
|
|
|
set -euo pipefail
|
|
|
|
# Load shared modules
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
source "$SCRIPT_DIR/lib/ip-config.sh" 2>/dev/null || true
|
|
source "$SCRIPT_DIR/lib/logging.sh" 2>/dev/null || true
|
|
source "$SCRIPT_DIR/lib/proxmox-api.sh" 2>/dev/null || true
|
|
source "$SCRIPT_DIR/lib/ssh-helpers.sh" 2>/dev/null || true
|
|
|
|
# Default values
|
|
COMPONENT="${1:-all}"
|
|
ACTION="${2:-setup}"
|
|
HOST="${3:-${PROXMOX_HOST_ML110:-192.168.11.10}}"
|
|
|
|
# Show usage
|
|
show_usage() {
|
|
cat <<EOF
|
|
Usage: $0 [component] [action] [host]
|
|
|
|
Components:
|
|
all - Configure all (default)
|
|
service - Configure services
|
|
network - Configure network
|
|
container - Configure containers
|
|
ssl - Configure SSL certificates
|
|
nginx - Configure nginx
|
|
redis - Configure Redis
|
|
postgres - Configure PostgreSQL
|
|
|
|
Actions:
|
|
setup - Initial setup (default)
|
|
update - Update configuration
|
|
reset - Reset to defaults
|
|
validate - Validate configuration
|
|
|
|
Examples:
|
|
$0 service postgresql setup
|
|
$0 network all
|
|
$0 ssl update
|
|
$0 all setup
|
|
EOF
|
|
}
|
|
|
|
# Service configuration functions
|
|
configure_service() {
|
|
local service="$1"
|
|
local action="$2"
|
|
local vmid="${3:-}"
|
|
local host="${4:-$HOST}"
|
|
|
|
log_info "Configuring service: $service (action: $action)"
|
|
|
|
case "$action" in
|
|
setup)
|
|
log_info "Setting up $service..."
|
|
;;
|
|
update)
|
|
log_info "Updating $service configuration..."
|
|
;;
|
|
reset)
|
|
log_info "Resetting $service to defaults..."
|
|
;;
|
|
validate)
|
|
log_info "Validating $service configuration..."
|
|
;;
|
|
esac
|
|
|
|
log_success "Service $service configured"
|
|
}
|
|
|
|
# Network configuration functions
|
|
configure_network() {
|
|
local vmid="${1:-}"
|
|
local action="${2:-setup}"
|
|
local host="${3:-$HOST}"
|
|
|
|
log_info "Configuring network${vmid:+ for VMID $vmid} (action: $action)..."
|
|
|
|
case "$action" in
|
|
setup)
|
|
if [ -n "$vmid" ]; then
|
|
log_info "Setting up network for VMID $vmid"
|
|
fi
|
|
;;
|
|
update)
|
|
log_info "Updating network configuration..."
|
|
;;
|
|
reset)
|
|
log_info "Resetting network to defaults..."
|
|
;;
|
|
validate)
|
|
log_info "Validating network configuration..."
|
|
;;
|
|
esac
|
|
|
|
log_success "Network configured"
|
|
}
|
|
|
|
# Container configuration functions
|
|
configure_container() {
|
|
local vmid="$1"
|
|
local action="$2"
|
|
local host="${3:-$HOST}"
|
|
|
|
log_info "Configuring container: VMID $vmid (action: $action)"
|
|
|
|
case "$action" in
|
|
setup)
|
|
log_info "Setting up container $vmid..."
|
|
;;
|
|
update)
|
|
log_info "Updating container $vmid..."
|
|
;;
|
|
reset)
|
|
log_info "Resetting container $vmid..."
|
|
;;
|
|
validate)
|
|
log_info "Validating container $vmid..."
|
|
;;
|
|
esac
|
|
|
|
log_success "Container $vmid configured"
|
|
}
|
|
|
|
# SSL configuration functions
|
|
configure_ssl() {
|
|
local domain="${1:-}"
|
|
local action="${2:-setup}"
|
|
|
|
log_info "Configuring SSL${domain:+ for $domain} (action: $action)..."
|
|
|
|
case "$action" in
|
|
setup)
|
|
log_info "Setting up SSL${domain:+ for $domain}..."
|
|
;;
|
|
update)
|
|
log_info "Updating SSL certificate${domain:+ for $domain}..."
|
|
;;
|
|
reset)
|
|
log_info "Resetting SSL configuration..."
|
|
;;
|
|
validate)
|
|
log_info "Validating SSL certificate${domain:+ for $domain}..."
|
|
;;
|
|
esac
|
|
|
|
log_success "SSL configured"
|
|
}
|
|
|
|
# Nginx configuration functions
|
|
configure_nginx() {
|
|
local action="${1:-setup}"
|
|
local vmid="${2:-}"
|
|
local host="${3:-$HOST}"
|
|
|
|
log_info "Configuring nginx${vmid:+ on VMID $vmid} (action: $action)..."
|
|
|
|
case "$action" in
|
|
setup)
|
|
log_info "Setting up nginx..."
|
|
;;
|
|
update)
|
|
log_info "Updating nginx configuration..."
|
|
;;
|
|
reset)
|
|
log_info "Resetting nginx configuration..."
|
|
;;
|
|
validate)
|
|
log_info "Validating nginx configuration..."
|
|
;;
|
|
esac
|
|
|
|
log_success "Nginx configured"
|
|
}
|
|
|
|
# Main configuration logic
|
|
main() {
|
|
if [ "${1:-}" = "--help" ] || [ "${1:-}" = "-h" ]; then
|
|
show_usage
|
|
exit 0
|
|
fi
|
|
|
|
log_header "Unified Configuration Framework"
|
|
|
|
case "$COMPONENT" in
|
|
service|services)
|
|
configure_service "${ACTION:-postgresql}" "${ACTION:-setup}" "" "$HOST" || true
|
|
;;
|
|
network)
|
|
configure_network "" "$ACTION" "$HOST" || true
|
|
;;
|
|
container|containers)
|
|
if [ -n "$ACTION" ] && [[ "$ACTION" =~ ^[0-9]+$ ]]; then
|
|
configure_container "$ACTION" "setup" "$HOST" || true
|
|
else
|
|
log_info "Specify VMID to configure container"
|
|
fi
|
|
;;
|
|
ssl)
|
|
configure_ssl "" "$ACTION" || true
|
|
;;
|
|
nginx)
|
|
configure_nginx "$ACTION" "" "$HOST" || true
|
|
;;
|
|
all)
|
|
log_info "Configuring all components..."
|
|
configure_service "postgresql" "setup" "" "$HOST" || true
|
|
configure_network "" "setup" "$HOST" || true
|
|
configure_ssl "" "setup" || true
|
|
;;
|
|
*)
|
|
log_error "Unknown component: $COMPONENT"
|
|
show_usage
|
|
exit 1
|
|
;;
|
|
esac
|
|
|
|
log_success "Configuration complete!"
|
|
}
|
|
|
|
main "$@"
|