diff --git a/lib/domain-discovery.sh b/lib/domain-discovery.sh index 9b47b7f..43a2ebf 100644 --- a/lib/domain-discovery.sh +++ b/lib/domain-discovery.sh @@ -8,8 +8,9 @@ # Source dependencies if [ -z "$TOOLKIT_BASE_DIR" ]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "$SCRIPT_DIR/common-functions.sh" - source "$SCRIPT_DIR/system-detect.sh" + + [ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; } + [ -f "$SCRIPT_DIR/system-detect.sh" ] && source "$SCRIPT_DIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; } fi # Source control panel helpers if available diff --git a/lib/mysql-analyzer.sh b/lib/mysql-analyzer.sh index 87733c5..60fb4e6 100755 --- a/lib/mysql-analyzer.sh +++ b/lib/mysql-analyzer.sh @@ -8,9 +8,10 @@ # Source dependencies if [ -z "$TOOLKIT_BASE_DIR" ]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "$SCRIPT_DIR/common-functions.sh" - source "$SCRIPT_DIR/system-detect.sh" - source "$SCRIPT_DIR/user-manager.sh" + + [ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; } + [ -f "$SCRIPT_DIR/system-detect.sh" ] && source "$SCRIPT_DIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; } + [ -f "$SCRIPT_DIR/user-manager.sh" ] && source "$SCRIPT_DIR/user-manager.sh" || { echo "ERROR: user-manager.sh not found" >&2; return 1; } fi ############################################################################# diff --git a/lib/plesk-helpers.sh b/lib/plesk-helpers.sh index 3c70c45..e0f84b2 100644 --- a/lib/plesk-helpers.sh +++ b/lib/plesk-helpers.sh @@ -8,7 +8,7 @@ # Source common functions if not already loaded if [ -z "$TOOLKIT_BASE_DIR" ]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "$SCRIPT_DIR/common-functions.sh" + [ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; } fi ############################################################################# diff --git a/lib/reference-db.sh b/lib/reference-db.sh index 38a252f..4c576f6 100755 --- a/lib/reference-db.sh +++ b/lib/reference-db.sh @@ -9,9 +9,10 @@ # Source dependencies if [ -z "$TOOLKIT_BASE_DIR" ]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "$SCRIPT_DIR/common-functions.sh" - source "$SCRIPT_DIR/system-detect.sh" - source "$SCRIPT_DIR/user-manager.sh" + + [ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; } + [ -f "$SCRIPT_DIR/system-detect.sh" ] && source "$SCRIPT_DIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; } + [ -f "$SCRIPT_DIR/user-manager.sh" ] && source "$SCRIPT_DIR/user-manager.sh" || { echo "ERROR: user-manager.sh not found" >&2; return 1; } fi # Reference database location diff --git a/lib/system-detect.sh b/lib/system-detect.sh index 88d6b19..745b606 100755 --- a/lib/system-detect.sh +++ b/lib/system-detect.sh @@ -9,7 +9,7 @@ # Source common functions if not already loaded if [ -z "$TOOLKIT_BASE_DIR" ]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "$SCRIPT_DIR/common-functions.sh" + [ -f "$SCRIPT_DIR/common-functions.sh" ] && source "$SCRIPT_DIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; } fi # Global variables (session-only) - only initialize if not already set diff --git a/lib/user-manager.sh b/lib/user-manager.sh index 96b7de6..22d73e4 100755 --- a/lib/user-manager.sh +++ b/lib/user-manager.sh @@ -8,8 +8,9 @@ # Source dependencies if [ -z "$TOOLKIT_BASE_DIR" ]; then _LIB_SRCDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "$_LIB_SRCDIR/common-functions.sh" - source "$_LIB_SRCDIR/system-detect.sh" + + [ -f "$_LIB_SRCDIR/common-functions.sh" ] && source "$_LIB_SRCDIR/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; return 1; } + [ -f "$_LIB_SRCDIR/system-detect.sh" ] && source "$_LIB_SRCDIR/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; return 1; } fi # Initialize temp session directory if not set diff --git a/modules/website/website-error-analyzer.sh b/modules/website/website-error-analyzer.sh index ba08956..382bfe8 100755 --- a/modules/website/website-error-analyzer.sh +++ b/modules/website/website-error-analyzer.sh @@ -9,10 +9,11 @@ ################################################################################ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)" -source "$SCRIPT_DIR/lib/common-functions.sh" -source "$SCRIPT_DIR/lib/system-detect.sh" -source "$SCRIPT_DIR/lib/user-manager.sh" -source "$SCRIPT_DIR/lib/ip-reputation.sh" + +[ -f "$SCRIPT_DIR/lib/common-functions.sh" ] && source "$SCRIPT_DIR/lib/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; exit 1; } +[ -f "$SCRIPT_DIR/lib/system-detect.sh" ] && source "$SCRIPT_DIR/lib/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; exit 1; } +[ -f "$SCRIPT_DIR/lib/user-manager.sh" ] && source "$SCRIPT_DIR/lib/user-manager.sh" || { echo "ERROR: user-manager.sh not found" >&2; exit 1; } +[ -f "$SCRIPT_DIR/lib/ip-reputation.sh" ] && source "$SCRIPT_DIR/lib/ip-reputation.sh" || { echo "ERROR: ip-reputation.sh not found" >&2; exit 1; } # Configuration - Use system-detected paths APACHE_ERROR_LOG="/var/log/apache2/error_log" # Will be auto-detected diff --git a/modules/website/wordpress/wordpress-cron-manager.sh b/modules/website/wordpress/wordpress-cron-manager.sh index 2b476ab..55186f3 100755 --- a/modules/website/wordpress/wordpress-cron-manager.sh +++ b/modules/website/wordpress/wordpress-cron-manager.sh @@ -12,8 +12,9 @@ ################################################################################ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/../../.." && pwd)" -source "$SCRIPT_DIR/lib/common-functions.sh" -source "$SCRIPT_DIR/lib/system-detect.sh" + +[ -f "$SCRIPT_DIR/lib/common-functions.sh" ] && source "$SCRIPT_DIR/lib/common-functions.sh" || { echo "ERROR: common-functions.sh not found" >&2; exit 1; } +[ -f "$SCRIPT_DIR/lib/system-detect.sh" ] && source "$SCRIPT_DIR/lib/system-detect.sh" || { echo "ERROR: system-detect.sh not found" >&2; exit 1; } if [ "$EUID" -ne 0 ]; then print_error "This script must be run as root"