From ae1671b361af4ed7d2c40ddba251bcc1a5268c1f Mon Sep 17 00:00:00 2001 From: The_miro Date: Wed, 5 Aug 2026 23:38:57 +0200 Subject: [PATCH] Deploy a complete instance with no mods present MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two things stopped a from-scratch deploy finishing in one run. The mirror reachability probe ran before counting jars, so a fresh instance with an empty mods directory still failed on an unreachable mirror despite having nothing to fetch. The probe now runs only when there is at least one jar, which also means the reverse proxy does not have to be in place yet to build the initial pack. mc-refresh-restart.sh gets the same treatment: zero jars is a legitimate state, and the orphan sweep clears the metadata to match. The probe itself never worked. curl -w '%{http_code}' already prints 000 on a connection failure, so the trailing "|| echo 000" appended a second one and the value was 000000, matching neither the unreachable case nor anything else — the guard silently degraded to a warning. Use "|| true" with a :-000 fallback. Verified against a refused port and a live host. Co-Authored-By: Claude Opus 5 --- mc-refresh-restart.sh | 17 ++++++++++++----- packwiz-setup.sh | 24 +++++++++++++----------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/mc-refresh-restart.sh b/mc-refresh-restart.sh index 6d05df0..807407b 100755 --- a/mc-refresh-restart.sh +++ b/mc-refresh-restart.sh @@ -57,13 +57,19 @@ DATASET="$(findmnt -no SOURCE "${SHARE}" 2>/dev/null || true)" log "Syncing pack metadata against ${MODS_DIR}..." cd "${PACK_DIR}" -probe="$(curl -so /dev/null -w '%{http_code}' --max-time 10 "${BASE_URL}/" || echo 000)" -[ "${probe}" = "000" ] && die "cannot reach ${BASE_URL} — packwiz needs it to hash each mod" - shopt -s nullglob JARS=("${MODS_DIR}"/*.jar) shopt -u nullglob -(( ${#JARS[@]} > 0 )) || die "no .jar files in ${MODS_DIR}" + +# Zero jars is legitimate — an empty pack, or every mod deliberately removed. +# The orphan sweep below then clears the metadata to match. +if (( ${#JARS[@]} > 0 )); then + probe="$(curl -so /dev/null -w '%{http_code}' --max-time 10 "${BASE_URL}/" || true)" + probe="${probe:-000}" + [ "${probe}" = "000" ] && die "cannot reach ${BASE_URL} — packwiz needs it to hash each mod" +else + log "WARNING: no .jar files in ${MODS_DIR} — pack will end up empty" +fi added=0; updated=0; unchanged=0; FAILED=() declare -A SEEN=() @@ -150,7 +156,8 @@ if [ -n "${PACK_URL}" ]; then fi # index.toml is fetched as a separate request and cached separately. - idx="$(curl -fsS --max-time 10 -o /dev/null -w '%{http_code}' "${PACK_URL}/index.toml" || echo 000)" + idx="$(curl -fsS --max-time 10 -o /dev/null -w '%{http_code}' "${PACK_URL}/index.toml" || true)" + idx="${idx:-000}" [ "${idx}" = "200" ] || die "${PACK_URL}/index.toml returned HTTP ${idx} — clients cannot resolve the pack" fi diff --git a/packwiz-setup.sh b/packwiz-setup.sh index 4f94689..c1cc5fa 100755 --- a/packwiz-setup.sh +++ b/packwiz-setup.sh @@ -234,16 +234,6 @@ if [ -n "$MODSDIR" ]; then grep -q 'url' <<<"$("$PACKWIZ" --help 2>&1 || true)" \ || die "this packwiz build has no 'url' subcommand — cannot add mods by URL" - # packwiz downloads each URL to hash it, so a mirror that isn't up yet - # produces a pile of confusing per-mod failures. Check once, up front. - info "checking mirror at $BASEURL" - probe="$(curl -so /dev/null -w '%{http_code}' --max-time 10 "$BASEURL/" || echo 000)" - case "$probe" in - 2*|3*|40[34]) ;; # a listing may legitimately be forbidden - 000) die "cannot reach $BASEURL — start the mirror before running this" ;; - *) warn "$BASEURL/ returned HTTP $probe; continuing, individual mods may fail" ;; - esac - shopt -s nullglob jars=("$MODSDIR"/*.jar) shopt -u nullglob @@ -251,9 +241,21 @@ if [ -n "$MODSDIR" ]; then failed=() if [ "${#jars[@]}" -eq 0 ]; then # An empty pack is a valid starting point: drop jars in later and run - # mc-refresh-restart.sh to register them. + # mc-refresh-restart.sh to register them. Nothing needs fetching, so the + # mirror does not have to be reachable yet either. warn "no .jar files in $MODSDIR yet — creating an empty pack" else + # packwiz downloads each URL to hash it, so a mirror that isn't up yet + # produces a pile of confusing per-mod failures. Check once, up front. + info "checking mirror at $BASEURL" + probe="$(curl -so /dev/null -w '%{http_code}' --max-time 10 "$BASEURL/" || true)" + probe="${probe:-000}" + case "$probe" in + 2*|3*|40[34]) ;; # a listing may legitimately be forbidden + 000) die "cannot reach $BASEURL — the pack server or proxy is not up yet" ;; + *) warn "$BASEURL/ returned HTTP $probe; continuing, individual mods may fail" ;; + esac + info "adding ${#jars[@]} mods from the mirror" for jar in "${jars[@]}"; do file="$(basename "$jar")"