From 24d890c9c90387c9ad10b2fb168cd96d2ee4f4e6 Mon Sep 17 00:00:00 2001 From: The_miro Date: Thu, 6 Aug 2026 01:21:02 +0200 Subject: [PATCH] Derive mc-refresh-restart.sh settings from deploy.conf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The refresh script kept its own copy of the pack directory and the three URLs, so every deployment had to hand-edit it after running the installer — the last manual step and an easy one to forget or get wrong. It now sources deploy.conf when one sits next to it and derives PACK_DIR, BASE_URL, CLIENT_URL and PACK_URL from PACK_NAME, SHARE and MIRROR_URL. The CONFIG block remains as the fallback when there is no config file, so the script still works standalone. CLIENT_URL was also referenced by the sync but never defined in the CONFIG block, which would have been an unbound variable under set -u on the first run with client mods. Verified both the with-config and without-config paths. Also gitignore deploy.conf and DEPLOY-NOTES.md as machine-local files. Co-Authored-By: Claude Opus 5 --- .gitignore | 4 ++++ mc-refresh-restart.sh | 22 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 22652d2..cdb440f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,6 @@ # build output /dist/ + +# local, machine-specific +/deploy.conf +/DEPLOY-NOTES.md diff --git a/mc-refresh-restart.sh b/mc-refresh-restart.sh index bd74c4b..7b810fb 100755 --- a/mc-refresh-restart.sh +++ b/mc-refresh-restart.sh @@ -14,13 +14,27 @@ set -euo pipefail +# If deploy.conf sits next to this script, every path and URL below is derived +# from it — no second place to keep in sync. The CONFIG block is the fallback. +_HERE="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)" +if [ -f "${_HERE}/deploy.conf" ]; then + # shellcheck source=/dev/null + . "${_HERE}/deploy.conf" + _SLUG="$(printf '%s' "${PACK_NAME}" | tr '[:upper:] ' '[:lower:]-' | tr -cd 'a-z0-9-')" + _SITE="${MIRROR_URL%/*}" +fi + ### CONFIG ############################################### -SHARE="/minecraft" # ZFS dataset mountpoint -PACK_DIR="${SHARE}/packs/mypack" # packwiz project root (has pack.toml) +SHARE="${SHARE:-/minecraft}" # ZFS dataset mountpoint +PACK_DIR="${_SLUG:+${SHARE}/packs/${_SLUG}}" # packwiz project root (has pack.toml) +PACK_DIR="${PACK_DIR:-${SHARE}/packs/mypack}" MODS_DIR="${SHARE}/mods" # server+client mods, loaded by the server CLIENT_MODS_DIR="${SHARE}/client-mods" # client-only mods, never loaded server-side -BASE_URL="https://games.abdelbaki.eu/mods" # mirror base URL, no trailing slash -PACK_URL="https://games.abdelbaki.eu/packs/mypack" # where PACK_DIR is served; "" to skip the check +BASE_URL="${MIRROR_URL:-https://games.abdelbaki.eu/abdelpakDelta/mods}" # mirror for MODS_DIR +CLIENT_URL="${_SITE:+${_SITE}/client-mods}" # mirror for CLIENT_MODS_DIR +CLIENT_URL="${CLIENT_URL:-https://games.abdelbaki.eu/abdelpakDelta/client-mods}" +PACK_URL="${_SITE:+${_SITE}/packs/${_SLUG}}" # where PACK_DIR is served +PACK_URL="${PACK_URL:-https://games.abdelbaki.eu/abdelpakDelta/packs/abdelpakdelta}" SERVICE_NAME="minecraft.service" START_TIMEOUT=60 # seconds to wait for the service to report active KEEP_SNAPSHOTS=8 # how many snapshots to retain