-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathmenu.sh
More file actions
136 lines (116 loc) · 4.24 KB
/
menu.sh
File metadata and controls
136 lines (116 loc) · 4.24 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
#!/bin/bash
# ═══════════════════════════════════════════════════════════
# CandyConnect - Management Menu
# ═══════════════════════════════════════════════════════════
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
CC_DIR="/opt/candyconnect"
CC_SERVICE="candyconnect"
# ── Helpers ──
clear_screen() {
clear
}
banner() {
echo -e "${BOLD}${CYAN}"
echo " ╔═══════════════════════════════════╗"
echo " ║ 🍬 CandyConnect VPN 🍬 ║"
echo " ║ Management Menu ║"
echo " ╚═══════════════════════════════════╝"
echo -e "${NC}"
}
check_install_status() {
if [ -d "$CC_DIR" ] && systemctl list-unit-files | grep -q "^$CC_SERVICE.service"; then
echo -e "Status: ${GREEN}${BOLD}INSTALLED${NC}"
return 0
else
echo -e "Status: ${RED}${BOLD}NOT INSTALLED${NC}"
return 1
fi
}
show_menu() {
banner
check_install_status
echo ""
echo -e " ${BOLD}1.${NC} ${CYAN}Install CandyConnect${NC}"
echo -e " ${BOLD}2.${NC} ${RED}Uninstall CandyConnect${NC}"
echo -e " ${BOLD}3.${NC} Exit"
echo ""
echo -n "Choose an option [1-3]: "
}
# ── Functions ──
install_cc() {
if [ -f "./install.sh" ]; then
chmod +x ./install.sh
./install.sh
else
echo -e "${RED}[✗] Error: install.sh not found in current directory.${NC}"
fi
}
uninstall_cc() {
echo -e "${YELLOW}[!] Warning: This will completely remove CandyConnect, its configs, and all data.${NC}"
read -p "Are you sure you want to proceed? (y/n): " confirm
if [[ "$confirm" == "y" || "$confirm" == "Y" ]]; then
echo -e "${CYAN}[i] Stopping and disabling service...${NC}"
systemctl stop "$CC_SERVICE" 2>/dev/null
systemctl disable "$CC_SERVICE" 2>/dev/null
echo -e "${CYAN}[i] Stopping active VPN sessions...${NC}"
systemctl stop "wg-quick@*" 2>/dev/null
systemctl stop "openvpn-server@*" 2>/dev/null
systemctl stop "strongswan-starter" 2>/dev/null
systemctl stop "xl2tpd" 2>/dev/null
# Force kill any lingering processes
pkill -f "dnstt-server" || true
pkill -f "xray" || true
echo -e "${CYAN}[i] Removing service files...${NC}"
rm -f "/etc/systemd/system/$CC_SERVICE.service"
systemctl daemon-reload
echo -e "${CYAN}[i] Removing installation directory...${NC}"
rm -rf "$CC_DIR"
echo -e "${CYAN}[i] Removing protocol binaries...${NC}"
rm -f "/usr/local/bin/dnstt-server"
rm -f "/usr/local/bin/xray"
read -p "Do you also want to remove installed packages (wireguard, openvpn, strongswan, etc)? (y/n): " remove_pkgs
if [[ "$remove_pkgs" == "y" || "$remove_pkgs" == "Y" ]]; then
echo -e "${CYAN}[i] Removing installed packages...${NC}"
apt remove -y wireguard wireguard-tools openvpn easy-rsa strongswan strongswan-pki xl2tpd dante-server redis-server nodejs
apt autoremove -y
fi
echo -e "${GREEN}[✓] CandyConnect has been completely uninstalled.${NC}"
else
echo -e "${CYAN}[i] Uninstall cancelled.${NC}"
fi
}
# ── Main ──
if [ "$(id -u)" -ne 0 ]; then
echo -e "${RED}[✗] This script must be run as root (use sudo)${NC}"
exit 1
fi
while true; do
clear_screen
show_menu
read choice
case $choice in
1)
install_cc
echo -e "\nPress enter to return to menu..."
read
;;
2)
uninstall_cc
echo -e "\nPress enter to return to menu..."
read
;;
3)
echo -e "${CYAN}Goodbye!${NC}"
exit 0
;;
*)
echo -e "${RED}Invalid option.${NC}"
sleep 1
;;
esac
done