Make start.sh standalone bootstrap for host-only setup
This commit is contained in:
parent
f2c0ffe5d0
commit
ce660151d8
2 changed files with 63 additions and 10 deletions
53
start.sh
53
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 \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue