first commit
This commit is contained in:
38
roles.sh
Executable file
38
roles.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/usr/bin/env bash
|
||||
# Orchestrateur de roles
|
||||
source "$PROJECT_DIR/lib.sh"
|
||||
enable_strict_mode
|
||||
|
||||
CONFIG_FILE="${CONFIG_FILE:-/etc/netbian.conf}"
|
||||
[[ -f "$CONFIG_FILE" ]] || fatal "Config file $CONFIG_FILE not found. Create it via run.sh."
|
||||
validate_config_file "$CONFIG_FILE"
|
||||
source "$CONFIG_FILE"
|
||||
[[ -n "${profile:-}" ]] || fatal "The 'profile' variable is not set in $CONFIG_FILE."
|
||||
export profile
|
||||
[[ -n "${lang:-}" ]] && export lang
|
||||
|
||||
PROFILE_FILE="$PROFILE_DIR/${profile}.sh"
|
||||
[[ -f "$PROFILE_FILE" ]] || fatal "Profile definition not found: $PROFILE_FILE"
|
||||
|
||||
trap 'status=$?; print_execution_summary; exit $status' EXIT
|
||||
|
||||
declare -a ROLE_ORDER=()
|
||||
source "$PROFILE_FILE"
|
||||
|
||||
((${#ROLE_ORDER[@]} > 0)) || fatal "No roles declared in $PROFILE_FILE"
|
||||
|
||||
validate_profile_definition "$PROFILE_FILE"
|
||||
validate_all_roles "${ROLE_ORDER[@]}"
|
||||
|
||||
for role in "${ROLE_ORDER[@]}"; do
|
||||
run_role "$role"
|
||||
done
|
||||
|
||||
cat <<'EOM'
|
||||
____ _
|
||||
/ ___| _ _ ___ ___ ___ ___ ___ | |
|
||||
\___ \| | | |/ __/ __/ _ \/ __/ __| | |
|
||||
___) | |_| | (_| (_| __/\__ \__ \ |_|
|
||||
|____/ \__,_|\___\___\___||___/___/ (_)
|
||||
|
||||
EOM
|
||||
Reference in New Issue
Block a user