2016-05-12 02:59:07 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2016-04-10 01:33:32 +00:00
|
|
|
set -e
|
|
|
|
PS1="$"
|
|
|
|
basedir="$(cd "$1" && pwd -P)"
|
|
|
|
workdir="$basedir/work"
|
|
|
|
minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
2018-05-24 18:41:50 +00:00
|
|
|
gitcmd="git -c commit.gpgsign=false"
|
2016-04-10 01:33:32 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# FUNCTIONS
|
|
|
|
#
|
2020-07-28 03:05:37 +00:00
|
|
|
source "$basedir"/scripts/functions.sh
|
2016-04-10 01:33:32 +00:00
|
|
|
|
|
|
|
updateTest() {
|
|
|
|
paperstash
|
2018-05-24 18:41:50 +00:00
|
|
|
$gitcmd reset --hard origin/master
|
2016-04-10 01:33:32 +00:00
|
|
|
paperunstash
|
|
|
|
}
|
|
|
|
|
|
|
|
papertestdir="${PAPER_TEST_DIR:-$workdir/test-server}"
|
|
|
|
|
|
|
|
mkdir -p "$papertestdir"
|
|
|
|
cd "$papertestdir"
|
|
|
|
|
|
|
|
#
|
|
|
|
# SKELETON CHECK
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ ! -d .git ]; then
|
2018-05-24 18:41:50 +00:00
|
|
|
$gitcmd init
|
|
|
|
$gitcmd remote add origin ${PAPER_TEST_SKELETON:-https://github.com/PaperMC/PaperTestServer}
|
|
|
|
$gitcmd fetch origin
|
2016-04-10 01:33:32 +00:00
|
|
|
updateTest
|
|
|
|
elif [ "$2" == "update" ] || [ "$3" == "update" ]; then
|
|
|
|
updateTest
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f server.properties ] || [ ! -d plugins ]; then
|
|
|
|
echo " "
|
|
|
|
echo " Checking out Test Server Skeleton"
|
|
|
|
updateTest
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# EULA CHECK
|
|
|
|
#
|
|
|
|
|
|
|
|
if [ -z "$(grep true eula.txt 2>/dev/null)" ]; then
|
|
|
|
echo
|
|
|
|
echo "$(color 32) It appears you have not agreed to Mojangs EULA yet! Press $(color 1 33)y$(colorend) $(color 32)to confirm agreement to"
|
|
|
|
read -p " Mojangs EULA found at:$(color 1 32) https://account.mojang.com/documents/minecraft_eula $(colorend) " -n 1 -r
|
|
|
|
echo ""
|
|
|
|
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
|
|
|
echo "$(color 1 31)Aborted$(colorend)"
|
|
|
|
exit;
|
|
|
|
fi
|
|
|
|
echo "eula=true" > eula.txt
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# JAR CHECK
|
|
|
|
#
|
|
|
|
|
2018-10-03 01:44:03 +00:00
|
|
|
folder="$basedir/Paper-Server"
|
|
|
|
jar="$folder/target/paper-${minecraftversion}.jar"
|
2020-05-22 04:46:44 +00:00
|
|
|
if [ ! -z "$PAPER_JAR" ]; then
|
|
|
|
jar="$PAPER_JAR"
|
|
|
|
fi
|
2018-10-03 01:44:03 +00:00
|
|
|
if [ ! -d "$folder" ]; then
|
2016-04-10 01:33:32 +00:00
|
|
|
(
|
2018-10-03 01:44:03 +00:00
|
|
|
echo "Building Patched Repo"
|
2016-04-10 01:33:32 +00:00
|
|
|
cd "$basedir"
|
|
|
|
./paper patch
|
|
|
|
)
|
|
|
|
fi
|
|
|
|
|
2020-05-22 04:46:44 +00:00
|
|
|
if [ "$2" == "build" ] || [ "$3" == "build" ]; then
|
2018-10-03 01:44:03 +00:00
|
|
|
(
|
|
|
|
echo "Building Paper"
|
|
|
|
cd "$basedir"
|
|
|
|
mvn package
|
|
|
|
)
|
|
|
|
fi
|
2016-04-10 01:33:32 +00:00
|
|
|
#
|
|
|
|
# JVM FLAGS
|
|
|
|
#
|
|
|
|
|
2020-06-29 01:27:16 +00:00
|
|
|
if [ -f "$jar" ]; then
|
|
|
|
cp "$jar" paper.jar
|
|
|
|
fi
|
2018-09-09 20:59:33 +00:00
|
|
|
baseargs="-server -Xms${PAPER_MIN_TEST_MEMORY:-512M} -Xmx${PAPER_TEST_MEMORY:-2G} -Dfile.encoding=UTF-8 -XX:MaxGCPauseMillis=150 -XX:+UseG1GC "
|
2020-04-10 00:45:38 +00:00
|
|
|
baseargs="$baseargs -DIReallyKnowWhatIAmDoingISwear=1 "
|
|
|
|
baseargs="$baseargs -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=60 "
|
|
|
|
baseargs="$baseargs -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=80 "
|
2016-12-27 21:12:39 +00:00
|
|
|
baseargs="$baseargs -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5100"
|
2016-04-10 01:33:32 +00:00
|
|
|
|
2020-03-04 22:27:59 +00:00
|
|
|
|
2020-05-24 17:09:02 +00:00
|
|
|
cmd="java ${PAPER_TEST_BASE_JVM_ARGS:-$baseargs} ${PAPER_TEST_EXTRA_JVM_ARGS} -jar paper.jar ${PAPER_TEST_APP_ARGS:-} nogui"
|
2016-05-12 02:59:07 +00:00
|
|
|
screen_command="screen -DURS papertest $cmd"
|
|
|
|
tmux_command="tmux new-session -A -s Paper -n 'Paper Test' -c '$(pwd)' '$cmd'"
|
2016-04-10 01:33:32 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# MULTIPLEXER CHOICE
|
|
|
|
#
|
|
|
|
|
2016-05-12 02:59:07 +00:00
|
|
|
multiplex=${PAPER_TEST_MULTIPLEXER}
|
2016-04-10 01:33:32 +00:00
|
|
|
|
2020-05-22 04:46:44 +00:00
|
|
|
if [ ! -z "$PAPER_NO_MULTIPLEX" ]; then
|
|
|
|
cmd="$cmd"
|
|
|
|
elif [ "$multiplex" == "screen" ]; then
|
2016-05-12 02:59:07 +00:00
|
|
|
if command -v "screen" >/dev/null 2>&1 ; then
|
|
|
|
cmd="$screen_command"
|
|
|
|
else
|
|
|
|
echo "screen not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
elif [ "$multiplex" == "tmux" ] ; then
|
|
|
|
if command -v "tmux" >/dev/null 2>&1 ; then
|
|
|
|
cmd="$tmux_command"
|
|
|
|
else
|
|
|
|
echo "tmux not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
2016-04-10 01:33:32 +00:00
|
|
|
else
|
2016-05-12 02:59:07 +00:00
|
|
|
if command -v "screen" >/dev/null 2>&1 ; then
|
|
|
|
cmd="$screen_command"
|
|
|
|
elif command -v "tmux" >/dev/null 2>&1 ; then
|
|
|
|
cmd="$tmux_command"
|
|
|
|
else
|
|
|
|
echo "screen or tmux not found - it is strongly recommended to install either"
|
|
|
|
echo "No terminal multiplexer will be used"
|
|
|
|
fi
|
2016-04-10 01:33:32 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# START / LOG
|
|
|
|
#
|
|
|
|
|
2016-04-10 01:46:09 +00:00
|
|
|
if [ ! -z "$PAPER_TEST_COMMAND_WRAPPER" ]; then
|
2016-05-12 02:59:07 +00:00
|
|
|
$PAPER_TEST_COMMAND_WRAPPER $cmd
|
2016-04-10 01:46:09 +00:00
|
|
|
else
|
2016-05-12 02:59:07 +00:00
|
|
|
echo "Running command: $cmd"
|
|
|
|
echo "In directory: $(pwd)"
|
2020-05-22 04:46:44 +00:00
|
|
|
#sleep 1
|
2016-05-12 02:59:07 +00:00
|
|
|
/usr/bin/env bash -c "$cmd"
|
2016-04-10 01:46:09 +00:00
|
|
|
fi
|