-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
146 lines (127 loc) · 5.21 KB
/
build.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
#!/bin/bash
# Version = "V2"
# Terminal colors
GREEN='\033[0;32m'
WHITE='\033[0;37m'
CYAN='\033[0;36m'
RED='\033[0;31m'
# Function to download files
download() {
wget -q --show-progress -O "$2" "$1"
}
check_arch() {
arch=$(uname -m)
if [[ "$arch" == *"Android"* ]]; then
bash termux/termux.sh
fi
}
# Function to install Cloudflared
install_cloudflared() {
mkdir -p .server
if [[ -e ".server/cloudflared" ]]; then
echo -e "\n${GREEN}[${WHITE}+${GREEN}]${GREEN} Cloudflared already installed."
else
echo -e "\n${GREEN}[${WHITE}+${GREEN}]${CYAN} Installing Cloudflared..."${WHITE}
arch=$(uname -m)
if [[ "$arch" == *'arm'* || "$arch" == *'Android'* ]]; then
download 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm' 'cloudflared'
elif [[ "$arch" == *'aarch64'* ]]; then
download 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-arm64' 'cloudflared'
elif [[ "$arch" == *'x86_64'* ]]; then
download 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64' 'cloudflared'
else
download 'https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-386' 'cloudflared'
fi
chmod +x ./cloudflared
mv ./cloudflared .server/cloudflared
if [[ -e ".server/cloudflared" ]]; then
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Cloudflared installed successfully."
else
echo -e "${RED}[${WHITE}--${RED}]${CYAN} Failed to move Cloudflared to .server directory."
fi
fi
}
install_java() {
echo -e "\n${GREEN}[${WHITE}+${GREEN}]${CYAN} Detecting system architecture and distribution..."${WHITE}
# Check architecture
ARCH=$(uname -m)
if [[ "$ARCH" == "x86_64" ]]; then
ARCH_TYPE="x64"
elif [[ "$ARCH" == "aarch64" ]]; then
ARCH_TYPE="aarch64"
else
echo -e "${RED}[${WHITE}--${RED}]${CYAN} Unsupported architecture: $ARCH"
exit 1
fi
# Check distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
else
echo -e "${RED}[${WHITE}--${RED}]${CYAN} Unsupported distribution or /etc/os-release not found."
exit 1
fi
# Set download URL based on architecture and distribution
if [[ "$ARCH_TYPE" == "x64" ]]; then
if [[ "$DISTRO" == "ubuntu" || "$DISTRO" == "debian" ]]; then
URL="https://download.oracle.com/java/21/archive/jdk-21.0.3_linux-x64_bin.deb"
PACKAGE_TYPE="deb"
elif [[ "$DISTRO" == "centos" || "$DISTRO" == "fedora" || "$DISTRO" == "rhel" ]]; then
URL="https://download.oracle.com/java/21/archive/jdk-21.0.3_linux-x64_bin.rpm"
PACKAGE_TYPE="rpm"
else
echo -e "${RED}[${WHITE}--${RED}]${CYAN} Unsupported distribution for x64: $DISTRO"
exit 1
fi
elif [[ "$ARCH_TYPE" == "aarch64" ]]; then
if [[ "$DISTRO" == "ubuntu" || "$DISTRO" == "debian" ]]; then
URL="https://download.oracle.com/java/21/archive/jdk-21.0.3_linux-aarch64_bin.tar.gz"
PACKAGE_TYPE="tar.gz"
elif [[ "$DISTRO" == "centos" || "$DISTRO" == "fedora" || "$DISTRO" == "rhel" ]]; then
URL="https://download.oracle.com/java/21/archive/jdk-21.0.3_linux-aarch64_bin.rpm"
PACKAGE_TYPE="rpm"
else
echo -e "${RED}[${WHITE}--${RED}]${CYAN} Unsupported distribution for aarch64: $DISTRO"
exit 1
fi
fi
# Download JDK
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Downloading JDK from $URL..."${WHITE}
download "$URL" "jdk-download"
# Install JDK
if [[ "$PACKAGE_TYPE" == "deb" ]]; then
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Installing .deb package..."${WHITE}
sudo dpkg -i jdk-download
elif [[ "$PACKAGE_TYPE" == "rpm" ]]; then
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Installing .rpm package..."${WHITE}
sudo rpm -ivh jdk-download
elif [[ "$PACKAGE_TYPE" == "tar.gz" ]]; then
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Extracting .tar.gz file..."${WHITE}
tar -xzf jdk-download
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Moving to /opt..."${WHITE}
sudo mv jdk-21.0.3 /opt/
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Setting up environment variables..."${WHITE}
echo "export JAVA_HOME=/opt/jdk-21.0.3" | sudo tee -a /etc/profile.d/jdk.sh
echo "export PATH=\$PATH:\$JAVA_HOME/bin" | sudo tee -a /etc/profile.d/jdk.sh
source /etc/profile.d/jdk.sh
fi
# Clean up
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Cleaning up..."${WHITE}
rm -f jdk-download
# Verify installation
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Verifying installation..."${WHITE}
java -version
echo -e "${GREEN}[${WHITE}+${GREEN}]${CYAN} Java installed successfully!"
}
install_make() {
sudo apt install build-essential -y
sudo apt install gcc -y
sudo apt install make -y
}
sudo apt install python3
sudo apt install python3-pip
sudo apt install curl
install_make
install_java
install_cloudflared
bash ./start.sh