Fix direct function calls in lib scripts to prevent execution on source

This commit is contained in:
Mărcziem ™
2025-10-03 09:54:41 +02:00
parent 5416687af2
commit 5b3b0465c7
2 changed files with 23 additions and 10 deletions

View File

@@ -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
# 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
else
log_error "Cannot detect the operating system."
exit 1
fi
fi

View File

@@ -43,5 +43,9 @@ if ! command -v log_info &>/dev/null; then
log_error() { echo "[ERROR] $1" >&2; }
fi
# Hauptlogik
install_portainer
# 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