-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
paperinstall
347 lines (300 loc) · 14.6 KB
/
paperinstall
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
#!/bin/bash
if [ "$EUID" -ne 0 ]
then echo "Please run as root or using the command sudo"
exit
fi
LATEST_VERSION=$(curl -s 'https://uploads.admlbs.fr/version_paper')
command=$1
ACTUAL_VERSION=1.0
SCRIPT_NAME="/usr/bin/paperinstall"
NEW_FILE="/tmp/paperinstall"
spigot_install () {
dossier_spigotinstall=$(whiptail --title "Paper Install" --inputbox "In which directory do you want to install your Bungeecord server? (Example: /home/bungee and no /home/bungee/)" 10 60 3>&1 1>&2 2>&3)
cd $dossier_spigotinstall 2> /dev/null
cd $dossier_spigotinstall 2> /dev/null
if cd $dossier_spigotinstall 2> /dev/null; then echo " " ; else echo -e "\e[32mThe folder does not exist therefore it has been created.\e[0m" && mkdir -p $dossier_spigotinstall ; fi
cd /tmp/minecraftinstall_files/
OPTION=$(whiptail --nocancel --title "Paper Install" --menu "Choose your version (using the keyboard arrows and then press enter) By installing Paper you agree with Paper's and Mojang's EULA." 15 60 4 \
"1" "1.8.8" \
"2" "1.9.4" \
"3" "1.10.2" \
"4" "1.11.2" \
"5" "1.12.2" \
"6" "1.13.2" \
"7" "1.14.4" \
"8" "1.15.2" 3>&1 1>&2 2>&3)
if [ "$OPTION" = 1 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.8.8.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
else
if [ "$OPTION" = 2 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.9.4.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
else
if [ "$OPTION" = 3 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.10.2.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
else
if [ "$OPTION" = 4 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.11.2.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
else
if [ "$OPTION" = 5 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.12.2.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
else
if [ "$OPTION" = 6 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.13.2.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
else
if [ "$OPTION" = 7 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.14.4.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
else
if [ "$OPTION" = 8 ]; then
curl https://uploads.admlbs.fr/download.php?file=paper-1.15.2.jar --output /tmp/minecraftinstall_files/paper.jar
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
fi
fi
fi
fi
fi
fi
fi
fi
cp /tmp/minecraftinstall_files/launch.sh $dossier_spigotinstall/launch.sh
cp /tmp/minecraftinstall_files/eula.txt $dossier_spigotinstall/eula.txt
servername=$(whiptail --title "Paper Install" --inputbox "Choose your server's name. (Ex : server, server1 or server2)" 10 60 3>&1 1>&2 2>&3)
RAM=$(whiptail --title "Paper Install" --inputbox "How much RAM do you want to allocate to your server ? (Express it in G or M, Example : 2G or 2000M )" 10 60 3>&1 1>&2 2>&3)
sed -i "s/2G/$RAM /g" $dossier_spigotinstall/launch.sh
sed -i "s/server/$servername /g" $dossier_spigotinstall/launch.sh
echo "Directory : $dossier_spigotinstall" >> $dossier_spigotinstall/INFORMATIONS.txt
echo "Allocated RAM : $RAM" >> $dossier_spigotinstall/INFORMATIONS.txt
echo "To view the console type the following command : screen -r server" >> $dossier_spigotinstall/INFORMATIONS.txt
echo "To quit the console without stopping the server please TYPE CTRL+A and CTRL+D" >> $dossier_spigotinstall/INFORMATIONS.txt;
cd $dossier_spigotinstall
sh $dossier_spigotinstall/launch.sh
}
updatercheck_when_install () { #VERSION OF THE UPDATER WHEN HE'S AUTO-LAUNCHED WITH THE INSTALL COMMAND OF THE SCRIPT
if [ "$ACTUAL_VERSION" == "$LATEST_VERSION" ]
then :
else
read -p "You do not have the latest version of the program. We advise you to update it as soon as possible. Type y to start the update. (y or n)" doit
case $doit in
n|N) echo -e "You refused to update the program." && exit ;;
y|Y) echo -e "\e[32mLoading updater.\e[0m" ;;
*) echo "Please type y (yes) or n (no)" && exit ;;
esac
curl https://uploads.admlbs.fr/download.php?file=paperinstall_updater --output /tmp/paperinstall
check_upgrade
fi
}
check_upgrade () {
[ -f "$NEW_FILE" ] && {
cp "$NEW_FILE" "$SCRIPT_NAME"
chmod 0777 "$SCRIPT_NAME"
rm -f "$NEW_FILE"
clear
echo "The script has been updated"
exit 0
}
}
updater_check () {
if [ "$ACTUAL_VERSION" == "$LATEST_VERSION" ]
then echo "Already last version."
else
read -p "You do not have the latest version of the program. We advise you to update it as soon as possible. Type y to start the update. (y or n)" doit
case $doit in
n|N) echo -e "You refused to update the program." && exit ;;
y|Y) echo -e "\e[32mLoading updater.\e[0m" ;;
*) echo "Please type y (yes) or n (no)" && exit ;;
esac
curl https://uploads.admlbs.fr/download.php?file=paperinstall_updater --output /tmp/paperinstall
check_upgrade
fi
}
download_prerequis_vb () { #DOWNLOAD NEEDED FILE
rm --recursive /tmp/minecraftinstall_files
mkdir /tmp/minecraftinstall_files/
curl https://uploads.admlbs.fr/download.php?file=prerequis --output /tmp/minecraftinstall_files/prerequis
curl https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar --output /tmp/minecraftinstall_files/BuildTools.jar
curl https://uploads.admlbs.fr/download.php?file=buildtools2.bash --output /tmp/minecraftinstall_files/buildtools2.bash
curl https://uploads.admlbs.fr/download.php?file=launch_paper.sh --output /tmp/minecraftinstall_files/launch.sh
curl https://uploads.admlbs.fr/download.php?file=eula.txt --output /tmp/minecraftinstall_files/eula.txt
chmod 0777 --recursive /tmp/minecraftinstall_files
cd /tmp/minecraftinstall_files/
}
use_buildtools_en_gui () {
cp /tmp/minecraftinstall_files/paper.jar $dossier_spigotinstall/paper.jar
}
bungeecord_install() {
dossier_bungeeinstall=$(whiptail --title "Paper Install" --inputbox "In which directory do you want to install your Bungeecord server? (Example: /home/bungee and no /home/bungee/)" 10 60 3>&1 1>&2 2>&3)
cd $dossier_bungeeinstall 2> /dev/null
if cd $dossier_bungeeinstall 2> /dev/null; then echo " " ; else echo -e "\e[32mThe folder does not exist therefore it has been created.\e[0m" && mkdir -p $dossier_bungeeinstall ; fi
cd $dossier_bungeeinstall
if (whiptail --title "Paper Install" --yes-button "I agree" --no-button "I disagree" --yesno "The script will install the latest version of BungeeCord using the official Spigot's official Jenkins page. That means your machine will download the BungeeCord.jar and the prerequisites itself. This operation may take a while depending of your Internet connexion. By continuing you accept Spigot's and Mojang's EULAs." 20 80) then
screen -dm bash -c 'wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/bootstrap/target/BungeeCord.jar; wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/module/cmd-alert/target/cmd_alert.jar; wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/module/cmd-find/target/cmd_find.jar; wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/module/cmd-list/target/cmd_list.jar; wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/module/cmd-send/target/cmd_send.jar; wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/module/cmd-server/target/cmd_server.jar; wget https://ci.md-5.net/job/BungeeCord/lastSuccessfulBuild/artifact/module/reconnect-yaml/target/reconnect_yaml.jar; curl https://uploads.admlbs.fr/download.php?file=launch_bungee.sh --output launch.sh;'
cd $dossier_bungeeinstall
{
percentage="0"
while (true)
do
proc=$(ps aux | grep -v grep | grep -e "wget")
if [[ "$proc" == "" ]] && [[ "$percentage" -eq "0" ]];
then
break;
elif [[ "$proc" == "" ]] && [[ "$percentage" -gt "0" ]];
then
sleep 2
echo 98
sleep 1
echo 99
sleep 1
echo 100
sleep 1
break;
elif [[ "51" -eq "$percentage" ]]
then
percentage="30"
fi
sleep 1
echo $percentage
percentage=$(expr $percentage + 1)
done
} | whiptail --title "Paper Install" --gauge "Downloading files...." 8 78 0
RAM=$(whiptail --title "Paper Install" --inputbox "How much RAM do you want to allocate to your server ? (Express it in G or M, Example : 2G or 2000M )" 10 60 3>&1 1>&2 2>&3)
sed -i "s/2G/$RAM /g" $dossier_bungeeinstall/launch.sh
echo "Directory : $dossier_bungeeinstall" >> $dossier_bungeeinstall/INFORMATIONS.txt
echo "Allocated RAM : $RAM" >> $dossier_bungeeinstall/INFORMATIONS.txt
echo "To view the console type the following command : screen -r bungee" >> $dossier_bungeeinstall/INFORMATIONS.txt
echo "To quit the console without stopping the server please TYPE CTRL+A and CTRL+D" >> $dossier_bungeeinstall/INFORMATIONS.txt;
else
clear && exit 0
fi
}
spigotbungee_install () {
whiptail --title "Paper Install" --msgbox "The script will first install Bungeecord and then install Paper." 20 80
bungeecord_install
whiptail --title "Paper Install" --msgbox "All the BungeeCord's files have been downloaded. Because you chose to install both Bungee and Paper, the server will not be started by the script. All the configurations files and other files are stored in $dossier_bungeeinstall" 20 80
whiptail --title "Paper Install" --msgbox "Command to start the server : sh $dossier_bungeeinstall/launch.sh
To view the console : screen -r bungee
All of the informations are available in the INFORMATIONS.txt file." 20 80
spigot_install
whiptail --title "Paper Install" --msgbox "All the Paper's files have been downloaded. Because you chose to install both Bungee and Paper, the server will not be started by the script. All the configurations files and other files are stored in $dossier" 20 80
whiptail --title "Paper Install" --msgbox "Command to start the server : sh $dossier/launch.sh
To view the console : screen -r $servername
All of the informations are available in the INFORMATIONS.txt file." 20 80
}
help_message () {
echo " Paper Install Commands"
echo " info : Shows infos about the script"
echo " update : Update the script"
echo " install : Installs a bungee or a Paper server"
echo " help : Shows this message"
}
if [ "$command" == "" ];
then
help_message
else
if [ "$command" == "help" ]; then
help_message
else
if [ "$command" == "install" ];
then
apt-get --force-yes --yes install curl
updatercheck_when_install
echo "--------------------------------------- Paper Install -------------------------------"
download_prerequis_vb
bash -c './prerequis >/dev/null 2>&1'
{
i="0"
while (true)
do
proc=$(ps aux | grep -v grep | grep -e "apt")
if [[ "$proc" == "" ]]; then break; fi
sleep 1
echo $i
i=$(expr $i + 1)
done
echo 100
sleep 2
} | whiptail --title "Paper Install" --gauge "Installing prerequisite packages" 8 78 0
git config --global --unset core.autocrlf
clear
echo -e "\033[32m===================================== Installation =====================================\e[0m"
echo -e "\033[33m===================================== Server type =======================================\e[0m"
whiptail --title "Paper Install" --msgbox "This script allows you to install a Paper server and / or a Bungeecord server.
A Paper server is an optimized Minecraft server that allows you to install plugins to customize your server.
A Bungeecord server is a "proxy" that allows you to link different Paper/Spigot servers between each other." 20 80
OPTION=$(whiptail --nocancel --title "Paper Install" --menu "Which type of server do you want to install ?" 15 60 4 \
"1" "Paper only" \
"2" "Bungeecord only" \
"3" "Paper and bungeecord" 3>&1 1>&2 2>&3)
if [ "$OPTION" = 1 ]; then
spigot_install
else
if [ "$OPTION" = 2 ]; then
bungeecord_install
whiptail --title "Paper Install" --msgbox "All the BungeeCord's files have been downloaded. The script will start the server for the first time. All the configurations files and other files are stored in $dossier" 20 80
whiptail --title "Paper Install" --msgbox "Command to start the server : sh $dossier_bungeeinstall/launch.sh
To view the console : screen -r bungee
All of the informations are available in the INFORMATIONS.txt file." 20 80
cd $dossier_bungeeinstall
sh $dossier_bungeeinstall/launch.sh
else
if [ "$OPTION" = 3 ]; then
spigotbungee_install
cd $dossier
sh $dossier/launch.sh
fi
fi
fi
fi
if [ "$command" == "info" ]; then
echo "------------------------------- Paper Install -------------------------------"
echo -e "\033[32m===================================== Infos =====================================\e[0m"
echo "Version : $ACTUAL_VERSION Latest Version : $LATEST_VERSION"
echo "Developper : Adam - LaaBaSe"
echo "Contact : [email protected]"
updater_check
fi
if [ "$command" == "update" ]; then
updater_check
else
if [ "$command" == "debug" ]; then
download_prerequis_vb
rm minecraftinstall_files/launch.sh
./prerequis
cd /tmp/testmc 2> /dev/null
cd /tmp/testmc 2> /dev/null
if cd /tmp/testmc 2> /dev/null; then echo " " ; else echo -e "\e[32mThe folder does not exist therefore it has been created.\e[0m" && mkdir -p /tmp/testmc ; fi
cd /tmp/minecraftinstall_files/
use_buildtools_test_gui 1.14.4
cp /tmp/minecraftinstall_files/launch.sh /tmp/testmc/launch.sh
cp /tmp/minecraftinstall_files/eula.txt /tmp/testmc/eula.txt
servername=server1
RAM=2G
sed -i "s/2G/$RAM /g" /tmp/testmc/launch.sh
sed -i "s/server/$servername /g" /tmp/testmc/launch.sh
echo "Directory : /tmp/testmc" >> /tmp/testmc/INFORMATIONS.txt
echo "Allocated RAM : $RAM" >> /tmp/testmc/INFORMATIONS.txt
echo "To view the console type the following command : screen -r server" >> /tmp/testmc/INFORMATIONS.txt
echo "To quit the console without stopping the server please TYPE CTRL+A and CTRL+D" >> /tmp/testmc/INFORMATIONS.txt;
cd /tmp/testmc
ls -l
FILE=/tmp/testmc/spigot.jar
if [[ -f "$FILE" ]]; then
echo "$FILE exist"
exit 0
else
echo "$FILE not here"
exit 1
fi
else
if [ "$command" == "$command" ]; then
help_message
fi
fi
fi
fi
fi