Do not fail when the mods directory is absent or empty
On a first deploy the server has not run yet, so /minecraft/mods does not exist and packwiz-setup.sh died before creating anything. It now creates the directory, and mc-service-setup.sh also creates it up front with setgid so jars dropped in by either the service user or the admin stay group-readable. An empty mods directory is likewise no longer fatal. A pack with no mods yet is a valid starting point: the pack, the index and the player guides are all generated, and jars registered later with mc-refresh-restart.sh. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>main
parent
b32b47f020
commit
908c4ecbb6
|
|
@ -87,6 +87,10 @@ fi
|
||||||
info "setting ownership of $SHARE to $MCUSER"
|
info "setting ownership of $SHARE to $MCUSER"
|
||||||
chown -R "$MCUSER":"$MCUSER" "$SHARE"
|
chown -R "$MCUSER":"$MCUSER" "$SHARE"
|
||||||
|
|
||||||
|
# The server creates mods/ on first run, but the pack setup needs it to exist
|
||||||
|
# before that. Setgid so jars dropped in by either side stay group-readable.
|
||||||
|
install -d -o "$MCUSER" -g "$MCUSER" -m 2775 "$SHARE/mods"
|
||||||
|
|
||||||
# Without this the chown above locks the human out of the share they author the
|
# Without this the chown above locks the human out of the share they author the
|
||||||
# pack on. Share root and packs/ become group-writable and setgid, so files
|
# pack on. Share root and packs/ become group-writable and setgid, so files
|
||||||
# created by either side stay readable to both.
|
# created by either side stay readable to both.
|
||||||
|
|
|
||||||
|
|
@ -98,7 +98,12 @@ mkdir -p "$PACKROOT" 2>/dev/null || true
|
||||||
[ -n "$BASEURL" ] && [ -z "$MODSDIR" ] && MODSDIR="$SHARE/mods"
|
[ -n "$BASEURL" ] && [ -z "$MODSDIR" ] && MODSDIR="$SHARE/mods"
|
||||||
if [ -n "$MODSDIR$BASEURL" ]; then
|
if [ -n "$MODSDIR$BASEURL" ]; then
|
||||||
[ -n "$BASEURL" ] || die "-M given without -u <http base url>"
|
[ -n "$BASEURL" ] || die "-M given without -u <http base url>"
|
||||||
[ -d "$MODSDIR" ] || die "mods dir does not exist: $MODSDIR"
|
# On a first deploy the server has not run yet, so mods/ may not exist.
|
||||||
|
# That is not an error — create it and carry on with an empty pack.
|
||||||
|
if [ ! -d "$MODSDIR" ]; then
|
||||||
|
info "creating $MODSDIR"
|
||||||
|
mkdir -p "$MODSDIR" || die "could not create $MODSDIR"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
BASEURL="${BASEURL%/}"
|
BASEURL="${BASEURL%/}"
|
||||||
|
|
||||||
|
|
@ -242,10 +247,14 @@ if [ -n "$MODSDIR" ]; then
|
||||||
shopt -s nullglob
|
shopt -s nullglob
|
||||||
jars=("$MODSDIR"/*.jar)
|
jars=("$MODSDIR"/*.jar)
|
||||||
shopt -u nullglob
|
shopt -u nullglob
|
||||||
[ "${#jars[@]}" -gt 0 ] || die "no .jar files found in $MODSDIR"
|
|
||||||
|
|
||||||
info "adding ${#jars[@]} mods from the mirror"
|
|
||||||
failed=()
|
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.
|
||||||
|
warn "no .jar files in $MODSDIR yet — creating an empty pack"
|
||||||
|
else
|
||||||
|
info "adding ${#jars[@]} mods from the mirror"
|
||||||
for jar in "${jars[@]}"; do
|
for jar in "${jars[@]}"; do
|
||||||
file="$(basename "$jar")"
|
file="$(basename "$jar")"
|
||||||
|
|
||||||
|
|
@ -266,6 +275,8 @@ if [ -n "$MODSDIR" ]; then
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
"$PACKWIZ" refresh
|
"$PACKWIZ" refresh
|
||||||
|
|
||||||
if [ "${#failed[@]}" -gt 0 ]; then
|
if [ "${#failed[@]}" -gt 0 ]; then
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue