Derive mc-refresh-restart.sh settings from deploy.conf

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 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-08-06 01:21:02 +02:00
parent 361d3ed82a
commit 24d890c9c9
2 changed files with 22 additions and 4 deletions

4
.gitignore vendored
View File

@ -1,2 +1,6 @@
# build output # build output
/dist/ /dist/
# local, machine-specific
/deploy.conf
/DEPLOY-NOTES.md

View File

@ -14,13 +14,27 @@
set -euo pipefail 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 ############################################### ### CONFIG ###############################################
SHARE="/minecraft" # ZFS dataset mountpoint SHARE="${SHARE:-/minecraft}" # ZFS dataset mountpoint
PACK_DIR="${SHARE}/packs/mypack" # packwiz project root (has pack.toml) 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 MODS_DIR="${SHARE}/mods" # server+client mods, loaded by the server
CLIENT_MODS_DIR="${SHARE}/client-mods" # client-only mods, never loaded server-side 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 BASE_URL="${MIRROR_URL:-https://games.abdelbaki.eu/abdelpakDelta/mods}" # mirror for MODS_DIR
PACK_URL="https://games.abdelbaki.eu/packs/mypack" # where PACK_DIR is served; "" to skip the check 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" SERVICE_NAME="minecraft.service"
START_TIMEOUT=60 # seconds to wait for the service to report active START_TIMEOUT=60 # seconds to wait for the service to report active
KEEP_SNAPSHOTS=8 # how many snapshots to retain KEEP_SNAPSHOTS=8 # how many snapshots to retain