-
Notifications
You must be signed in to change notification settings - Fork 0
/
frps.sh
60 lines (41 loc) · 1.23 KB
/
frps.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
#! /bin/bash
DownloadUrl=`curl -s https://api.github.com/repos/fatedier/frp/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep linux_amd64`
tempDir=/root/frpTemp
if [ ! -d $tempDir ]; then
mkdir $tempDir
fi
cd $tempDir
tarName=${DownloadUrl##*/}
echo $tarName
if [ ! -e $tarName ]; then
curl -L $DownloadUrl
fi
folderName=${tarName%.tar.gz*}
echo $folderName
if [ -d $folderName ]; then
rm -rf $folderName
fi
tar -zxf $tarName
cd $folderName
echo "source download ok. Installing..."
service=`systemctl | grep frps | awk '{print $1}'`
if [ $service != "" ]; then
echo "停止已有的frps服务:$service..."
systemctl stop $service && systemctl disable $service
fi
if [ ! -d "/etc/frp" ]; then
mkdir /etc/frp
mv frps.ini /etc/frp/frps.ini
fi
cp -f systemd/frps.service /lib/systemd/system/
cp -f frps /usr/bin/
systemctl enable frps && systemctl start frps
ufw allow 7000:7010/tcp
status=` systemctl list-units --type=service --state=running | grep frps| awk '{print $1}'`
if [ $status != "frps.service" ]; then
echo "frps 没有运行,请检查log"
echo "bin path: /usr/bin/frps"
echo "config path: /etc/frp/frps.ini"
else
echo "程序正确安装并在运行。结束"
fi