Files
sailarr-installer/scripts/get-config-dirs.sh
JaviPege 9c2a253945 feat: Integrate template system into setup.sh - MAJOR REFACTOR
Fully integrated the modular template system into setup.sh, reducing code
from 1426 to 1076 lines (-350 lines, -25% code).

**PHASE 1 - Configuration (Lines 170-198):**
- Added interactive template selector
- Default: core + plex + overseerr
- Custom: User selects media server and optional services
- Validates dependencies automatically
- Saves SELECTED_TEMPLATES to .env.install

**PHASE 2 - Summary (Lines 369-379):**
- Displays selected templates with descriptions
- Shows what will be installed before proceeding

**PHASE 3 - Installation (Lines 460-512):**
- Generates docker-compose.yml dynamically from templates
- Creates config directories based on selected services only
- Sets permissions dynamically for selected services only
- No more hardcoded service lists

**PHASE 4 - Auto-Configuration (Lines 889-917):**
- REPLACED ~350 lines of manual configuration code
- Single call to setup-executor.sh with selected templates
- setup-executor reads service JSONs and executes steps
- Automatic: API key extraction, root folders, download clients,
  indexers, Prowlarr sync, Recyclarr, etc.

**Service Validation (Lines 807-820):**
- Dynamic service list from selected templates
- Filters out setup-only services (recyclarr, networks, volumes)
- No more hardcoded EXPECTED_SERVICES array

**Helper Scripts Created:**
- scripts/get-services-list.sh: Extracts service names from templates
- scripts/get-config-dirs.sh: Returns services needing config dirs

**Benefits:**
 Modular: Users choose exactly what to install
 Maintainable: Add services = create JSON, no setup.sh changes
 Scalable: Easy to add new templates/services
 Less code: -350 lines (-25%)
 Dependencies: Automatically validated (e.g., Overseerr requires Plex)

**Testing:**
- Validates templates exist
- Checks JSON syntax
- Helper scripts tested with multiple template combinations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-22 18:15:46 +02:00

79 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Get Config Directories - Extracts list of services that need config directories
# Usage: ./get-config-dirs.sh core mediaplayers/plex extras/overseerr
# Output: radarr sonarr prowlarr plex overseerr decypharr autoscan zilean
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TEMPLATES_DIR="${SCRIPT_DIR}/../templates"
# Services that need config directories
# Infrastructure services (networks, volumes) don't need config dirs
# Some services like recyclarr are setup-only and don't need persistent config
CONFIG_REQUIRING_SERVICES=(
"radarr"
"sonarr"
"prowlarr"
"plex"
"overseerr"
"decypharr"
"autoscan"
"zilean"
"tautulli"
"homarr"
"pinchflat"
"jellyfin"
"jellyseerr"
"plextraktsync"
)
# Check if a service requires a config directory
requires_config_dir() {
local service=$1
for config_service in "${CONFIG_REQUIRING_SERVICES[@]}"; do
if [ "$service" = "$config_service" ]; then
return 0
fi
done
return 1
}
# Get all services from templates
get_all_services() {
"${SCRIPT_DIR}/get-services-list.sh" "$@"
}
# Main execution
main() {
local templates=("$@")
if [ ${#templates[@]} -eq 0 ]; then
echo "ERROR: No templates specified" >&2
echo "Usage: $0 <template1> [template2] ..." >&2
exit 1
fi
# Get all services
local all_services=($(get_all_services "${templates[@]}"))
# Filter to only those that need config directories
local config_dirs=()
for service in "${all_services[@]}"; do
if requires_config_dir "$service"; then
config_dirs+=("$service")
fi
done
# Output space-separated list
echo "${config_dirs[@]}"
}
# Only run main if executed directly (not sourced)
if [ "${BASH_SOURCE[0]}" -ef "$0" ]; then
main "$@"
fi