mirror of
https://github.com/kossakovsky/n8n-install.git
synced 2026-03-07 22:33:11 +00:00
refactor: consolidate shared utilities and add script documentation
- move common functions to utils.sh: init_paths, read_env_var, write_env_var, is_profile_active, load_env, gen_password, gen_hex, gen_base64, generate_bcrypt_hash - add documentation headers to all installation scripts - replace duplicate code with shared utility calls - consolidate bcrypt hash generation loop in 03_generate_secrets.sh - add DEBIAN_FRONTEND save/restore helpers for whiptail scripts - standardize path initialization across all scripts
This commit is contained in:
@@ -1,47 +1,50 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# 06_run_services.sh - Service launcher
|
||||
# =============================================================================
|
||||
# Starts all selected services using Docker Compose via start_services.py.
|
||||
#
|
||||
# Pre-flight checks:
|
||||
# - Verifies .env, docker-compose.yml, and Caddyfile exist
|
||||
# - Ensures Docker daemon is running
|
||||
# - Makes start_services.py executable if needed
|
||||
#
|
||||
# The actual service orchestration is handled by start_services.py which:
|
||||
# - Starts services in correct dependency order
|
||||
# - Handles profile-based service selection
|
||||
# - Manages health checks and startup timeouts
|
||||
#
|
||||
# Usage: bash scripts/06_run_services.sh
|
||||
# =============================================================================
|
||||
|
||||
set -e
|
||||
|
||||
# Source the utilities file
|
||||
# Source the utilities file and initialize paths
|
||||
source "$(dirname "$0")/utils.sh"
|
||||
init_paths
|
||||
|
||||
# 1. Check for .env file
|
||||
if [ ! -f ".env" ]; then
|
||||
log_error ".env file not found in project root." >&2
|
||||
exit 1
|
||||
fi
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
# 2. Check for docker-compose.yml file
|
||||
if [ ! -f "docker-compose.yml" ]; then
|
||||
log_error "docker-compose.yml file not found in project root." >&2
|
||||
exit 1
|
||||
fi
|
||||
# Check required files
|
||||
require_file "$ENV_FILE" ".env file not found in project root."
|
||||
require_file "$PROJECT_ROOT/docker-compose.yml" "docker-compose.yml file not found in project root."
|
||||
require_file "$PROJECT_ROOT/Caddyfile" "Caddyfile not found in project root. Reverse proxy might not work."
|
||||
require_file "$PROJECT_ROOT/start_services.py" "start_services.py file not found in project root."
|
||||
|
||||
# 3. Check for Caddyfile (optional but recommended for reverse proxy)
|
||||
if [ ! -f "Caddyfile" ]; then
|
||||
log_warning "Caddyfile not found in project root. Reverse proxy might not work as expected." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 4. Check if Docker daemon is running
|
||||
# Check if Docker daemon is running
|
||||
if ! docker info > /dev/null 2>&1; then
|
||||
log_error "Docker daemon is not running. Please start Docker and try again." >&2
|
||||
log_error "Docker daemon is not running. Please start Docker and try again."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 5. Check if start_services.py exists and is executable
|
||||
if [ ! -f "start_services.py" ]; then
|
||||
log_error "start_services.py file not found in project root." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x "start_services.py" ]; then
|
||||
# Ensure start_services.py is executable
|
||||
if [ ! -x "$PROJECT_ROOT/start_services.py" ]; then
|
||||
log_warning "start_services.py is not executable. Making it executable..."
|
||||
chmod +x "start_services.py"
|
||||
chmod +x "$PROJECT_ROOT/start_services.py"
|
||||
fi
|
||||
|
||||
log_info "Launching services using start_services.py..."
|
||||
# Execute start_services.py
|
||||
./start_services.py
|
||||
"$PROJECT_ROOT/start_services.py"
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user