43 lines
1.0 KiB
Bash
Executable File
43 lines
1.0 KiB
Bash
Executable File
#! /bin/bash
|
|
#
|
|
# start-server.sh
|
|
# Copyright (C) 2021 Vintage Salt <rehashedsalt@cock.li>
|
|
#
|
|
# Distributed under terms of the MIT license.
|
|
#
|
|
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
|
|
unzip pack.zip
|
|
directory="$(find . -type d -iname "mods" -execdir pwd \; | sort -n | head -n 1)"
|
|
echo "Found modpack directory: $directory"
|
|
rsync -av "$directory"/ /minecraft/
|
|
popd > /dev/null 2>&1
|
|
fi
|
|
|
|
# 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"
|
|
|
|
# Start 'er up
|
|
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
|
|
|