Make start.sh standalone bootstrap for host-only setup

This commit is contained in:
J0Z1L 2026-02-27 23:34:26 +01:00
parent f2c0ffe5d0
commit ce660151d8
2 changed files with 63 additions and 10 deletions

View file

@ -36,7 +36,25 @@ Danach erreichbar unter: [http://localhost:3000](http://localhost:3000)
## Unraid: Build + Template automatisch aktualisieren/anlegen ## 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 ```bash
chmod +x start.sh scripts/run-unraid.sh chmod +x start.sh scripts/run-unraid.sh

View file

@ -4,11 +4,34 @@ if [ -z "${BASH_VERSION:-}" ]; then
fi fi
set -euo pipefail 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_URL="${REPO_URL:-https://forgejo.tailef61c0.ts.net/openclaw/lidarr-spotify-frontend.git}"
REPO_BRANCH="${REPO_BRANCH:-main}" 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 if ! command -v git >/dev/null 2>&1; then
echo "Fehler: git wurde nicht gefunden." echo "Fehler: git wurde nicht gefunden."
exit 1 exit 1
@ -24,14 +47,26 @@ if [[ "${START_BOOTSTRAPPED:-0}" != "1" ]]; then
git -C "${INSTALL_DIR}" pull --ff-only origin "${REPO_BRANCH}" git -C "${INSTALL_DIR}" pull --ff-only origin "${REPO_BRANCH}"
fi fi
else else
if [[ -n "$(ls -A "${INSTALL_DIR}" 2>/dev/null)" ]]; then mapfile -t existing_files < <(ls -A "${INSTALL_DIR}")
echo "Fehler: ${INSTALL_DIR} existiert, ist aber kein Git-Repo und nicht leer." if [[ "${#existing_files[@]}" -eq 0 ]]; then
echo "Bitte leeren/entfernen oder INSTALL_DIR auf einen anderen Pfad setzen." 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
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 exit 1
fi fi
fi
echo "==> Clone Repo nach ${INSTALL_DIR}"
git clone --branch "${REPO_BRANCH}" "${REPO_URL}" "${INSTALL_DIR}"
fi fi
exec env \ exec env \