From ce660151d81d76e8497b31f7a8f93c95991907c7 Mon Sep 17 00:00:00 2001 From: J0Z1L Date: Fri, 27 Feb 2026 23:34:26 +0100 Subject: [PATCH] Make start.sh standalone bootstrap for host-only setup --- README.md | 20 +++++++++++++++++++- start.sh | 53 ++++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 63 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6889854..ae381e5 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,25 @@ Danach erreichbar unter: [http://localhost:3000](http://localhost:3000) ## Unraid: Build + Template automatisch aktualisieren/anlegen -Einmalig: +Du brauchst am Anfang nur `start.sh` auf dem Host. + +Beispiel: + +```bash +mkdir -p /mnt/user/appdata/Lidarr-Frontend +cd /mnt/user/appdata/Lidarr-Frontend +# start.sh hier ablegen +bash start.sh +``` + +Danach macht das Skript automatisch: + +- Repo in diesem Ordner clonen (oder aktualisieren) +- Docker-Image bauen +- Unraid-Template erstellen/aktualisieren +- Template-Seite in Unraid oeffnen + +Alternativ (wenn du schon im Repo bist), einmalig: ```bash chmod +x start.sh scripts/run-unraid.sh diff --git a/start.sh b/start.sh index 2a680d3..57fac31 100755 --- a/start.sh +++ b/start.sh @@ -4,11 +4,34 @@ if [ -z "${BASH_VERSION:-}" ]; then fi set -euo pipefail -INSTALL_DIR="${INSTALL_DIR:-/boot/config/custom/lidarr-spotify-frontend}" +SCRIPT_PATH="$(cd "$(dirname "$0")" && pwd)/$(basename "$0")" +SCRIPT_DIR="$(cd "$(dirname "${SCRIPT_PATH}")" && pwd)" +LOCAL_RUN_SCRIPT="${SCRIPT_DIR}/scripts/run-unraid.sh" + +INSTALL_DIR="${INSTALL_DIR:-${SCRIPT_DIR}}" REPO_URL="${REPO_URL:-https://forgejo.tailef61c0.ts.net/openclaw/lidarr-spotify-frontend.git}" REPO_BRANCH="${REPO_BRANCH:-main}" -if [[ "${START_BOOTSTRAPPED:-0}" != "1" ]]; then +bootstrap_repo_into_install_dir() { + local tmpdir + tmpdir="$(mktemp -d)" + trap 'rm -rf "${tmpdir}"' EXIT + + echo "==> Clone Repo nach temporaer: ${tmpdir}/repo" + git clone --branch "${REPO_BRANCH}" "${REPO_URL}" "${tmpdir}/repo" + + echo "==> Kopiere Repo nach ${INSTALL_DIR}" + cp -a "${tmpdir}/repo/." "${INSTALL_DIR}/" +} + +is_allowed_bootstrap_file() { + case "$1" in + start.sh|.env|.env.unraid) return 0 ;; + *) return 1 ;; + esac +} + +if [[ "${START_BOOTSTRAPPED:-0}" != "1" && ! -f "${LOCAL_RUN_SCRIPT}" ]]; then if ! command -v git >/dev/null 2>&1; then echo "Fehler: git wurde nicht gefunden." exit 1 @@ -24,14 +47,26 @@ if [[ "${START_BOOTSTRAPPED:-0}" != "1" ]]; then git -C "${INSTALL_DIR}" pull --ff-only origin "${REPO_BRANCH}" fi else - if [[ -n "$(ls -A "${INSTALL_DIR}" 2>/dev/null)" ]]; then - echo "Fehler: ${INSTALL_DIR} existiert, ist aber kein Git-Repo und nicht leer." - echo "Bitte leeren/entfernen oder INSTALL_DIR auf einen anderen Pfad setzen." - exit 1 - fi + mapfile -t existing_files < <(ls -A "${INSTALL_DIR}") + if [[ "${#existing_files[@]}" -eq 0 ]]; then + bootstrap_repo_into_install_dir + else + only_allowed=1 + for file in "${existing_files[@]}"; do + if ! is_allowed_bootstrap_file "${file}"; then + only_allowed=0 + break + fi + done - echo "==> Clone Repo nach ${INSTALL_DIR}" - git clone --branch "${REPO_BRANCH}" "${REPO_URL}" "${INSTALL_DIR}" + if [[ "${only_allowed}" -eq 1 ]]; then + bootstrap_repo_into_install_dir + else + echo "Fehler: ${INSTALL_DIR} ist kein Git-Repo und enthaelt bereits andere Dateien." + echo "Bitte INSTALL_DIR setzen oder Verzeichnis leeren." + exit 1 + fi + fi fi exec env \