forked from PaperMC/Paper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestServer.sh
executable file
·148 lines (126 loc) · 3.5 KB
/
testServer.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/usr/bin/env bash
set -e
PS1="$"
basedir="$(cd "$1" && pwd -P)"
workdir="$basedir/work"
minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
gitcmd="git -c commit.gpgsign=false"
#
# FUNCTIONS
#
source "$basedir"/scripts/functions.sh
updateTest() {
paperstash
$gitcmd reset --hard origin/master
paperunstash
}
papertestdir="${PAPER_TEST_DIR:-$workdir/test-server}"
mkdir -p "$papertestdir"
cd "$papertestdir"
#
# SKELETON CHECK
#
if [ ! -d .git ]; then
$gitcmd init
$gitcmd remote add origin ${PAPER_TEST_SKELETON:-https://github.com/PaperMC/PaperTestServer}
$gitcmd fetch origin
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
#
folder="$basedir/Paper-Server"
jar="$folder/target/paper-${minecraftversion}.jar"
if [ ! -z "$PAPER_JAR" ]; then
jar="$PAPER_JAR"
fi
if [ ! -d "$folder" ]; then
(
echo "Building Patched Repo"
cd "$basedir"
./paper patch
)
fi
if [ "$2" == "build" ] || [ "$3" == "build" ]; then
(
echo "Building Paper"
cd "$basedir"
mvn package
)
fi
#
# JVM FLAGS
#
if [ -f "$jar" ]; then
cp "$jar" paper.jar
fi
baseargs="-server -Xms${PAPER_MIN_TEST_MEMORY:-512M} -Xmx${PAPER_TEST_MEMORY:-2G} -Dfile.encoding=UTF-8 -XX:MaxGCPauseMillis=150 -XX:+UseG1GC "
baseargs="$baseargs -DIReallyKnowWhatIAmDoingISwear=1 "
baseargs="$baseargs -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=60 "
baseargs="$baseargs -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=80 "
baseargs="$baseargs -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5100"
cmd="java ${PAPER_TEST_BASE_JVM_ARGS:-$baseargs} ${PAPER_TEST_EXTRA_JVM_ARGS} -jar paper.jar ${PAPER_TEST_APP_ARGS:-} nogui"
screen_command="screen -DURS papertest $cmd"
tmux_command="tmux new-session -A -s Paper -n 'Paper Test' -c '$(pwd)' '$cmd'"
#
# MULTIPLEXER CHOICE
#
multiplex=${PAPER_TEST_MULTIPLEXER}
if [ ! -z "$PAPER_NO_MULTIPLEX" ]; then
cmd="$cmd"
elif [ "$multiplex" == "screen" ]; then
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
else
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
fi
#
# START / LOG
#
if [ ! -z "$PAPER_TEST_COMMAND_WRAPPER" ]; then
$PAPER_TEST_COMMAND_WRAPPER $cmd
else
echo "Running command: $cmd"
echo "In directory: $(pwd)"
#sleep 1
/usr/bin/env bash -c "$cmd"
fi