Initial Commit
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
# AMMIDS Setup Orchestrator
|
||||
# Author: Cortex@Fossgate
|
||||
# Src: https://git.fossgate.uk/ammids
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/init/scripts/functions.sh"
|
||||
resolve_paths
|
||||
|
||||
ENV_FILE="${ROOT_DIR}/.env"
|
||||
BACKUP_DIR="${ROOT_DIR}/backups"
|
||||
|
||||
log_info "=== AMMIDS Setup Orchestrator ==="
|
||||
|
||||
# 1. Environment Setup
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
log_warn ".env exists."
|
||||
read -r -p " Overwrite and create backup? [y/N]: " confirm
|
||||
if [[ "$confirm" =~ ^[Yy]$ ]]; then
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
BACKUP_FILE="${BACKUP_DIR}/.env.$(date +%Y%m%d_%H%M%S)"
|
||||
cp "$ENV_FILE" "$BACKUP_FILE"
|
||||
log_info "Backup created: $BACKUP_FILE"
|
||||
"${SCRIPT_DIR}/init/scripts/set_env.sh"
|
||||
else
|
||||
log_info "Preserving existing .env. Skipping regeneration."
|
||||
fi
|
||||
else
|
||||
log_info "No .env found. Running initial setup..."
|
||||
"${SCRIPT_DIR}/init/scripts/set_env.sh"
|
||||
fi
|
||||
|
||||
# 2. Load Environment & Resolve Paths
|
||||
source "$ENV_FILE"
|
||||
resolve_volume_path
|
||||
|
||||
# 3. Directory & Permission Management
|
||||
if [[ ! -d "$VOLUME_PATH" ]]; then
|
||||
log_info "Creating data directory: $VOLUME_PATH"
|
||||
mkdir -p "$VOLUME_PATH"
|
||||
fi
|
||||
|
||||
fix_ownership "$VOLUME_PATH"
|
||||
|
||||
# 4. Stack Generation
|
||||
log_info "Generating compose and configurations..."
|
||||
"${SCRIPT_DIR}/init/scripts/compose_gen.sh"
|
||||
"${SCRIPT_DIR}/init/scripts/config_gen.sh"
|
||||
"${SCRIPT_DIR}/init/scripts/config_link.sh"
|
||||
|
||||
# 5. Worker Generation
|
||||
read -r -p "Number of worker processes? [Default: 1]: " worker_count
|
||||
worker_count="${worker_count:-1}"
|
||||
|
||||
if ! [[ "$worker_count" =~ ^[0-9]+$ ]]; then
|
||||
log_error "Invalid number. Aborting worker generation."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$worker_count" -gt 0 ]]; then
|
||||
log_info "Generating $worker_count worker(s)..."
|
||||
"${SCRIPT_DIR}/init/scripts/worker_gen.sh" -c "$worker_count"
|
||||
else
|
||||
log_info "Skipping worker generation (count: 0)."
|
||||
fi
|
||||
|
||||
log_info "Setup complete. Run 'docker compose up -d' to start services."
|
||||
Reference in New Issue
Block a user