-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstart-modules.sh
More file actions
67 lines (55 loc) · 2.11 KB
/
start-modules.sh
File metadata and controls
67 lines (55 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
# Ensure Unix line endings
sed -i 's/\r$//' "$0"
find modules -type f -name "*.sh" -exec sed -i 's/\r$//' {} + 2>/dev/null || true
set -euo pipefail
trap 'echo -e "${RED}[Orchestrator] Error on line $LINENO${NC}"' ERR
# Enable nullglob so non-matching globs expand to empty
shopt -s nullglob
# Color definitions
BLUE='\033[0;34m'; BOLD_BLUE='\033[1;34m'
WHITE='\033[0;37m'; GREEN='\033[0;32m'
YELLOW='\033[0;33m'; RED='\033[0;31m'
CYAN='\033[0;36m'; NC='\033[0m'
# header function for consistent separators
header() {
echo -e " "
echo -e "\n${BLUE}───────────────────────────────────────────────${NC}"
echo -e "${BOLD_BLUE}[Orchestrator] $1${NC}"
}
# Start orchestration
echo -e "\n${BOLD_BLUE}[Orchestrator] Rust Web Egg - Module orchestration starting...${NC}"
# Helper to test enabled status: true or 1
is_enabled() { [[ "$1" =~ ^(true|1)$ ]]; }
# 1) Run logcleaner first if enabled
LOGCLEANER_STATUS="${LOGCLEANER_STATUS:-false}"
if is_enabled "$LOGCLEANER_STATUS"; then
header "Running module: logcleaner"
modules/logcleaner/start.sh
fi
# 2) Run auto-update if enabled (only if module exists)
AUTOUPDATE_STATUS="${AUTOUPDATE_STATUS:-true}"
if is_enabled "$AUTOUPDATE_STATUS" && [[ -f "modules/autoupdate/start.sh" ]]; then
header "Running module: autoupdate"
modules/autoupdate/start.sh
fi
# 3) Execute other modules (except autoupdate and logcleaner)
for module_dir in modules/*/; do
module_name=$(basename "$module_dir")
[[ "$module_name" == "autoupdate" || "$module_name" == "logcleaner" ]] && continue
start_script="${module_dir}start.sh"
status_var="${module_name^^}_STATUS"
status="${!status_var:-false}"
# Skip silently if disabled
if ! is_enabled "$status"; then
continue
fi
# Run module if script is executable
if [[ -x "$start_script" ]]; then
header "Running module: ${module_name}"
"$start_script"
fi
done
# Completion message
echo -e "\n${GREEN}[Orchestrator] Module orchestration complete.${NC}\n"
echo -e "${CYAN}[Orchestrator] Starting Rust application...${NC}\n"