-
Notifications
You must be signed in to change notification settings - Fork 1
/
frp.sh
executable file
·78 lines (71 loc) · 1.93 KB
/
frp.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
#!/bin/bash
sudo apt install axel wget aria2 -y
FRP_VERSION=0.14.1
FRP_ARCH=amd64
Server=n
Client=n
Just_Install=n
#FRP_ARCH=arm
while getopts 'v:a:sc' OPT; do
case $OPT in
v)
FRP_VERSION="$OPTARG";;
a)
FRP_ARCH="$OPTARG";;
s)
Server="y";;
c)
Client="y";;
?)
echo "Usage: `basename $0` [options] filename"
esac
done
shift $(($OPTIND - 1))
if [ ! -d "$HOME/frp" ]; then
aria2c https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_${FRP_ARCH}.tar.gz && \
#axel -n 10 https://github.com/fatedier/frp/releases/download/v${FRP_VERSION}/frp_${FRP_VERSION}_linux_${FRP_ARCH}.tar.gz && \
tar -xzf frp_${FRP_VERSION}_linux_${FRP_ARCH}.tar.gz && \
sudo mv frp_${FRP_VERSION}_linux_${FRP_ARCH} ~/frp && \
rm frp_${FRP_VERSION}_linux_${FRP_ARCH}.tar.gz
fi
if [ ! -d "/etc/frp" ]; then
sudo mkdir /etc/frp
fi
sudo ln -sf ~/frp/frps.ini /etc/frp/frps.ini
sudo ln -sf ~/frp/frpc.ini /etc/frp/frpc.ini
sudo ln -sf ~/frp/frps /usr/local/bin/frps
sudo ln -sf ~/frp/frpc /usr/local/bin/frpc
if [ ${Server} = "y" ]; then
sudo tee /etc/systemd/system/frps.service <<-'EOF'
[Unit]
Description=frps Service
After=network.target
Wants=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/frps -c /etc/frp/frps.ini
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable frps.service
sudo systemctl start frps.service
fi
if [ ${Client} = "y" ]; then
sudo tee /etc/systemd/system/frpc.service <<-'EOF'
[Unit]
Description=frpc Service
After=NetworkManager-wait-online.service network.target network-online.target
Wants=NetworkManager-wait-online.service network.target network-online.target
[Service]
Type=simple
ExecStart=/usr/local/bin/frpc -c /etc/frp/frpc.ini
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl daemon-reload
sudo systemctl enable frpc.service
sudo systemctl start frpc.service
fi