forked from itzg/docker-minecraft-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
executable file
·98 lines (90 loc) · 2.32 KB
/
launch.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
#!/bin/bash
if [ ! -e eula.txt ]; then
if [ "$EULA" != "" ]; then
echo "# Generated via Docker on $(date)" > eula.txt
echo "eula=$EULA" >> eula.txt
else
echo ""
echo "Please accept the Minecraft EULA at"
echo " https://account.mojang.com/documents/minecraft_eula"
echo "by adding the following immediately after 'docker run':"
echo " -e EULA=TRUE"
echo ""
exit 1
fi
fi
if [ ! -e server.properties ]; then
cp /server.properties .
fi
# If supplied with a URL for a world, download it and unpack
if [[ "$WORLD" ]]; then
case "X$WORLD" in
X[Hh][Tt][Tt][Pp]*)
echo "Downloading world..."
echo "$WORLD"
wget -q -O - "$WORLD" > world.zip
echo "Unzipping world..."
unzip -q world.zip
rm -f world.zip
if [ ! -d world ]; then
echo World directory not found
for i in */level.dat; do
if [ -f "$i" ]; then
d=`dirname "$i"`
echo Renaming world directory from $d
mv -f "$d" world
fi
done
fi
;;
*)
echo "Invalid URL given for world: Must be HTTP or HTTPS and a ZIP file"
;;
esac
fi
# If supplied with a URL for a modpack (simple zip of jars), download it and unpack
if [[ "$MODPACK" ]]; then
case "X$MODPACK" in
X[Hh][Tt][Tt][Pp]*[Zz][iI][pP])
echo "Downloading modpack..."
echo "$MODPACK"
wget -q -O /tmp/modpack.zip "$MODPACK"
mkdir -p mods
unzip -d mods /tmp/modpack.zip
rm -f /tmp/modpack.zip
;;
*)
echo "Invalid URL given for modpack: Must be HTTP or HTTPS and a ZIP file"
;;
esac
fi
if [ -n "$ICON" -a ! -e server-icon.png ]; then
echo "Using server icon from $ICON..."
# Not sure what it is yet...call it "img"
wget -q -O /tmp/icon.img $ICON
specs=$(identify /tmp/icon.img | awk '{print $2,$3}')
if [ "$specs" = "PNG 64x64" ]; then
mv /tmp/icon.img server-icon.png
else
echo "Converting image to 64x64 PNG..."
convert /tmp/icon.img -resize 64x64! server-icon.png
fi
fi
# If any modules have been provided, copy them over
[ -d mods ] || mkdir mods
for m in /mods/*.jar
do
if [ -f "$m" ]; then
echo Copying mod `basename "$m"`
cp -f "$m" mods
fi
done
[ -d config ] || mkdir config
for c in /config/*
do
if [ -f "$c" ]; then
echo Copying configuration `basename "$c"`
cp -rf "$c" config
fi
done
exec java $JVM_OPTS -jar "/server.jar"