-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathmenuzivpn
More file actions
208 lines (202 loc) · 7.25 KB
/
menuzivpn
File metadata and controls
208 lines (202 loc) · 7.25 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
#!/bin/bash
#Zahid - PowerMX
IP=`curl -4 icanhazip.com`;
distribution=`( lsb_release -ds || cat /etc/*release || uname -om ) 2>/dev/null | head -n1`;
Network=`ip -4 route ls|grep default|grep -Po '(?<=dev )(\S+)'|head -1`;
ports=`netstat -tunlp | grep zivpn | grep ::: | awk '{print substr($4,4); }' > /tmp/udpzivpn.txt && echo | cat /tmp/udpzivpn.txt | tr '\n' ' ' > /tmp/udpzivpnports.txt && cat /tmp/udpzivpnports.txt`;
#colors
RED='\033[1;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;33m'
BLUE='\033[1;34m'
PURPLE='\033[1;35m'
CYAN='\033[1;36m'
GRAY='\033[1;37m'
WHITE='\033[1;37m'
RESET='\033[0m'
#menu
while true; do
if [ $(id -u) -eq 0 ]; then
clear
else
echo -e "Run the script as root user"
exit
fi
#installv1
function installv1(){
echo -e "${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}This option will install ZIVPN version 1, UDP port range will be 20000:50000 redirected to 5666"
echo -e "${YELLOW}Continue?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}INSTALLING.."
bash <(curl -fsSL https://raw.githubusercontent.com/powermx/zivpn/main/ziv1.sh)
fi
}
#installv2
function installv2(){
echo -e "${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}This option will install ZIVPN version 2 AMD, UDP port range will be 6000:19999 redirected to 5667"
echo -e "${YELLOW}Continue?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}INSTALLING.."
bash <(curl -fsSL https://raw.githubusercontent.com/powermx/zivpn/main/ziv2.sh)
fi
}
#installv3
function installv3(){
echo -e "${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}This option will install ZIVPN version 2 ARM, UDP port range will be 6000:19999 redirected to 5667"
echo -e "${YELLOW}Continue?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}INSTALLING.."
bash <(curl -fsSL https://raw.githubusercontent.com/powermx/zivpn/main/ziv3.sh)
fi
}
#uninstall
function uninstall(){
echo -e "${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}This option will uninstall the ZIVPN server in any of its versions"
echo -e "${YELLOW}Continue?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}UNINSTALLING.."
bash <(curl -fsSL https://raw.githubusercontent.com/powermx/zivpn/main/uninstall.sh)
fi
}
#start
function startzivpn(){
echo -e "${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}This option will start the ZiVPN server"
echo -e "${YELLOW}Continue?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}STARTING.."
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}Checking for ZiVPN services..."
if [[ -f /etc/systemd/system/zivpn.service ]]; then
echo -e "${YELLOW}Starting ZiVPN service..."
sudo systemctl start zivpn.service
fi
if [[ -f /etc/systemd/system/zivpn_backfill.service ]]; then
echo -e "${YELLOW}Starting ZiVPN Backfill service..."
sudo systemctl start zivpn_backfill.service
fi
echo -e "${YELLOW}DONE!"
fi
fi
}
#stop
function stopzivpn(){
echo -e "${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}This option will stop the ZiVPN server"
echo -e "${YELLOW}Continue?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}STOPPING.."
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}Checking for ZiVPN services..."
if [[ -f /etc/systemd/system/zivpn.service ]]; then
echo -e "${YELLOW}Starting ZiVPN service..."
sudo systemctl stop zivpn.service
fi
if [[ -f /etc/systemd/system/zivpn_backfill.service ]]; then
echo -e "${YELLOW}Starting ZiVPN Backfill service..."
sudo systemctl stop zivpn_backfill.service
fi
echo -e "${YELLOW}DONE!"
fi
fi
}
#restart
function restartzivpn(){
echo -e "${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}This option will restart the ZiVPN server"
echo -e "${YELLOW}Continue?"
while [[ ${yesno} != @(s|S|y|Y|n|N) ]]; do
read -p "[S/N]: " yesno
tput cuu1 && tput dl1
done
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}RESTARTING.."
if [[ ${yesno} = @(s|S|y|Y) ]]; then
echo -e "${YELLOW}Checking for ZiVPN services..."
if [[ -f /etc/systemd/system/zivpn.service ]]; then
echo -e "${YELLOW}Starting ZiVPN service..."
sudo systemctl restart zivpn.service
fi
if [[ -f /etc/systemd/system/zivpn_backfill.service ]]; then
echo -e "${YELLOW}Starting ZiVPN Backfill service..."
sudo systemctl restart zivpn_backfill.service
fi
echo -e "${YELLOW}DONE!"
fi
fi
}
if [[ $1 == "" ]]; then
clear && printf '\e[3J'
echo -e "${GRAY}[${RED}-${GRAY}]${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW} 【 ${RED}ZIVPN ${YELLOW}】 "
echo -e "${YELLOW} › ${WHITE}Linux Dist:${GREEN} $distribution "
echo -e "${YELLOW} › ${WHITE}IP:${GREEN} $IP "
echo -e "${YELLOW} › ${WHITE}Network:${GREEN} $Network "
echo -e "${YELLOW} › ${WHITE}Running:${GREEN} $ports "
echo -e "${GRAY}[${RED}-${GRAY}]${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW}[${GREEN}1${YELLOW}] ${RED} › ${WHITE} INSTALL ZIVPN V1 (5666) [Discontinued]
${YELLOW}[${GREEN}2${YELLOW}] ${RED} › ${WHITE} INSTALL ZIVPN V2 AMD (5667) [Recommended]
${YELLOW}[${GREEN}3${YELLOW}] ${RED} › ${WHITE} INSTALL ZIVPN V2 ARM (5667)
${YELLOW}[${GREEN}4${YELLOW}] ${RED} › ${WHITE} UNINSTALL ZIVPN
${YELLOW}[${GREEN} ${YELLOW}] ${RED} › ${WHITE} ────────
${YELLOW}[${GREEN}5${YELLOW}] ${RED} › ${WHITE} START ZIVPN
${YELLOW}[${GREEN}6${YELLOW}] ${RED} › ${WHITE} STOP ZIVPN
${YELLOW}[${GREEN}7${YELLOW}] ${RED} › ${WHITE} RESTART ZIVPN
${YELLOW}[${GREEN}0${YELLOW}] ${RED} › ${WHITE} EXIT
${GRAY}[${RED}-${GRAY}]${RED} ────────────── /// ─────────────── "
echo -e "${YELLOW} Δ CHOOSE AN OPTION: ${YELLOW}"
read -p " : " option
tput cuu1 >&2 && tput dl1 >&2
else
option=$1
fi
case $option in
1 | 01 )
installv1;;
2 | 02 )
installv2;;
3 | 03 )
installv3;;
4 | 04)
uninstall;;
5 | 05)
startzivpn;;
6 | 06)
stopzivpn;;
7 | 07)
restartzivpn;;
0)
exit;;
*)
continue;;
esac
break
done