Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
482 lines (451 loc) · 22.3 KB
/
Copy pathsetup.sh
File metadata and controls
482 lines (451 loc) · 22.3 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
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
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
#!/bin/bash
# Copyright (c) 2026 Eng. Abdelrahman Rabie. All rights reserved.
# ==========================================================
# AutoVPN-Pro - setup.sh
# Main installer. Run as root on a fresh VPS:
# git clone https://github.com/PacketBreaker/AutoVPN-Pro.git
# cd AutoVPN-Pro && chmod +x setup.sh && ./setup.sh
#
# Design rules learned from real installs:
# - every module runs through run_module(): a failed module warns
# and the install CONTINUES; the menu is always installed.
# - installer logs go to stderr; setup_domain() prints ONLY the
# domain on stdout, so it can never corrupt a config value.
# - service config files are installed 644 (services running as
# DynamicUser cannot read 600 files).
# - any `read` under `set -e` must end with `|| true`.
# - v2.38 resume: run_module() records each module DONE/FAILED in
# /etc/vpn/install-state (see install/common.sh). Re-running
# ./setup.sh skips DONE steps and retries the rest; use
# ./setup.sh --force (or --reinstall) to start over from scratch.
# ==========================================================
set -u
# NOTE: no `set -e` here on purpose — run_module() handles failures.
# Never let a package prompt hang the install: iptables-persistent
# (and others) ask via debconf, and a hung prompt looks exactly like
# a stuck install. v2.41: the Base packages step stalled for minutes
# on a fresh Hostinger install with no visible progress.
export DEBIAN_FRONTEND=noninteractive
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR" || exit 1
source "$SCRIPT_DIR/install/common.sh"
source "$SCRIPT_DIR/theme.sh"
# ---------- resume / --force (v2.38) ----------
# --force / --reinstall ignores the install state file and runs
# every module again. Unknown arguments warn and the install still
# resumes — it never aborts on a typo here.
INSTALL_RESUME=1
INSTALL_FORCE=0
while [[ $# -gt 0 ]]; do
case "$1" in
--force|--reinstall)
INSTALL_FORCE=1
INSTALL_RESUME=0
# v2.47: --force never reset the install-state file, so a
# "fresh" run still skipped DONE modules. Remove it.
rm -f "$INSTALL_STATE_FILE" 2>/dev/null || true
shift
;;
--help|-h)
echo "Usage: ./setup.sh [--force|--reinstall]"
echo " (no argument) Resume a previous install: completed steps"
echo " are skipped, failed / missing steps run."
echo " --force Ignore the install state and run every"
echo " module again from scratch."
exit 0
;;
*)
warn "Unknown argument '$1' (only --force / --reinstall are supported); continuing in resume mode."
shift
;;
esac
done
# Never let a dpkg conffile prompt hang the install either: when a
# package ships a config the script already rewrote (e.g. the
# haproxy.cfg the HAProxy module generates), dpkg asks which version
# to keep — with stdin from /dev/null the answer is EOF and the
# install aborts. Force dpkg to keep the installed (script-managed)
# version without asking. (v2.43: this blocked the Web UI
# dependencies install on a fresh Hostinger run, after the HAProxy
# module had rewritten haproxy.cfg.)
mkdir -p /etc/apt/apt.conf.d
cat > /etc/apt/apt.conf.d/99-autovpn-pro <<'APTEOF'
Dpkg::Options {
"--force-confdef";
"--force-confold";
};
APTEOF
# Append a run header instead of truncating: on a resumed run the
# previous run's log still holds the failure that made the user
# re-run, and wiping it destroyed the only evidence. run_with_progress
# appends each step's full output below this header.
{ printf '\n===== AutoVPN-Pro setup run %s =====\n' "$(date -u +%FT%TZ)"; } >> /root/log-install.txt 2>/dev/null || true
start_time=$(date +%s)
# ---------- root check ----------
if [[ "${EUID}" -ne 0 ]]; then
err "This script must be run as root."
exit 1
fi
# ---------- virtualization check ----------
if [[ "$(systemd-detect-virt 2>/dev/null)" == "openvz" ]]; then
err "OpenVZ is not supported. Use KVM/VMware."
exit 1
fi
clear
theme_banner "INSTALLATION"
echo ""
step "AutoVPN-Pro installer starting."
step "Repository: $REPO_URL"
# ---------- resume banner (v2.38) ----------
# Shown up front so the user knows immediately whether this run is
# resuming or starting over — not halfway through the module list.
if [[ "$INSTALL_FORCE" == "1" ]]; then
step "Full reinstall requested (--force): ignoring previous install state, every module will run again."
elif [[ -f "$INSTALL_STATE_FILE" ]]; then
RESUMED_DONE="$(install_state_count_done)"
if (( RESUMED_DONE > 0 )); then
echo ""
echo " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo " Previous install found — resuming, skipping $RESUMED_DONE completed step(s)."
echo " Steps that failed or never ran will run now."
echo " To start over from scratch instead: ./setup.sh --force"
echo " ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
fi
fi
# ---------- server detection (architecture + cloud) ----------
# Detect the CPU architecture and the cloud provider up front, so the
# installer picks the right binaries for this machine and warns about
# the right firewall. On ARM (e.g. Oracle Ampere) the amd64 binaries
# cannot run at all, so the choice is printed clearly here instead of
# failing silently in a module later.
ARCH="$(detect_arch)"
CLOUD="$(detect_cloud)"
step "Detected architecture: $(uname -m) ($ARCH)."
if [[ "$ARCH" == "arm64" ]]; then
step "ARM64 server — using arm64 builds (Xray/ZiVPN arm64, Dropbear from apt, UDP Custom third-party arm64, BadVPN built from source)."
elif [[ "$ARCH" == "armv7" ]]; then
step "ARMv7 server — using armv7 builds where available."
else
step "x86_64 server — using amd64 builds."
fi
if [[ "$CLOUD" == "oracle" ]]; then
step "Detected cloud: Oracle Cloud (OCI)."
fi
# ---------- firewall / ports warning ----------
# Shown before the install starts (and again at the end): a closed
# cloud firewall is the #1 reason a fresh install "does not work".
print_ports_warning
# ---------- /etc/hosts fix ----------
localip=$(hostname -I 2>/dev/null | awk '{print $1}')
hostname_now=$(hostname)
# v2.52: only add the line when hostname -I actually returned an
# address — an empty $localip wrote a malformed " hostname" line.
if [[ -n "$localip" ]] && ! grep -qw "$hostname_now" /etc/hosts 2>/dev/null; then
printf '%s %s\n' "$localip" "$hostname_now" >> /etc/hosts
fi
# ---------- directories ----------
mkdir -p /etc/xray /etc/v2ray /etc/vpn/users /var/lib /etc/autoscriptvpn/cache
for f in domain scdomain; do
touch "/etc/xray/$f" "/etc/v2ray/$f" "/root/$f" 2>/dev/null || true
done
touch /var/lib/ipvps.conf
# ---------- timezone (UTC, neutral default) ----------
ln -fs /usr/share/zoneinfo/UTC /etc/localtime 2>/dev/null || true
# ---------- base dependencies ----------
# This used to run with all output to /dev/null, so the screen sat on
# a frozen "Installing base dependencies..." line for 2-5 minutes and
# looked stuck (it fooled a real install). run_with_progress streams
# the command's real output live (v2.41 — the braille spinner it used
# before rendered as a garbled wall of "Base packages —" lines on the
# user's phone terminal and hid the real progress); the full apt output
# is kept in /root/log-install.txt.
# v2.38: resumable — once the base packages install cleanly the step
# is recorded DONE in the install state and a later run skips both
# apt calls. A failed run is recorded FAILED and retried next time.
if install_state_is_done base-packages; then
step "Base packages already installed — skipping (resume)."
else
run_with_progress "Updating package lists" apt update -y \
|| warn "apt update failed; continuing."
if run_with_progress "Base packages" apt install -y curl wget git screen unzip bzip2 gzip coreutils python3 \
python3-pip iptables iptables-persistent netfilter-persistent vnstat \
openssl jq socat cron lsof gnupg ca-certificates qrencode \
resolvconf; then
install_state_set base-packages DONE
else
warn "Some base packages failed to install."
install_state_set base-packages FAILED
fi
fi
# ---------- domain ----------
# v2.38: resumable where safe. setup_domain() / setup_slowdns_domain()
# already reuse a saved value instead of asking again, but calling
# them unconditionally still rewrote the files and re-prompted when
# a value was missing. Now they run only when the value is actually
# missing: /etc/xray/domain for the main domain, NS_DOMAIN in
# /etc/vpn/slowdns.conf for the SlowDNS NS domain. A saved value is
# reused as-is and printed, with no prompt.
clear
theme_banner "DOMAIN SETUP"
echo ""
domain="$(cat /etc/xray/domain 2>/dev/null | tr -d '[:space:]')"
# v2.52: a saved domain was trusted as-is — a stale/corrupt value
# (e.g. a typo from an old install) broke every later step. Validate
# it; when invalid, drop the saved value and fall through to
# setup_domain(), which prompts (or reuses a valid /root/domain).
if [[ -n "$domain" ]] && ! valid_domain "$domain"; then
warn "Saved domain '$domain' in /etc/xray/domain is not a valid domain — ignoring it."
rm -f /etc/xray/domain /root/domain
domain=""
fi
if [[ -z "$domain" ]]; then
domain="$(setup_domain)" || { err "No valid domain — aborting the install."; exit 1; }
else
step "Using saved domain: $domain"
fi
step "Domain set: $domain"
echo ""
ns_domain="$(grep -oP '^NS_DOMAIN="\K[^"]+' /etc/vpn/slowdns.conf 2>/dev/null || true)"
if [[ -z "$ns_domain" ]]; then
ns_domain="$(setup_slowdns_domain)"
else
step "Using saved SlowDNS NS domain: $ns_domain"
fi
step "SlowDNS NS domain set: $ns_domain"
step "Remember: add an NS record at your DNS provider: $ns_domain NS -> $domain"
sleep 1
# ---------- ask about Web UI and Telegram ----------
INSTALL_WEBUI="y"
INSTALL_TELEGRAM="y"
read -rp "Install the Web UI (login panel)? [Y/n]: " _ans || true
[[ "${_ans,,}" == "n" ]] && INSTALL_WEBUI="n"
read -rp "Install the Telegram bot (needs a bot token later)? [Y/n]: " _ans || true
[[ "${_ans,,}" == "n" ]] && INSTALL_TELEGRAM="n"
# ---------- run installer modules ----------
# Repo checkouts lose the exec bit: make every module executable first,
# otherwise run_module() would skip them all as "not found" (this left a
# real install with a menu but zero services installed).
# v2.47: --force on a live HAProxy-enabled server cascades — HAProxy
# holds public 80/443 while nginx.sh recreates default.conf on :80
# and xray.sh needs nginx on :80 for the ACME webroot. Stop and
# disable the front door first and move nginx back to the public
# ports; the HAProxy module at the end of the list re-enables it.
if [[ "$INSTALL_FORCE" == "1" ]]; then
systemctl stop haproxy 2>/dev/null || true
systemctl disable haproxy 2>/dev/null || true
if [[ -f /etc/nginx/conf.d/xray.conf ]]; then
sed -i 's/listen 127.0.0.1:10080;/listen 80;/; s/listen \[::1\]:10080;/listen [::]:80;/; s/listen 127.0.0.1:10443 ssl http2;/listen 443 ssl http2;/; s/listen \[::1\]:10443 ssl http2;/listen [::]:443 ssl http2;/' /etc/nginx/conf.d/xray.conf
nginx -t >/dev/null 2>&1 && systemctl reload nginx 2>/dev/null || true
fi
fi
chmod +x "$SCRIPT_DIR"/install/*.sh 2>/dev/null || true
# Total module count for the numbered progress headers. Web UI and
# Telegram are optional, so count only the ones actually enabled.
# 20 base modules (the 19 below HAProxy plus Account Limits at the
# end) + 1 each for Web UI / Telegram when enabled.
MODULE_TOTAL=20
[[ "$INSTALL_WEBUI" == "y" ]] && MODULE_TOTAL=$(( MODULE_TOTAL + 1 ))
[[ "$INSTALL_TELEGRAM" == "y" ]] && MODULE_TOTAL=$(( MODULE_TOTAL + 1 ))
run_module "NGINX Reverse Proxy" "$SCRIPT_DIR/install/nginx.sh"
run_module "Xray Core + SSL" "$SCRIPT_DIR/install/xray.sh"
run_module "VLESS Reality (TCP 8443)" "$SCRIPT_DIR/install/reality.sh"
run_module "SSH + WebSocket" "$SCRIPT_DIR/install/ssh.sh"
run_module "stunnel (raw SSH over TLS)" "$SCRIPT_DIR/install/stunnel.sh"
run_module "WireGuard" "$SCRIPT_DIR/install/wg.sh"
run_module "UDP ZiVPN" "$SCRIPT_DIR/install/zivpn.sh"
run_module "OpenVPN" "$SCRIPT_DIR/install/openvpn.sh"
run_module "SlowDNS (DNSTT)" "$SCRIPT_DIR/install/slowdns.sh"
run_module "DNS Boost (parallel DNSTT + V2Ray)" "$SCRIPT_DIR/install/dnsboost.sh"
run_module "Slipstream (QUIC over DNS)" "$SCRIPT_DIR/install/slipstream.sh"
run_module "Hysteria2 (QUIC/UDP)" "$SCRIPT_DIR/install/hysteria.sh"
run_module "AnyTLS (sing-box)" "$SCRIPT_DIR/install/anytls.sh"
run_module "Juicity (QUIC/UDP)" "$SCRIPT_DIR/install/juicity.sh"
run_module "Mieru (obfuscated)" "$SCRIPT_DIR/install/mieru.sh"
run_module "TUIC (sing-box)" "$SCRIPT_DIR/install/tuic.sh"
run_module "IKEv2/IPsec (StrongSwan)" "$SCRIPT_DIR/install/ikev2.sh"
run_module "mKCP + XHTTP-H3 ports" "$SCRIPT_DIR/install/mkcp-xhttp.sh"
run_module "HAProxy" "$SCRIPT_DIR/install/haproxy.sh"
if [[ "$INSTALL_WEBUI" == "y" ]]; then
run_module "Web UI" "$SCRIPT_DIR/install/webui.sh"
fi
if [[ "$INSTALL_TELEGRAM" == "y" ]]; then
run_module "Telegram Bot" "$SCRIPT_DIR/install/telegram.sh"
fi
run_module "Account Limits" "$SCRIPT_DIR/install/limits.sh"
# ---------- install menu, sub-menus, tools (ALWAYS, even on failures) ----------
step "Installing the menu and tools..."
mkdir -p /etc/autoscriptvpn/{ssh,xray,wg,udp,openvpn,tools,webui,hysteria,anytls,juicity,mieru,tuic,ikev2,dnsboost,reality,slipstream}
cp -f "$SCRIPT_DIR/theme.sh" /etc/autoscriptvpn/theme.sh
cp -f "$SCRIPT_DIR/lib.sh" /etc/autoscriptvpn/lib.sh
cp -f "$SCRIPT_DIR/menu.sh" /etc/autoscriptvpn/menu.sh
cp -f "$SCRIPT_DIR/uninstall.sh" /etc/autoscriptvpn/uninstall.sh
cp -f "$SCRIPT_DIR/VERSION" /etc/autoscriptvpn/VERSION 2>/dev/null || true
cp -rf "$SCRIPT_DIR/ssh/"* /etc/autoscriptvpn/ssh/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/xray/"* /etc/autoscriptvpn/xray/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/wg/"* /etc/autoscriptvpn/wg/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/udp/"* /etc/autoscriptvpn/udp/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/openvpn/"* /etc/autoscriptvpn/openvpn/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/hysteria/"* /etc/autoscriptvpn/hysteria/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/anytls/"* /etc/autoscriptvpn/anytls/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/juicity/"* /etc/autoscriptvpn/juicity/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/mieru/"* /etc/autoscriptvpn/mieru/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/tuic/"* /etc/autoscriptvpn/tuic/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/ikev2/"* /etc/autoscriptvpn/ikev2/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/dnsboost/"* /etc/autoscriptvpn/dnsboost/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/reality/"* /etc/autoscriptvpn/reality/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/slipstream/"* /etc/autoscriptvpn/slipstream/ 2>/dev/null || true
cp -rf "$SCRIPT_DIR/tools/"* /etc/autoscriptvpn/tools/ 2>/dev/null || true
if [[ -d "$SCRIPT_DIR/install" ]]; then
mkdir -p /etc/autoscriptvpn/install
cp -rf "$SCRIPT_DIR/install/"* /etc/autoscriptvpn/install/ 2>/dev/null || true
fi
if [[ -d "$SCRIPT_DIR/webui" ]]; then
cp -rf "$SCRIPT_DIR/webui/"* /etc/autoscriptvpn/webui/ 2>/dev/null || true
fi
# Repo checkouts lose the exec bit — make sure every installed tool is
# executable, otherwise the menu reports "not found" for it. This must
# cover the extensionless submenu scripts (m-ssh, m-zivpn, ...) too, not
# just *.sh: a copy that only took *.sh left every submenu missing and
# option 7 closed the whole SSH session (menu.sh runs `exec menu`).
chmod 755 /etc/autoscriptvpn/ssh/*.sh /etc/autoscriptvpn/xray/*.sh \
/etc/autoscriptvpn/wg/*.sh /etc/autoscriptvpn/udp/*.sh \
/etc/autoscriptvpn/openvpn/*.sh \
/etc/autoscriptvpn/hysteria/*.sh /etc/autoscriptvpn/anytls/*.sh \
/etc/autoscriptvpn/juicity/*.sh /etc/autoscriptvpn/mieru/*.sh \
/etc/autoscriptvpn/tuic/*.sh /etc/autoscriptvpn/ikev2/*.sh \
/etc/autoscriptvpn/dnsboost/*.sh /etc/autoscriptvpn/reality/*.sh /etc/autoscriptvpn/slipstream/*.sh \
/etc/autoscriptvpn/tools/*.sh /etc/autoscriptvpn/uninstall.sh \
/etc/autoscriptvpn/ssh/m-ssh /etc/autoscriptvpn/xray/m-vmess \
/etc/autoscriptvpn/xray/m-vless /etc/autoscriptvpn/xray/m-trojan \
/etc/autoscriptvpn/xray/m-ssws /etc/autoscriptvpn/wg/m-wg \
/etc/autoscriptvpn/udp/m-zivpn /etc/autoscriptvpn/openvpn/m-openvpn /etc/autoscriptvpn/hysteria/m-hysteria \
/etc/autoscriptvpn/anytls/m-anytls /etc/autoscriptvpn/juicity/m-juicity \
/etc/autoscriptvpn/mieru/m-mieru /etc/autoscriptvpn/tuic/m-tuic \
/etc/autoscriptvpn/ikev2/m-ikev2 /etc/autoscriptvpn/dnsboost/m-dnsboost \
/etc/autoscriptvpn/reality/m-reality /etc/autoscriptvpn/slipstream/m-slipstream \
/etc/autoscriptvpn/tools/tools-menu \
2>/dev/null || true
chmod 644 /etc/autoscriptvpn/theme.sh /etc/autoscriptvpn/lib.sh
# Menu entry points. These are SYMLINKS to /etc/autoscriptvpn/menu.sh,
# not copies: a copy goes stale the moment the installed menu is
# updated (that left /usr/bin/menu on the old layout while the
# installed menu was already fixed — a real bug found 2026-11-30).
# A symlink always runs the current installed menu.
ln -sf /etc/autoscriptvpn/menu.sh /usr/bin/menu
ln -sf /etc/autoscriptvpn/menu.sh /usr/local/bin/vpn
chmod 755 /etc/autoscriptvpn/menu.sh 2>/dev/null || true
for m in m-ssh m-vmess m-vless m-trojan m-ssws m-wg m-zivpn m-openvpn m-hysteria m-anytls m-juicity m-mieru m-tuic m-ikev2 m-dnsboost m-reality m-slipstream tools-menu; do
src=""
for d in ssh xray wg udp openvpn hysteria anytls juicity mieru tuic ikev2 dnsboost reality slipstream tools; do
[[ -f "$SCRIPT_DIR/$d/$m" ]] && src="$SCRIPT_DIR/$d/$m"
done
[[ -n "$src" ]] && install -m 755 "$src" "/usr/bin/$m"
done
for t in backup.sh speedtest.sh domain.sh running.sh list-users.sh online.sh; do
[[ -f "$SCRIPT_DIR/tools/$t" ]] && install -m 755 "$SCRIPT_DIR/tools/$t" "/usr/bin/$t"
done
# Verify the copyright line survived in every installed file.
for f in /etc/autoscriptvpn/theme.sh /etc/autoscriptvpn/lib.sh \
/etc/autoscriptvpn/menu.sh /etc/autoscriptvpn/uninstall.sh; do
verify_copyright "$f"
done
# ---------- install marker ----------
mkdir -p /etc/vpn
printf 'AutoVPN-Pro installed %s\n' "$(date -u +%F)" > /etc/vpn/.autovpn-installed
# ---------- auto menu on root login ----------
# v2.48: back up an existing .profile first — the old blind overwrite
# destroyed the user's own login customisations on a re-install.
[[ -f /root/.profile ]] && cp -f /root/.profile "/root/.profile.autovpn-backup-$(date +%Y%m%d-%H%M%S)" 2>/dev/null || true
cat > /root/.profile <<'EOF'
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
clear
menu
EOF
chmod 644 /root/.profile
# ---------- finish ----------
end_time=$(date +%s)
elapsed=$(( end_time - start_time ))
clear
theme_banner "INSTALLATION DONE"
echo ""
echo " Services (live status — checked just now):"
print_svc() { # print_svc UNIT LABEL — live ✔ ACTIVE / ✗ OFFLINE
local unit="$1" label="$2"
if systemctl is-active --quiet "$unit" 2>/dev/null; then
printf ' %-44s \033[1;38;5;48m✔ ACTIVE\033[0m\n' "$label"
else
printf ' %-44s \033[1;38;5;203m✗ OFFLINE\033[0m\n' "$label"
fi
}
# Mieru: `mita status` is the truth — same check menu.sh uses, since
# the mita systemd state alone can mislead. Falls back to the
# systemctl check when `mita status` says nothing.
print_svc_mieru() {
if mita status 2>/dev/null | grep -qi "RUNNING"; then
printf ' %-44s \033[1;38;5;48m✔ ACTIVE\033[0m\n' "Mieru (obfuscated)"
else
print_svc mita "Mieru (obfuscated)"
fi
}
print_svc xray "Xray (VMess/VLESS/Trojan/Shadowsocks)"
print_svc nginx "Nginx"
print_svc dropbear "Dropbear (SSH)"
print_svc dropbear-ws "SSH WS (Dropbear WebSocket)"
print_svc stunnel-ws "SSH WSS (Stunnel WebSocket)"
print_svc stunnel4 "stunnel (raw SSH over TLS)"
print_svc haproxy "HAProxy (front door)"
print_svc wg-quick@wg0 "WireGuard"
print_svc openvpn-server@server "OpenVPN"
print_svc zivpn "UDP ZiVPN"
print_svc udp-custom "UDP Custom"
print_svc udpgw "BadVPN UDPGW"
print_svc slowdns "SlowDNS (DNSTT)"
print_svc slowdns2 "SlowDNS 2 (DNSTT v2dns, DNS Boost)"
print_svc dns-router "DNS Boost router (UDP 5300)"
print_svc slipstream "Slipstream (QUIC over DNS)"
print_svc hysteria-server "Hysteria2 (QUIC/UDP 443)"
print_svc sing-box "AnyTLS (sing-box, TCP 443)"
print_svc juicity-server "Juicity (QUIC/UDP 8443)"
print_svc_mieru
print_svc sing-box "TUIC (shares sing-box with AnyTLS)"
print_svc strongswan-starter "IKEv2/IPsec (StrongSwan)"
# No systemd unit of their own: VLESS Reality, mKCP and XHTTP-H3 are
# inbounds inside Xray, so their line mirrors Xray's live state and
# says so — a separate check would be inventing a service.
print_svc xray "VLESS Reality (in Xray, TCP 8443)"
print_svc xray "mKCP + XHTTP-H3 (in Xray)"
# Web UI / Telegram used to print just "y"/"n" — "y" even when the
# service had failed to start. Now they show the live service state
# when installed, and "not installed" when skipped.
if [[ "$INSTALL_WEBUI" == "y" ]]; then
print_svc autovpn-webui "Web UI (Flask panel)"
else
printf ' %-44s %s\n' "Web UI (Flask panel)" "not installed"
fi
if [[ "$INSTALL_TELEGRAM" == "y" ]]; then
print_svc autovpn-telegram "Telegram Bot"
else
printf ' %-44s %s\n' "Telegram Bot" "not installed"
fi
echo ""
echo -e " Installation time : $(( elapsed / 60 )) minutes $(( elapsed % 60 )) seconds"
echo ""
print_ports_warning
if [[ ${#FAILED_MODULES[@]} -gt 0 ]]; then
warn "These modules failed (the menu was still installed):"
for m in "${FAILED_MODULES[@]}"; do echo " - $m"; done
echo "Re-run the matching install/<module>.sh script to retry one."
echo "Or just re-run ./setup.sh — it resumes and retries only the failed steps."
echo ""
fi
theme_footer
echo ""
echo -e "Open the menu any time with: menu (or: vpn)"
echo -e "Web UI (if installed): https://<your-domain>/panel/"
echo -e "A reboot is recommended: reboot"
echo ""