Bootstrap start.sh for Unraid clone/pull and bash re-exec
This commit is contained in:
parent
fe3601cb5b
commit
f2c0ffe5d0
2 changed files with 59 additions and 9 deletions
53
start.sh
53
start.sh
|
|
@ -1,20 +1,57 @@
|
|||
#!/usr/bin/env bash
|
||||
if [ -z "${BASH_VERSION:-}" ]; then
|
||||
exec bash "$0" "$@"
|
||||
fi
|
||||
set -euo pipefail
|
||||
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
INSTALL_DIR="${INSTALL_DIR:-/boot/config/custom/lidarr-spotify-frontend}"
|
||||
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
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
echo "Fehler: git wurde nicht gefunden."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir -p "${INSTALL_DIR}"
|
||||
|
||||
if [[ -d "${INSTALL_DIR}/.git" ]]; then
|
||||
echo "==> Repo vorhanden, aktualisiere: ${INSTALL_DIR}"
|
||||
if [[ "${SKIP_GIT_PULL:-0}" != "1" ]]; then
|
||||
git -C "${INSTALL_DIR}" fetch --prune origin
|
||||
git -C "${INSTALL_DIR}" checkout "${REPO_BRANCH}"
|
||||
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
|
||||
|
||||
echo "==> Clone Repo nach ${INSTALL_DIR}"
|
||||
git clone --branch "${REPO_BRANCH}" "${REPO_URL}" "${INSTALL_DIR}"
|
||||
fi
|
||||
|
||||
exec env \
|
||||
START_BOOTSTRAPPED=1 \
|
||||
INSTALL_DIR="${INSTALL_DIR}" \
|
||||
REPO_URL="${REPO_URL}" \
|
||||
REPO_BRANCH="${REPO_BRANCH}" \
|
||||
SKIP_GIT_PULL="${SKIP_GIT_PULL:-0}" \
|
||||
UNRAID_URL="${UNRAID_URL:-}" \
|
||||
TEMPLATE_NAME="${TEMPLATE_NAME:-my-lidarr-spotify-frontend.xml}" \
|
||||
bash "${INSTALL_DIR}/start.sh" "$@"
|
||||
fi
|
||||
|
||||
PROJECT_ROOT="${INSTALL_DIR}"
|
||||
RUN_SCRIPT="${PROJECT_ROOT}/scripts/run-unraid.sh"
|
||||
|
||||
if [[ ! -x "${RUN_SCRIPT}" ]]; then
|
||||
chmod +x "${RUN_SCRIPT}"
|
||||
fi
|
||||
|
||||
if [[ "${SKIP_GIT_PULL:-0}" != "1" ]] && command -v git >/dev/null 2>&1; then
|
||||
if git -C "${PROJECT_ROOT}" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
echo "==> Aktualisiere Git-Stand (git pull --ff-only)"
|
||||
git -C "${PROJECT_ROOT}" pull --ff-only || echo "Hinweis: git pull fehlgeschlagen, fahre mit lokalem Stand fort."
|
||||
fi
|
||||
fi
|
||||
|
||||
for env_file in "${PROJECT_ROOT}/.env.unraid" "${PROJECT_ROOT}/.env"; do
|
||||
if [[ -f "${env_file}" ]]; then
|
||||
echo "==> Lade Umgebungswerte aus ${env_file}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue