-
-
Notifications
You must be signed in to change notification settings - Fork 70
/
Copy pathinstall.sh
executable file
·165 lines (131 loc) · 3.69 KB
/
install.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
#!/bin/bash
VERSION_CODENAME=$(lsb_release -cs);
if [ "$VERSION_CODENAME" != "buster" ]; then
echo "只支持 buster 系统"
exit 1
fi
if test "$NETWORK_RC_BETA" = "1"; then
echo '安装 Beta 版'
fi
if test "$NETWORK_RC_VERSION" = ""; then
echo '安装最新版本'
DOWNLOAD_LINK='https://download.esonwong.com/network-rc/network-rc.tar.gz'
else
echo '开始安装 Network RC 版本: '$NETWORK_RC_VERSION
DOWNLOAD_LINK="https://download.esonwong.com/network-rc/network-rc-${NETWORK_RC_VERSION}.tar.gz"
fi
read -p "使用内置 frp 服务器(yes/no, 默认 yes):" defaultFrp
defaultFrp=${defaultFrp:-yes}
echo defaultFrp: $defaultFrp
if [ "$defaultFrp" = "yes" ] || [ "$defaultFrp" = "y" ]; then
defaultFrp=true
defaultSubDomain=$(cat /proc/sys/kernel/random/uuid | cut -c 1-4)
read -p "域名前缀(默认 $defaultSubDomain):" subDomain
subDomain=${subDomain:-$defaultSubDomain}
else
defaultFrpcConfig="/home/pi/frpc.ini"
read -p "frpc 配置文件地址(默认 $defaultFrpcConfig):" frpcConfig
frpcConfig=${frpcConfig:-$defaultFrpcConfig}
fi
read -p "Network RC 密码(默认 networkrc):" password
password=${password:-networkrc}
read -p "本地端口(默认 8080):" localPort
localPort=${localPort:-8080}
echo ""
echo ""
echo ""
echo "你的设置如下"
echo "----------------------------------------"
if [ $defaultFrp = true ]; then
echo "域名前缀: $subDomain"
echo "Network RC 控制界面访问地址: https://${subDomain}.nrc.esonwong.com:9000";
else
echo "使用自定义 frp 服务器"
echo "frpc 配置文件地址: $frpcConfig"
fi
echo "Network RC 控制界面访问密码: $password"
echo "本地端口: $localPort"
echo ""
echo ""
echo ""
read -p "输入 ok 继续安装, 输入其他结束:" ok
echo "$ok"
if [ "$ok" = "ok" ]; then
echo ""
echo ""
echo ""
if sudo apt update; then
echo "apt update 成功"
else
echo "apt update 失败"
exit 1
fi
echo "安装依赖..."
if sudo apt install ffmpeg pulseaudio -y; then
echo "安装依赖成功"
else
echo "安装依赖失败"
exit 1
fi
echo ""
echo ""
echo ""
sudo rm -f /tmp/network-rc.tar.gz
if test "$NETWORK_RC_BETA" = "1"; then
echo "下载 Network RC beta 版本"
if wget -O /tmp/network-rc.tar.gz https://download.esonwong.com/network-rc/network-rc-beta.tar.gz; then
echo "下载成功"
else
echo "下载失败"
exit 1
fi
else
echo "下载 Network RC"
if wget -O /tmp/network-rc.tar.gz $DOWNLOAD_LINK; then
echo "下载成功"
else
echo "下载失败"
exit 1
fi
fi
echo ""
echo ""
echo ""
echo "解压 Network RC 中..."
tar -zxf /tmp/network-rc.tar.gz -C /home/pi/
echo ""
echo ""
echo ""
echo "安装 Network RC 服务"
echo "[Unit]
Description=network-rc
After=syslog.target network.target
Wants=network.target
[Service]
User=pi
Type=simple
ExecStart=/home/pi/network-rc/node /home/pi/network-rc/index.js --frpConfig \"$frpcConfig\" --password \"$password\" --subDomain \"$subDomain\" --localPort \"$localPort\"
Restart=always
RestartSec=15s
[Install]
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/network-rc.service
echo ""
echo ""
echo "创建 Network RC 服务完成"
sudo systemctl enable network-rc.service
echo "重启 Network RC 服务"
sudo systemctl restart network-rc.service
echo ""
echo ""
echo ""
echo "安装完成"
if [ $defaultFrp = true ]; then
echo "域名前缀: $subDomain"
echo "Network RC 控制界面访问地址: https://${subDomain}.nrc.esonwong.com:9000"
else
echo "frpc 配置文件地址: $frpcConfig"
fi
echo "Network RC 控制界面访问密码: $password"
else
exit 0
fi