-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcinstall_testing
272 lines (234 loc) · 10.9 KB
/
mcinstall_testing
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
#!/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')
command=$1
ACTUAL_VERSION=1.4.3
SCRIPT_NAME="/usr/bin/mcinstall"
NEW_FILE="/tmp/mcinstall"
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=mcinstall_updater --output /tmp/mcinstall
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.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 () {
cd /tmp/minecraftinstall_files/
java -Xmx1000M -jar BuildTools.jar --rev $1
cp /tmp/minecraftinstall_files/spigot-$1.jar /tmp/test/spigot.jar
}
bungeecord_install() {
dossier_bungeeinstall=$(whiptail --title "McInstall" --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 "McInstall" --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 "McInstall" --gauge "Downloading files...." 8 78 0
RAM=$(whiptail --title "McInstall" --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
}
spigot_install () {
dossier_spigotinstall="~/test"
cd /tmp/test 2> /dev/null
cd /tmp/test 2> /dev/null
if cd /tmp/test 2> /dev/null; then echo " " ; else echo -e "\e[32mThe folder does not exist therefore it has been created.\e[0m" && mkdir -p /tmp/test ; fi
cd /tmp/minecraftinstall_files/
use_buildtools_en_gui 1.14.4
cp /tmp/minecraftinstall_files/launch.sh /tmp/test/launch.sh
cp /tmp/minecraftinstall_files/eula.txt /tmp/test/eula.txt
servername=server1
RAM=2G
sed -i "s/2G/$RAM /g" /tmp/test/launch.sh
sed -i "s/server/$servername /g" /tmp/test/launch.sh
echo "Directory : /tmp/test" >> /tmp/test/INFORMATIONS.txt
echo "Allocated RAM : $RAM" >> /tmp/test/INFORMATIONS.txt
echo "To view the console type the following command : screen -r server" >> /tmp/test/INFORMATIONS.txt
echo "To quit the console without stopping the server please TYPE CTRL+A and CTRL+D" >> /tmp/test/INFORMATIONS.txt;
cd /tmp/test
sh /tmp/test/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=mcinstall_updater --output /tmp/mcinstall
check_upgrade
fi
}
spigotbungee_install () {
whiptail --title "McInstall" --msgbox "The script will first install Bungeecord and then install Spigot." 20 80
bungeecord_install
whiptail --title "McInstall" --msgbox "All the BungeeCord's files have been downloaded. Because you chose to install both Bungee and Spigot, 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 "McInstall" --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 "McInstall" --msgbox "All the Spigot's files have been downloaded. Because you chose to install both Bungee and Spigot, the server will not be started by the script. All the configurations files and other files are stored in $dossier" 20 80
whiptail --title "McInstall" --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 " McInstall Commands"
echo " info : Shows infos about the script"
echo " update : Update the script"
echo " install : Installs a bungee or a spigot server"
echo " help : Shows this message"
}
if [ "$command" == "" ];
then
download_prerequis_vb
./prerequis
spigot_install
else
if [ "$command" == "help" ]; then
help_message
else
if [ "$command" == "install" ];
then
apt-get --force-yes --yes install curl
updatercheck_when_install
echo "--------------------------------------- McInstall -------------------------------"
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 "McInstall" --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 "McInstall" --msgbox "This script allows you to install a Spigot server and / or a Bungeecord server.
A Spigot 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 Spigot servers between each other." 20 80
OPTION=$(whiptail --nocancel --title "McInstall" --menu "Which type of server do you want to install ?" 15 60 4 \
"1" "Spigot only" \
"2" "Bungeecord only" \
"3" "Spigot and bungeecord" 3>&1 1>&2 2>&3)
if [ "$OPTION" = 1 ]; then
spigot_install
else
if [ "$OPTION" = 2 ]; then
bungeecord_install
whiptail --title "McInstall" --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 "McInstall" --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 "------------------------------- McInstall -------------------------------"
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" == "$command" ]; then
download_prerequis_vb
./prerequis
spigot_install
else
if [ "$command" == "test" ]; then
download_prerequis_vb
./prerequis
spigot_install
fi
fi
fi
fi
fi