diff --git a/mc-service-setup.sh b/mc-service-setup.sh index 3c6e237..cc004b2 100755 --- a/mc-service-setup.sh +++ b/mc-service-setup.sh @@ -87,6 +87,10 @@ fi info "setting ownership of $SHARE to $MCUSER" 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 # pack on. Share root and packs/ become group-writable and setgid, so files # created by either side stay readable to both. diff --git a/packwiz-setup.sh b/packwiz-setup.sh index 8998e58..4f94689 100755 --- a/packwiz-setup.sh +++ b/packwiz-setup.sh @@ -98,7 +98,12 @@ mkdir -p "$PACKROOT" 2>/dev/null || true [ -n "$BASEURL" ] && [ -z "$MODSDIR" ] && MODSDIR="$SHARE/mods" if [ -n "$MODSDIR$BASEURL" ]; then [ -n "$BASEURL" ] || die "-M given without -u " - [ -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 BASEURL="${BASEURL%/}" @@ -242,10 +247,14 @@ if [ -n "$MODSDIR" ]; then shopt -s nullglob jars=("$MODSDIR"/*.jar) shopt -u nullglob - [ "${#jars[@]}" -gt 0 ] || die "no .jar files found in $MODSDIR" - info "adding ${#jars[@]} mods from the mirror" 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 file="$(basename "$jar")" @@ -266,6 +275,8 @@ if [ -n "$MODSDIR" ]; then fi done + fi + "$PACKWIZ" refresh if [ "${#failed[@]}" -gt 0 ]; then