aboutsummaryrefslogtreecommitdiff
path: root/tests/prepare.sh
blob: 89982c3422b62715f9a57c37c0d2eb4eed6ca9aa (plain)
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
#~/bin/bash
if [[ "$(basename -- "$0")" = "prepare.sh" ]]; then
	echo "Please only source this script"
	exit 1
fi

# Write basic configuration
cp ../example.conf mcwrapper.conf

if [[ $PREPARED != "y" ]]; then
	# Move to known directory
	cd "$( readlink -f "${BASH_SOURCE[0]}" )"

	if [[ $MCSERVERS == "y" ]]; then
		mkdir -p minecraft-server
		echo "eula=true" > minecraft-server/eula.txt
		# Get Minecraft 1.8.8
		[ -f minecraft-server/minecraft_server.1.8.8.jar ] || \
			wget https://s3.amazonaws.com/Minecraft.Download/versions/1.8.8/minecraft_server.1.8.8.jar -O minecraft-server/minecraft_server.1.8.8.jar
		# Get Minecraft 1.9
		[ -f minecraft-server/minecraft_server.1.9.jar ] || \
			wget https://s3.amazonaws.com/Minecraft.Download/versions/1.9/minecraft_server.1.9.jar -O minecraft-server/minecraft_server.1.9.jar
		function mcservers_clean {
			find minecraft-server | tail -n +2 | egrep -v "minecraft_server.*jar" | egrep -v "eula.txt" | xargs rm -rf
		}
	fi

	export PATH=$( realpath .. ):$PATH
	export PREPARED="y"
fi