32 lines
1.2 KiB
Bash
32 lines
1.2 KiB
Bash
|
|
#!/usr/bin/env bash
|
||
|
|
# Initialize all common libraries
|
||
|
|
# Usage: source "$(dirname "$0")/init.sh"
|
||
|
|
#
|
||
|
|
# This script loads all common libraries in the correct order.
|
||
|
|
# Individual scripts can source this instead of sourcing each library separately.
|
||
|
|
|
||
|
|
# Get lib directory (this file's directory)
|
||
|
|
LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
|
||
|
|
# Get script directory if not set (try to get from calling script)
|
||
|
|
if [ -z "${SCRIPT_DIR:-}" ]; then
|
||
|
|
# Try to get from calling script (BASH_SOURCE[2] because init.sh adds one level)
|
||
|
|
if [ -n "${BASH_SOURCE[2]:-}" ]; then
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[2]}")" && pwd)"
|
||
|
|
elif [ -n "${BASH_SOURCE[1]:-}" ]; then
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd)"
|
||
|
|
fi
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Source libraries in order (dependencies first)
|
||
|
|
source "${LIB_DIR}/common/colors.sh"
|
||
|
|
source "${LIB_DIR}/common/logging.sh"
|
||
|
|
source "${LIB_DIR}/common/utils.sh"
|
||
|
|
source "${LIB_DIR}/common/validation.sh" 2>/dev/null || true
|
||
|
|
source "${LIB_DIR}/common/error-handling.sh" 2>/dev/null || true
|
||
|
|
source "${LIB_DIR}/config/env.sh" 2>/dev/null || true
|
||
|
|
|
||
|
|
# Log that libraries are loaded (only in debug mode)
|
||
|
|
[ "${LOG_LEVEL:-2}" -ge 3 ] && log_debug "Common libraries loaded from ${LIB_DIR}"
|
||
|
|
|