-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathuninstall.sh
More file actions
154 lines (118 loc) · 4.38 KB
/
uninstall.sh
File metadata and controls
154 lines (118 loc) · 4.38 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
#!/bin/bash
green="\033[0;32m"
red="\033[0;31m"
yellow="\033[1;33m"
blue="\033[0;34m"
nc="\033[0m"
log_info() { echo -e "${blue}[ Info ]${nc} $1"; }
log_success() { echo -e "${green}[ Success ]${nc} $1"; }
log_error() { echo -e "${red}[ Error ]${nc} $1"; }
log_warning() { echo -e "${yellow}[ Warning ]${nc} $1"; }
if [ "$(id -u)" -ne 0 ]; then
log_error "Run as root."
exit 1
fi
clear
echo "-----------------------------"
echo " Uninstalling AutoScriptX "
echo "-----------------------------"
log_info "Stopping and disabling services..."
# Stop and disable all AutoScriptX services
services=(
dropbear
ws-proxy.service
nginx
stunnel4
sshguard
squid
)
for service in "${services[@]}"; do
log_info "Stopping $service..."
systemctl disable --now "$service" > /dev/null 2>&1 || log_warning "Failed to stop $service"
done
# Stop BadVPN services
for port in 7200 7300; do
log_info "Stopping badvpn-udpgw@$port.service..."
systemctl disable --now badvpn-udpgw@"$port".service > /dev/null 2>&1 || log_warning "Failed to stop badvpn-udpgw@$port.service"
done
# Kill any remaining processes
pkill -f badvpn-udpgw > /dev/null 2>&1 || true
pkill -f ws-proxy > /dev/null 2>&1 || true
log_info "Removing installed files and configurations..."
# Remove main AutoScriptX directory
rm -rf /etc/AutoScriptX
# Remove SSL certificates and acme.sh
rm -rf /root/.acme.sh
# Remove stunnel configuration and certificates
rm -f /etc/stunnel/stunnel.{conf,pem} /etc/stunnel/{key.pem,cert.pem}
# Remove dropbear configuration
rm -f /etc/default/dropbear
sed -i '/AutoScriptX\/banner/d' /etc/default/dropbear 2>/dev/null
# Remove systemd service files
rm -f /etc/systemd/system/ws-proxy.service
rm -f /etc/systemd/system/badvpn-udpgw@.service
# Remove binaries
rm -f /usr/local/bin/ws-proxy /usr/bin/badvpn-udpgw /usr/local/bin/gum
# Remove nginx configurations
rm -f /etc/nginx/nginx.conf /etc/nginx/conf.d/{reverse-proxy.conf,real_ip_sources.conf}
rm -f /etc/nginx/sites-available/default /etc/nginx/sites-enabled/default /etc/nginx/conf.d/default.conf
rm -rf /home/vps/public_html
# Remove squid configuration
rm -f /etc/squid/squid.conf
# Remove cron jobs
rm -f /etc/cron.d/auto-reboot /etc/cron.d/clean-expired-accounts
# Remove scripts
for cmd in autoscriptx asx menu create-account delete-account edit-banner edit-response \
lock-unlock renew-account change-domain manage-services system-info clean-expired-accounts; do
rm -f /usr/bin/$cmd
done
log_info "Cleaning up system modifications..."
# Clean up /etc/shells modifications
sed -i '/\/bin\/false/d;/\/usr\/sbin\/nologin/d' /etc/shells
# Re-enable IPv6 (reverse the installer's IPv6 disable)
rm -f /etc/sysctl.d/99-disable-ipv6.conf
echo "net.ipv6.conf.all.disable_ipv6 = 0" > /etc/sysctl.d/99-enable-ipv6.conf
echo "net.ipv6.conf.default.disable_ipv6 = 0" >> /etc/sysctl.d/99-enable-ipv6.conf
sysctl --system > /dev/null 2>&1 || log_warning "Failed to reload sysctl settings"
# Clean up /etc/profile modifications (remove HISTFILE unset)
sed -i '/unset HISTFILE/d' /etc/profile
# Reset iptables rules
log_info "Resetting firewall rules..."
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X
iptables -t mangle -F
iptables -t mangle -X
# Set default policies to ACCEPT (reverse restrictive rules)
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# Save the cleaned rules
netfilter-persistent save > /dev/null 2>&1
netfilter-persistent reload > /dev/null 2>&1
# Clean up iptables files
rm -f /etc/iptables.up.rules
log_info "Removing installed packages..."
# Remove packages that were specifically installed by AutoScriptX
# Note: Being conservative here - only removing packages that are primarily for AutoScriptX
packages_to_remove=(
stunnel4
dropbear
squid
sshguard
)
for package in "${packages_to_remove[@]}"; do
log_info "Removing package: $package"
apt purge -y "$package" > /dev/null 2>&1 || log_warning "Failed to remove $package"
done
# Clean up package dependencies
apt autoremove -y > /dev/null 2>&1
apt autoclean -y > /dev/null 2>&1
log_info "Reloading systemd daemon..."
systemctl daemon-reload > /dev/null 2>&1
log_info "Restarting remaining services..."
# Restart cron to reload without AutoScriptX jobs
service cron restart > /dev/null 2>&1 || log_warning "Failed to restart cron"
log_success "AutoScriptX uninstalled successfully."
log_info "System has been restored to its previous state."