-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmenu.sh
240 lines (226 loc) · 7.05 KB
/
menu.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
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
#!/bin/bash
for script in /opt/Port-Shifter/scripts/*.sh; do
source "$script"
done
iptables_menu() {
while true; do
choice=$(whiptail --backtitle "Port-Shifter" --title "IP-Tables Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install IP-Tables Rules" \
"Status" "Check Ports In Use" \
"Uninstall" "Uninstall IP-Tables Rules" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
case $choice in
Install)
install_iptables
;;
Status)
check_port_iptables
;;
Uninstall)
uninstall_iptables
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
gost_menu() {
while true; do
choice=$(whiptail --backtitle "Port-Shifter" --title "GOST Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install GOST" \
"Status" "Check GOST Port And Status" \
"Add" "Add Another Port And Domain" \
"Remove" "Remove Port And Domain" \
"Uninstall" "Uninstall GOST" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
case $choice in
Install)
install_gost
;;
Status)
check_port_gost
;;
Add)
add_port_gost
;;
Remove)
remove_port_gost
;;
Uninstall)
uninstall_gost
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
dokodemo_menu() {
while true; do
choice=$(whiptail --backtitle "Port-Shifter" --title "Dokodemo-Door Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install Xray For Dokodemo-Door And Add Inbound" \
"Status" "Check Xray Service Status" \
"Traffic" "Inbound Traffic Statistics" \
"Add" "Add Another Inbound" \
"Remove" "Remove an Inbound Configuration" \
"Uninstall" "Uninstall Xray And Tunnel" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
case $choice in
Install)
install_xray
;;
Status)
check_service_xray
;;
Traffic)
trafficstat
;;
Add)
add_another_inbound
;;
Remove)
remove_inbound
;;
Uninstall)
uninstall_xray
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
haproxy_menu() {
while true; do
choice=$(whiptail --backtitle "Port-Shifter" --title "HA-Proxy Menu" --menu "Please choose one of the following options:" 20 60 10 \
"Install" "Install HA-Proxy" \
"Status" "Check HA-Proxy Port and Status" \
"Add" "Add more tunnel Configuration" \
"Remove" "Remove tunnel Configuration" \
"Uninstall" "Uninstall HAProxy" \
"Back" "Back To Main Menu" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
case $choice in
Install)
install_haproxy
;;
Status)
check_haproxy
;;
Add)
add_frontend_backend
;;
Remove)
remove_frontend_backend
;;
Uninstall)
uninstall_haproxy
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
function other_options_menu() {
while true; do
other_choice=$(whiptail --backtitle "Welcome to Port-Shifter" --title "Other Options" --menu "Please choose one of the following options:" 20 60 10 \
"DNS" "Configure DNS" \
"Update" "Update Server" \
"Ping" "Ping to check internet connectivity" \
"Back" "Return to Main Menu" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
case $other_choice in
DNS)
configure_dns
;;
Update)
update_server
;;
Ping)
ping_websites
;;
Back)
menu
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
;;
esac
else
exit 1
fi
done
}
function menu() {
while true; do
choice=$(whiptail --backtitle "Welcome to Port-Shifter" --title "Choose Your Tunnel Mode" --menu "Please choose one of the following options:" 20 60 10 \
"IP-Tables" "Manage IP-Tables Tunnel" \
"GOST" "Manage GOST Tunnel" \
"Dokodemo-Door" "Manage Dokodemo-Door Tunnel" \
"HA-Proxy" "Manage HA-Proxy Tunnel" \
"Options" "Additional Configuration Options" \
"Quit" "Exit From The Script" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
case $choice in
IP-Tables)
iptables_menu
;;
GOST)
gost_menu
;;
Dokodemo-Door)
dokodemo_menu
;;
HA-Proxy)
haproxy_menu
;;
Options)
other_options_menu
;;
Quit)
exit 0
;;
*)
whiptail --title "Invalid Option" --msgbox "Please select a valid option." 8 60
exit 1
;;
esac
else
exit 1
fi
done
}
menu