-
Notifications
You must be signed in to change notification settings - Fork 0
/
initserver.sh
executable file
·238 lines (210 loc) · 5.74 KB
/
initserver.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ] || [ -z "$4" ]
then
echo "Please provide four arguments"
echo "$0 <spigot-release> <plugin-type> <plugin-release> <server-ram>"
echo "Spigot-release:"
echo " - latest "
echo " - 1.12.2 "
echo " - ..."
echo "plugin-type: "
echo " - MM"
echo " - VD"
echo " - BB"
echo " - TB"
echo "plugin-release:"
echo " - latest"
echo " - beta"
echo " - stable"
echo "server-ram:"
echo " - 512"
echo " - 256"
echo "Add in an optional fith argument "skip" to skipp the buildtools process completly! Remember ONLY do this when the spigot.jar is ALREADY in place!"
exit
fi
if ! [ -x "$(command -v ruby)" ];
then
echo "Installing Ruby and screens"
sudo apt-get update
#Install ruby to acces Json data from website to get the latest LuckyPerms
sudo apt-get install ruby -y
#Install screens while we're at it
sudo apt-get install screen
#Install w3m while we're at it
sudo apt-get install w3m
fi
version="$1" #Minecraft version
plugintype="$2" #Plugin type (MM, VD, BB)
pluginversion="$3" #latest, beta, stable
downloadlink="https://download.plugily.xyz/direct.php"
luckpermsdownloadlink=$(curl -s "https://metadata.luckperms.net/data/downloads" | ruby -rjson -e 'data = JSON.parse(STDIN.read); puts data["downloads"]["bukkit"]')
serverram="$4"
extras="$5"
if [[ ! -d ./BuildTools ]]
then
mkdir ./BuildTools
fi
cd BuildTools
if [ ! -d ./spigot-*.jar ]
then
rm ./spigot-.jar
fi
if [ -z "$5"]
then
extras=""
fi
#Put buildTools in a function so we don't have to run it always
runBuildTools(){
curl -z BuildTools.jar -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
chmod +x BuildTools.jar
java -jar BuildTools.jar --rev $version
}
cd ..
if [[ ! -d ./Plugins ]];
then
echo "MAKING PLUGINS"
mkdir ./Plugins
cd Plugins
mkdir MurderMystery
mkdir TheBridge
mkdir VillageDefense
mkdir BuildBattle
mkdir LuckPerms
cd ..
fi
cd ./Plugins
cd ./LuckPerms
if [ -d ./LuckPerms.jar ];
then
rm ./LuckPerms.jar
fi
wget "$luckpermsdownloadlink" -O LuckPerms.jar
cd ..
if [ $plugintype = "MM" ] || [ $plugintype = "mm" ];
then
cd ./MurderMystery
if [ -d ./MurderMystery$3.jar ]
then
rm ./MurderMystery$3.jar
fi
w3m -dump_source "$downloadlink?type=MurderMystery&version=$3" > ./Plugins/MurderMystery/MurderMystery$3.jar
fi
if [ $plugintype = "VD" ] || [ $plugintype = "vd" ];
then
cd ./VillageDefense
if [ -d ./VillageDefense$3.jar ]
then
rm ./VillageDefense$3.jar
fi
w3m -dump_source "$downloadlink?type=VillageDefense&version=$3" > ./Plugins/VillageDefense/VillageDefense$3.jar
fi
if [ $plugintype = "TB" ] || [ $plugintype = "TB" ];
then
cd ./TheBridge
if [ -d ./TheBridge$3.jar ]
then
rm ./TheBridge$3.jar
fi
w3m -dump_source "$downloadlink?type=TheBridge&version=$3" > ./Plugins/TheBridge/TheBridge$3.jar
fi
if [ $plugintype = "BB" ] || [ $plugintype = "bb" ];
then
cd ./BuildBattle
if [ -d ./BuildBattle$3.jar ]
then
rm ./BuildBattle$3.jar
fi
w3m -dump_source "$downloadlink?type=BuildBattle&version=$3" > ./Plugins/BuildBattle/BuildBattle$3.jar
fi
cd ..
cd ..
#Files are now all downloaded, server building starts here
if [[ ! -d ./Servers ]]
then
mkdir ./Servers
fi
cd ./Servers
runnedBuildTools="false"
if [[ $extras == "skip" ]];
then
runnedBuildTools="true"
fi
if [[ ! -d ./$version$serverram ]]
then
cd ..
cd ./BuildTools
runBuildTools
cd ..
cd ./Servers
runnedBuildTools="true"
mkdir ./$version$serverram
mkdir ./$version$serverram/plugins
cd ..
cp -v ./BuildTools/spigot-*.jar ./Servers/$version$serverram
if [ ! -e ./Servers/$version$serverram/start_server.sh ]; then
echo "java -Xms${serverram}M -Xmx${serverram}M -jar spigot.jar">> ./Servers/$version$serverram/start_server.sh
fi
if [ ! -e ./Servers/$version$serverram/eula.txt ];then
echo "eula=true" >> ./Servers/$version$serverram/eula.txt
fi
cp -v ./Plugins/LuckPerms/LuckPerms.jar ./Servers/$version$serverram/plugins
cd ./Servers/$version$serverram
mv ./spigot-*.jar ./spigot.jar
chmod +x ./start_server.sh
cd ..
fi
cd ..
#Replace the latest version spigot version
if [[ $version = "latest" ]];
then
if [[ $runnedBuildTools -ne "true" ]];
then
cd ./BuildTools
runBuildTools
cd ..
fi
cd ./Servers/$version$serverram
cd ..
cd ..
rm -f ./spigot-*.jar
cp -v ./BuildTools/spigot-*.jar ./Servers/$version$serverram
cd ./Servers/$version$serverram
mv ./spigot-*.jar ./spigot.jar
cd ..
cd ..
fi
cd ./Servers
#Remove all the our own plugins
cd ./$version$serverram/plugins
rm -f ./BuildBattle*.jar
rm -f ./MurderMystery*.jar
rm -f ./VillageDefense*.jar
rm -f ./TheBridge*.jar
cd ..
cd ..
cd ..
#Install LuckPerms in the server
cp -u ./Plugins/LuckPerms/LuckPerms.jar ./Servers/$version$serverram/plugins
if [ $plugintype = "MM" ] || [ $plugintype = "mm" ]
then
cp -u ./Plugins/MurderMystery/MurderMystery$pluginversion.jar ./Servers/$version$serverram/plugins
fi
if [ $plugintype = "VD" ] || [ $plugintype = "vd" ]
then
cp -u ./Plugins/VillageDefense/VillageDefense$pluginversion.jar ./Servers/$version$serverram/plugins
fi
if [ $plugintype = "BB" ] || [ $plugintype = "bb" ]
then
cp -u ./Plugins/BuildBattle/BuildBattle$pluginversion.jar ./Servers/$version$serverram/plugins
fi
if [ $plugintype = "TB" ] || [ $plugintype = "tb" ]
then
cp -u ./Plugins/TheBridge/TheBridge$pluginversion.jar ./Servers/$version$serverram/plugins
fi
pwd
cd ./Servers/$version$serverram
screen -S minecraft$version$serverram sudo ./start_server.sh