Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
312 lines (226 loc) · 6.15 KB
/
Copy pathsetup.sh
File metadata and controls
312 lines (226 loc) · 6.15 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
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
#!/bin/bash
# ==========================================
# Setup Script XRAY_AIO
# Developed by Eng.Abdelrahman Rabie
# XRAY + WireGuard + UDP ZIVPN
# ==========================================
echo "" > /root/log-install.txt
cd "$(dirname "$0")"
source ./theme.sh
clear
# ==========================================
# COLOR
# ==========================================
red='\e[1;38;5;203m'
green='\e[0;38;5;48m'
yellow='\e[1;38;5;220m'
blue='\e[1;38;5;99m'
cyan='\e[1;38;5;51m'
NC='\e[0m'
# ==========================================
# FUNCTION
# ==========================================
function info() {
echo -e "${green}[INFO]${NC} $1"
}
function warn() {
echo -e "${yellow}[WARNING]${NC} $1"
}
function error() {
echo -e "${red}[ERROR]${NC} $1"
}
# ==========================================
# TIMER
# ==========================================
start_time=$(date +%s)
# ==========================================
# CHECK ROOT
# ==========================================
if [ "${EUID}" -ne 0 ]; then
error "This script must be run as root."
exit 1
fi
# ==========================================
# CHECK VIRTUALIZATION
# ==========================================
if [ "$(systemd-detect-virt)" == "openvz" ]; then
error "OpenVZ is not supported. Use KVM/VMware."
exit 1
fi
# ==========================================
# FIX /etc/hosts
# ==========================================
localip=$(hostname -I | awk '{print $1}')
hostname=$(hostname)
domainline=$(grep -w "$hostname" /etc/hosts | awk '{print $2}')
if [[ "$hostname" != "$domainline" ]]; then
echo "$localip $hostname" >> /etc/hosts
fi
# ==========================================
# CREATE REQUIRED FOLDER
# ==========================================
mkdir -p /etc/xray
mkdir -p /etc/v2ray
mkdir -p /var/lib
for file in domain scdomain; do
touch /etc/xray/$file
touch /etc/v2ray/$file
touch /root/$file
done
touch /var/lib/ipvps.conf
# ==========================================
# SET TIMEZONE
# ==========================================
ln -fs /usr/share/zoneinfo/Asia/Jakarta /etc/localtime
# ==========================================
# UPDATE & INSTALL PACKAGE
# ==========================================
info "Installing dependencies..."
apt update -y
apt install -y \
curl \
wget \
git \
screen \
unzip \
bzip2 \
gzip \
coreutils \
python3 \
python3-pip \
iptables \
iptables-persistent \
netfilter-persistent \
vnstat \
openssl \
ufw >/dev/null 2>&1
# ==========================================
# INSTALL LINUX HEADER
# ==========================================
kernelver=$(uname -r)
headerpkg="linux-headers-$kernelver"
if ! dpkg -s $headerpkg >/dev/null 2>&1; then
info "Installing $headerpkg..."
apt install -y $headerpkg
fi
# ==========================================
# DOMAIN SETUP
# ==========================================
clear
theme_banner "DOMAIN SETUP"
echo ""
read -rp "$(echo -e "${GOLD}❯ Enter your domain : ${NC}")" domain
if [[ -z "$domain" ]]; then
error "Domain must not be empty!"
exit 1
fi
echo "$domain" > /root/domain
for dfile in domain scdomain; do
echo "$domain" > /etc/xray/$dfile
echo "$domain" > /etc/v2ray/$dfile
echo "$domain" > /root/$dfile
done
echo "IP=$domain" > /var/lib/ipvps.conf
echo ""
info "Domain set successfully: $domain"
sleep 2
# ==========================================
# RUN INSTALLER
# ==========================================
info "Installing NGINX Reverse Proxy..."
bash install/nginx.sh
info "Installing XRAY Core..."
bash install/xray.sh
info "Installing SSH Websocket..."
bash install/ssh.sh
info "Installing WireGuard..."
bash install/wg.sh
info "Installing UDP ZIVPN..."
bash install/zivpn.sh
# ==========================================
# COPY MENU COMMAND
# ==========================================
info "Copying menu commands..."
cp -f ssh/m-ssh /usr/bin/
cp -f xray/m-vmess /usr/bin/
cp -f xray/m-vless /usr/bin/
cp -f xray/m-trojan /usr/bin/
cp -f xray/m-ssws /usr/bin/
cp -f wg/m-wg /usr/bin/
cp -f udp/m-zivpn /usr/bin/
cp -f tools/tools-menu /usr/bin/
cp -f tools/backup.sh /usr/bin/
cp -f tools/speedtest.sh /usr/bin/
cp -f tools/domain.sh /usr/bin/
cp -f tools/running.sh /usr/bin/
cp -f menu.sh /usr/bin/menu
# ==========================================
# SET PERMISSION
# ==========================================
chmod +x /usr/bin/menu
chmod +x /usr/bin/m-ssh
chmod +x /usr/bin/m-vmess
chmod +x /usr/bin/m-vless
chmod +x /usr/bin/m-trojan
chmod +x /usr/bin/m-ssws
chmod +x /usr/bin/m-wg
chmod +x /usr/bin/m-zivpn
chmod +x /usr/bin/tools-menu
chmod +x /usr/bin/backup.sh
chmod +x /usr/bin/speedtest.sh
chmod +x /usr/bin/domain.sh
chmod +x /usr/bin/running.sh
chmod +x ssh/*.sh
chmod +x xray/*.sh
chmod +x wg/*.sh
chmod +x udp/*.sh
chmod +x tools/*.sh
# ==========================================
# COPY RUNTIME SCRIPT
# ==========================================
info "Copying all submenus to /etc/autoscriptvpn/..."
mkdir -p /etc/autoscriptvpn/{ssh,xray,wg,udp,tools}
cp -f theme.sh /etc/autoscriptvpn/theme.sh
chmod 644 /etc/autoscriptvpn/theme.sh
cp -r ssh/* /etc/autoscriptvpn/ssh/
cp -r xray/* /etc/autoscriptvpn/xray/
cp -r wg/* /etc/autoscriptvpn/wg/
cp -r udp/* /etc/autoscriptvpn/udp/
cp -r tools/* /etc/autoscriptvpn/tools/
chmod +x /etc/autoscriptvpn/*/*.sh
# ==========================================
# AUTO MENU LOGIN
# ==========================================
cat > /root/.profile <<-EOF
if [ "\$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
clear
menu
EOF
chmod 644 /root/.profile
# ==========================================
# CLEAN FILE
# ==========================================
rm -f cf
rm -f ins-xray.sh
# ==========================================
# FINISH
# ==========================================
end_time=$(date +%s)
elapsed=$((end_time - start_time))
clear
theme_banner "✔ INSTALLATION DONE ✔"
echo -e " SSH : INSTALLED"
echo -e " XRAY : INSTALLED"
echo -e " WireGuard : INSTALLED"
echo -e " UDP ZIVPN : INSTALLED"
echo ""
echo -e " Installation Time : $((elapsed / 60)) menit $((elapsed % 60)) detik"
theme_footer
echo ""
echo -e "${green}♻️ The VPS will reboot in 10 seconds...${NC}"
sleep 10
reboot