From 5b3b0465c7c5c591447cf742715f4b2a3d98dedc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=83rcziem=20=E2=84=A2?= <118485377+spalencsar@users.noreply.github.com> Date: Fri, 3 Oct 2025 09:54:41 +0200 Subject: [PATCH] Fix direct function calls in lib scripts to prevent execution on source --- lib/jellyfin.sh | 25 +++++++++++++++++-------- lib/portainer.sh | 8 ++++++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/lib/jellyfin.sh b/lib/jellyfin.sh index 8703b49..a7094d4 100644 --- a/lib/jellyfin.sh +++ b/lib/jellyfin.sh @@ -55,12 +55,21 @@ install_jellyfin() { log_info "Jellyfin installation completed." } -# Detect the distribution and call the appropriate function -if [ -f /etc/os-release ]; then - . /etc/os-release - DISTRO=$ID - install_jellyfin -else - log_error "Cannot detect the operating system." - exit 1 +# Logging-Funktionen bereitstellen, falls nicht vorhanden +if ! command -v log_info &>/dev/null; then + log_info() { echo "[INFO] $1"; } + log_error() { echo "[ERROR] $1" >&2; } +fi + +# Nur ausführen, wenn diese Datei direkt ausgeführt wird (nicht beim `source` in setup.sh). +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + # Detect the distribution and call the appropriate function + if [ -f /etc/os-release ]; then + . /etc/os-release + DISTRO=$ID + install_jellyfin + else + log_error "Cannot detect the operating system." + exit 1 + fi fi \ No newline at end of file diff --git a/lib/portainer.sh b/lib/portainer.sh index c1f53bf..2d6d8aa 100644 --- a/lib/portainer.sh +++ b/lib/portainer.sh @@ -43,5 +43,9 @@ if ! command -v log_info &>/dev/null; then log_error() { echo "[ERROR] $1" >&2; } fi -# Hauptlogik -install_portainer \ No newline at end of file +# Nur ausführen, wenn diese Datei direkt ausgeführt wird (nicht beim `source` in setup.sh). +if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then + # Hauptlogik + install_portainer + exit $? +fi \ No newline at end of file