-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.sh
executable file
·70 lines (60 loc) · 1.58 KB
/
test.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
#!/bin/bash
cd $(dirname $0)
BASE_DIR=$(pwd)
mkdir -p test
cd test
function set_mcdr_config(){
while IFS='' read line; do
if [[ "${line}" == 'check_update:'* ]]; then
echo 'check_update: false'
# elif [[ "${line}" == 'advanced_console:'* ]]; then
# echo 'advanced_console: false'
# elif [[ "${line}" == 'disable_console_color:'* ]]; then
# echo 'disable_console_color: true'
elif [[ "${line}" == 'debug:'* ]]; then
echo "${line}"
IFS='' read line
if [[ "${line}" == ' all:'* ]]; then
echo ' all: true'
fi
else
echo "${line}"
fi
done <config.yml >.tmp.config.yml
cp .tmp.config.yml config.yml
rm .tmp.config.yml
}
if ! python3 --version; then
echo '[ERROR] Cannot find python3'
exit 2
fi
if ! [ -f config.yml ]; then
echo '==> Initing mcdreforged'
python3 -m mcdreforged init || exit $?
set_mcdr_config
fi
if ! [ -n "$SERVER_URL" ]; then
SERVER_URL=https://piston-data.mojang.com/v1/objects/c9df48efed58511cdd0213c56b9013a7b5c9ac1f/server.jar
fi
SERVER_DIR=server
SERVRE_JAR=$SERVER_DIR/minecraft_server.jar
if ! [ -f "$SERVRE_JAR" ]; then
echo "==> Getting '$SERVER_URL'"
if ! wget -O "$SERVRE_JAR" "$SERVER_URL" 2>/dev/null; then
curl -L --output "$SERVRE_JAR" "$SERVER_URL" || exit $?
fi
fi
echo '==> Packing plugin'
P=$(pwd)
cd ${BASE_DIR}
_id=($(python3 -c "import json
o = json.load(open('mcdreforged.plugin.json','r'))
print(o['id'])"))
if [ $? -ne 0 ]; then
echo
echo "[ERROR] Cannot parse 'mcdreforged.plugin.json'"
exit 1
fi
python3 -m mcdreforged pack -o "${P}/plugins" -n "${_id}-dev" || exit $?
cd ${P}
exec python3 -m mcdreforged