2021-05-12 22:41:01 -05:00
|
|
|
#! /bin/bash
|
2021-04-09 16:28:17 -05:00
|
|
|
#
|
|
|
|
# start-server.sh
|
|
|
|
# Copyright (C) 2021 Vintage Salt <rehashedsalt@cock.li>
|
|
|
|
#
|
|
|
|
# Distributed under terms of the MIT license.
|
|
|
|
#
|
2021-04-09 16:54:45 -05:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# Download and extract a pack zip, if one is provided
|
|
|
|
if [ -n "$FORGE_PACK_ZIP" ]; then
|
|
|
|
echo "Downloading pack: $FORGE_PACK_ZIP"
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
pushd "$tmpdir" > /dev/null 2>&1
|
|
|
|
curl -L "$FORGE_PACK_ZIP" -o pack.zip
|
2022-05-26 22:05:42 -05:00
|
|
|
unzip -q pack.zip
|
|
|
|
ls -alh
|
2021-04-09 16:54:45 -05:00
|
|
|
directory="$(find . -type d -iname "mods" -execdir pwd \; | sort -n | head -n 1)"
|
2022-05-26 21:59:36 -05:00
|
|
|
if [ -z "$directory" ]; then
|
|
|
|
echo "Unable to find mods directory"
|
|
|
|
else
|
|
|
|
echo "Found modpack directory: $directory"
|
|
|
|
fi
|
2022-05-26 22:12:18 -05:00
|
|
|
echo "Syncing content to /minecraft"
|
2022-06-14 13:56:39 -05:00
|
|
|
rsync --ignore-existing "$directory"/ /minecraft/
|
2021-04-09 16:54:45 -05:00
|
|
|
popd > /dev/null 2>&1
|
|
|
|
fi
|
2021-04-09 16:28:17 -05:00
|
|
|
|
2021-05-29 14:22:53 -05:00
|
|
|
# Then also download and extract a config repo, if one exists
|
|
|
|
if [ -n "$CONFIG_REPO" ]; then
|
|
|
|
echo "Downloading config repo: $CONFIG_REPO"
|
|
|
|
tmpdir="$(mktemp -d)"
|
|
|
|
pushd "$tmpdir" > /dev/null 2>&1
|
|
|
|
git clone "$CONFIG_REPO" .
|
|
|
|
rm -rf .git
|
2021-11-06 14:27:29 -05:00
|
|
|
rsync -av --delete ./ /minecraft/
|
2021-05-29 14:22:53 -05:00
|
|
|
popd > /dev/null 2>&1
|
|
|
|
fi
|
|
|
|
|
2021-04-09 16:28:17 -05:00
|
|
|
# Entrypoint will be server.jar
|
|
|
|
args="-jar server.jar nogui"
|
|
|
|
|
|
|
|
# Memory configuration
|
|
|
|
[ -n "$JRE_XMX" ] && args="-Xmx$JRE_XMX $args"
|
|
|
|
[ -n "$JRE_XMS" ] && args="-Xms$JRE_XMS $args"
|
|
|
|
[ -n "$ARGS" ] && args="$ARGS $args"
|
|
|
|
|
|
|
|
# Debugging info
|
|
|
|
java -version
|
|
|
|
echo "Invoking java with args: $args"
|
2022-01-02 10:57:28 -06:00
|
|
|
echo
|
|
|
|
echo "To see the server console, execute this command in the container:"
|
|
|
|
echo " screen -r minecraft"
|
2021-04-09 16:28:17 -05:00
|
|
|
|
|
|
|
# Start 'er up
|
2021-05-12 22:41:01 -05:00
|
|
|
cleanup() {
|
|
|
|
screen -p 0 -S minecraft -X stuff save-all^M
|
|
|
|
screen -p 0 -S minecraft -X stuff stop^M
|
|
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
screen -DmS minecraft java $args
|
2021-04-09 16:28:17 -05:00
|
|
|
|