forked from lordofwizard/mcserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstallJava
More file actions
executable file
·139 lines (119 loc) · 2.99 KB
/
installJava
File metadata and controls
executable file
·139 lines (119 loc) · 2.99 KB
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
#!/bin/bash
set -e
export THIS_DIR="$PWD"
# -----------------------------
# Ask Minecraft version (ONCE)
# -----------------------------
echo ""
echo "Enter Minecraft version (example: 1.14.2, 1.16.5, 1.18.2, 1.20.4 or latest)"
read -rp "> " MC_VERSION
# Default
MC_VERSION="${MC_VERSION:-latest}"
export MC_VERSION
# -----------------------------
# Decide Java version
# -----------------------------
JAVA_PKG=""
case "$MC_VERSION" in
1.1[0-6]*)
JAVA_PKG="temurin-8-jdk"
;;
1.17*)
JAVA_PKG="temurin-16-jdk"
;;
1.18*|1.19*)
JAVA_PKG="temurin-17-jdk"
;;
1.20*)
JAVA_PKG="temurin-21-jdk"
;;
latest)
JAVA_PKG="temurin-21-jdk"
;;
*)
JAVA_PKG="temurin-17-jdk"
;;
esac
echo "> Minecraft version: $MC_VERSION"
echo "> Installing Java package: $JAVA_PKG"
# -----------------------------
# Dependencies (UNCHANGED)
# -----------------------------
sudo apt update -y
sudo apt install -y \
screen neofetch curl wget jq \
apt-transport-https ca-certificates gnupg lsb-release
# -----------------------------
# Adoptium (Temurin) repo
# -----------------------------
if [[ ! -f /etc/apt/sources.list.d/adoptium.list ]]; then
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public \
| sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/adoptium.gpg
echo "deb https://packages.adoptium.net/artifactory/deb $(lsb_release -cs) main" \
| sudo tee /etc/apt/sources.list.d/adoptium.list
fi
sudo apt update -y
sudo apt install -y "$JAVA_PKG"
echo "> Java installed successfully"
java -version
# -----------------------------
# Server directory
# -----------------------------
mkdir -p server
# -----------------------------
# Server installer menu
# -----------------------------
install_server () {
choice="$1"
cd JavaInstallScripts || exit 1
chmod +x *
case "$choice" in
""|1) ./VanillaInstall ;;
2) ./PaperInstall ;;
3) ./ForgeInstall ;;
4) ./SpongeInstall ;;
5) ./FabricInstall ;;
6) ./SpigotInstall ;;
7) ./BungeecordInstall ;;
*)
echo "> Invalid response"
cd "$THIS_DIR"
exec ./installJava
;;
esac
}
echo ""
echo "-- Pick Server Type --"
echo "[1] Vanilla"
echo "[2] Paper"
echo "[3] Forge"
echo "[4] Sponge"
echo "[5] Fabric"
echo "[6] Spigot"
echo "[7] Bungeecord"
read -rp "> " choiceForServer
install_server "$choiceForServer"
cd "$THIS_DIR"
# -----------------------------
# Playit.gg (UNCHANGED)
# -----------------------------
echo "> Installing Playit.gg..."
curl -SsL https://playit-cloud.github.io/ppa/key.gpg | sudo apt-key add -
sudo curl -SsL -o /etc/apt/sources.list.d/playit-cloud.list \
https://playit-cloud.github.io/ppa/playit-cloud.list
sudo apt update
sudo apt install -y playit
echo "> Playit.gg installed"
# -----------------------------
# Start prompt
# -----------------------------
echo ""
echo "Start server now?"
echo "[1] Yes"
echo "[2] No"
read -rp "> " StartServer
if [[ "$StartServer" == "1" ]]; then
./startserver
else
echo "You can start later using: ./startserver"
fi