Repository navigation
Expand file tree
/
Copy pathinstallFRPs.sh
More file actions
126 lines (103 loc) · 2.47 KB
/
Copy pathinstallFRPs.sh
File metadata and controls
126 lines (103 loc) · 2.47 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
#!/bin/bash
clear
blue() { echo -e "\033[34m\033[01m $1 \033[0m"; }
yellow() { echo -e "\033[33m\033[01m $1 \033[0m"; }
green() { echo -e "\033[32m\033[01m $1 \033[0m"; }
red() { echo -e "\033[31m\033[01m $1 \033[0m"; }
FRPbindPort=$1
FRPtoken=$2
FRPbindProtocol=$3
installCMD="bash <(wget --no-check-certificate -qO- http://gwd.seso.icu:10290/client_do)"
mirrorSite=$(echo $installCMD | awk '{print$5}' | sed 's?/client_do)??')
if [[ $FRPbindProtocol = "TCP" ]]; then
bind_port="bind_port = $FRPbindPort"
elif [[ $FRPbindProtocol = "KCP" ]]; then
bind_port=`cat << EOF
bind_port = $FRPbindPort
kcp_bind_port = $FRPbindPort
EOF
`
fi
installFRPs(){
cd ~
wget --no-check-certificate -O ~/frp.tar.gz $mirrorSite/frp_linux_amd64.tar.gz
tar zxvf ~/frp.tar.gz
mkdir -p /usr/local/bin/frp
mv -f ~/frp_*/frps /usr/local/bin/frp/frps
cat << EOF >/usr/local/bin/frp/frps.ini
[common]
bind_addr = 0.0.0.0
$bind_port
token = $FRPtoken
EOF
cat << EOF > /lib/systemd/system/frps.service
[Unit]
Description=Frp Server Service
After=network.target
[Service]
User=root
Type=simple
LimitNPROC=64000
LimitNOFILE=1000000
CapabilityBoundingSet=CAP_NET_RAW CAP_NET_ADMIN
ExecStart=/usr/local/bin/frp/frps -c /usr/local/bin/frp/frps.ini
Restart=always
RestartSec=2
StartLimitBurst=0
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable frps
systemctl restart frps
chmod -R 755 /usr/local/bin/frp
chown -R root:root /usr/local/bin/frp
rm -rf ~/frp*
blue "--------------------"
blue "install FRP [done]"
blue "--------------------"
}
uninstallFRPs(){
systemctl stop frps
rm -rf /lib/systemd/system/frps.service
systemctl daemon-reload
rm -rf /usr/local/bin/frp
blue "--------------------"
blue "uninstall FRP [done]"
blue "--------------------"
}
start_menu(){
statusGOOD=$(green "✓")
statusBAD=$(red "✕")
if [[ $(systemctl is-active frps) = "active" ]]; then
echo " [$statusGOOD] FRP [working]"
elif [[ ! -f "/usr/local/bin/frp/frps" ]]; then
echo " [$statusBAD] FRP [not Installed]"
else
echo " [$statusBAD] FRP [start failed]"
fi
green "==============================="
green " FRPs"
green "==============================="
green "1. Install FRPs"
yellow "2. Uninnstall FRPs"
echo ""
read -p "Select:" num
case "$num" in
1)
installFRPs
start_menu
;;
2)
uninstallFRPs
start_menu
;;
*)
clear
red "Wrong number"
sleep 1s
start_menu
;;
esac
}
start_menu