Skip to content

Commit c6c7dd5

Browse files
authored
add install_host & tls prompt for dashboard script (#26)
1 parent 8b13399 commit c6c7dd5

File tree

9 files changed

+240
-158
lines changed

9 files changed

+240
-158
lines changed

extras/config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ debug: false
22
listenport: nz_port
33
language: nz_language
44
sitename: "nz_site_title"
5+
installhost: nz_hostport
6+
tls: nz_tls

install.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,29 @@ modify_config() {
330330
return 0
331331
fi
332332

333-
334333
printf "请输入站点标题: "
335334
read -r nz_site_title
336335
printf "请输入暴露端口: (默认 8008)"
337336
read -r nz_port
338-
info "请指定后台语言"
339-
info "1. 中文(简体)"
340-
info "2. 中文(台灣)"
341-
info "3. English"
337+
printf "请指定安装命令中预设的 nezha-agent 连接地址 (例如 example.com:443)"
338+
read -r nz_hostport
339+
printf "是否希望通过 TLS 连接 Agent?(影响安装命令)[y/N]"
340+
read -r input
341+
case $input in
342+
[yY][eE][sS] | [yY])
343+
nz_tls=true
344+
;;
345+
[nN][oO] | [nN])
346+
nz_tls=false
347+
;;
348+
*)
349+
nz_tls=false
350+
;;
351+
esac
352+
println "请指定后台语言"
353+
println "1. 中文(简体)"
354+
println "2. 中文(台灣)"
355+
println "3. English"
342356
while true; do
343357
printf "请输入选项 [1-3]"
344358
read -r option
@@ -361,7 +375,7 @@ modify_config() {
361375
esac
362376
done
363377

364-
if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ]; then
378+
if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ] || [ -z "$nz_hostport" ]; then
365379
err ""所有选项都不能为空""
366380
before_show_menu
367381
return 1
@@ -374,6 +388,8 @@ modify_config() {
374388
sed -i "s/nz_port/${nz_port}/" /tmp/nezha-config.yaml
375389
sed -i "s/nz_language/${nz_lang}/" /tmp/nezha-config.yaml
376390
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
391+
sed -i "s/nz_hostport/${nz_hostport}/" /tmp/nezha-config.yaml
392+
sed -i "s/nz_tls/${nz_tls}/" /tmp/nezha-config.yaml
377393
if [ "$IS_DOCKER_NEZHA" = 1 ]; then
378394
sed -i "s/nz_port/${nz_port}/g" /tmp/nezha-docker-compose.yaml
379395
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml

install_en.sh

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,15 +330,29 @@ modify_config() {
330330
return 0
331331
fi
332332

333-
334333
printf "Please enter the site title: "
335334
read -r nz_site_title
336335
printf "Please enter the exposed port: (default 8008)"
337336
read -r nz_port
338-
info "Please specify the backend locale"
339-
info "1. 中文(简体)"
340-
info "2. 中文(台灣)"
341-
info "3. English"
337+
printf "Please specify the preset nezha-agent host in install commands: (e.g. example.com:443)"
338+
read -r nz_hostport
339+
printf "Do you prefer to connect Agent via TLS? [y/N]"
340+
read -r input
341+
case $input in
342+
[yY][eE][sS] | [yY])
343+
nz_tls=true
344+
;;
345+
[nN][oO] | [nN])
346+
nz_tls=false
347+
;;
348+
*)
349+
nz_tls=false
350+
;;
351+
esac
352+
println "Please specify the backend locale"
353+
println "1. 中文(简体)"
354+
println "2. 中文(台灣)"
355+
println "3. English"
342356
while true; do
343357
printf "Please enter [1-3]: "
344358
read -r option
@@ -361,7 +375,7 @@ modify_config() {
361375
esac
362376
done
363377

364-
if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ]; then
378+
if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ] || [ -z "$nz_hostport" ]; then
365379
err "All options cannot be empty"
366380
before_show_menu
367381
return 1
@@ -374,6 +388,8 @@ modify_config() {
374388
sed -i "s/nz_port/${nz_port}/" /tmp/nezha-config.yaml
375389
sed -i "s/nz_language/${nz_lang}/" /tmp/nezha-config.yaml
376390
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
391+
sed -i "s/nz_hostport/${nz_hostport}/" /tmp/nezha-config.yaml
392+
sed -i "s/nz_tls/${nz_tls}/" /tmp/nezha-config.yaml
377393
if [ "$IS_DOCKER_NEZHA" = 1 ]; then
378394
sed -i "s/nz_port/${nz_port}/g" /tmp/nezha-docker-compose.yaml
379395
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml

nezha/template.pot

Lines changed: 56 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2024-11-29 21:03+0800\n"
11+
"POT-Creation-Date: 2024-12-02 13:39+0800\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -96,194 +96,204 @@ msgstr ""
9696
msgid "https://${GITHUB_RAW_URL}/install_en.sh"
9797
msgstr ""
9898

99-
#: nezha/template.sh:249
99+
#: nezha/template.sh:249 nezha/template.sh:266
100100
msgid "Execute new script after 3s"
101101
msgstr ""
102102

103-
#: nezha/template.sh:257
103+
#: nezha/template.sh:274
104104
msgid "* Press Enter to return to the main menu *"
105105
msgstr ""
106106

107-
#: nezha/template.sh:262
107+
#: nezha/template.sh:279
108108
msgid "> Install"
109109
msgstr ""
110110

111-
#: nezha/template.sh:268
111+
#: nezha/template.sh:285
112112
msgid ""
113113
"You may have already installed the dashboard, repeated installation will "
114114
"overwrite the data, please pay attention to backup."
115115
msgstr ""
116116

117-
#: nezha/template.sh:269
117+
#: nezha/template.sh:286
118118
msgid "Exit the installation? [Y/n]"
119119
msgstr ""
120120

121-
#: nezha/template.sh:273 nezha/template.sh:281
121+
#: nezha/template.sh:290 nezha/template.sh:297
122122
msgid "Exit the installation"
123123
msgstr ""
124124

125-
#: nezha/template.sh:277
125+
#: nezha/template.sh:294
126126
msgid "Continue"
127127
msgstr ""
128128

129-
#: nezha/template.sh:295
129+
#: nezha/template.sh:311
130130
msgid "Modify Configuration"
131131
msgstr ""
132132

133-
#: nezha/template.sh:299
133+
#: nezha/template.sh:315
134134
msgid "Download Docker Script"
135135
msgstr ""
136136

137-
#: nezha/template.sh:302 nezha/template.sh:313
137+
#: nezha/template.sh:318 nezha/template.sh:329
138138
msgid ""
139139
"Script failed to get, please check if the network can link ${GITHUB_RAW_URL}"
140140
msgstr ""
141141

142-
#: nezha/template.sh:306
142+
#: nezha/template.sh:322
143143
msgid ""
144144
"Please install docker-compose manually. https://docs.docker.com/compose/"
145145
"install/linux/"
146146
msgstr ""
147147

148-
#: nezha/template.sh:318
148+
#: nezha/template.sh:334
149149
msgid "Please enter the site title: "
150150
msgstr ""
151151

152-
#: nezha/template.sh:320
152+
#: nezha/template.sh:336
153153
msgid "Please enter the exposed port: (default 8008)"
154154
msgstr ""
155155

156-
#: nezha/template.sh:322
156+
#: nezha/template.sh:338
157+
msgid ""
158+
"Please specify the preset nezha-agent host in install commands: (e.g. "
159+
"example.com:443)"
160+
msgstr ""
161+
162+
#: nezha/template.sh:340
163+
msgid "Do you prefer to connect Agent via TLS? [y/N]"
164+
msgstr ""
165+
166+
#: nezha/template.sh:355
157167
msgid "Please specify the backend locale"
158168
msgstr ""
159169

160-
#: nezha/template.sh:327
170+
#: nezha/template.sh:360
161171
msgid "Please enter [1-3]: "
162172
msgstr ""
163173

164-
#: nezha/template.sh:343
174+
#: nezha/template.sh:376
165175
msgid "Please enter the correct number [1-3]"
166176
msgstr ""
167177

168-
#: nezha/template.sh:349
178+
#: nezha/template.sh:382
169179
msgid "All options cannot be empty"
170180
msgstr ""
171181

172-
#: nezha/template.sh:373
182+
#: nezha/template.sh:408
173183
msgid "Downloading service file"
174184
msgstr ""
175185

176-
#: nezha/template.sh:377 nezha/template.sh:383
186+
#: nezha/template.sh:412 nezha/template.sh:418
177187
msgid ""
178188
"File failed to get, please check if the network can link ${GITHUB_RAW_URL}"
179189
msgstr ""
180190

181-
#: nezha/template.sh:391
191+
#: nezha/template.sh:426
182192
msgid ""
183193
"Dashboard configuration modified successfully, please wait for Dashboard "
184194
"self-restart to take effect"
185195
msgstr ""
186196

187-
#: nezha/template.sh:401
197+
#: nezha/template.sh:436
188198
msgid "> Restart and Update"
189199
msgstr ""
190200

191-
#: nezha/template.sh:410
201+
#: nezha/template.sh:445
192202
msgid "Nezha Monitoring Restart Successful"
193203
msgstr ""
194204

195-
#: nezha/template.sh:411
205+
#: nezha/template.sh:446
196206
msgid "Default address: domain:site_access_port"
197207
msgstr ""
198208

199-
#: nezha/template.sh:413
209+
#: nezha/template.sh:448
200210
msgid ""
201211
"The restart failed, probably because the boot time exceeded two seconds, "
202212
"please check the log information later"
203213
msgstr ""
204214

205-
#: nezha/template.sh:440
215+
#: nezha/template.sh:475
206216
msgid ""
207217
"Fail to obtain Dashboard version, please check if the network can link "
208218
"https://api.github.com/repos/nezhahq/nezha/releases/latest"
209219
msgstr ""
210220

211-
#: nezha/template.sh:443
221+
#: nezha/template.sh:478
212222
msgid "The current latest version is: ${_version}"
213223
msgstr ""
214224

215-
#: nezha/template.sh:472
225+
#: nezha/template.sh:507
216226
msgid "> View Log"
217227
msgstr ""
218228

219-
#: nezha/template.sh:498
229+
#: nezha/template.sh:533
220230
msgid "> Uninstall"
221231
msgstr ""
222232

223-
#: nezha/template.sh:537
233+
#: nezha/template.sh:572
224234
msgid "Nezha Monitor Management Script Usage: "
225235
msgstr ""
226236

227-
#: nezha/template.sh:539
237+
#: nezha/template.sh:574
228238
msgid "./nezha.sh - Show Menu"
229239
msgstr ""
230240

231-
#: nezha/template.sh:540
241+
#: nezha/template.sh:575
232242
msgid "./nezha.sh install - Install Dashboard"
233243
msgstr ""
234244

235-
#: nezha/template.sh:541
245+
#: nezha/template.sh:576
236246
msgid "./nezha.sh modify_config - Modify Dashboard Configuration"
237247
msgstr ""
238248

239-
#: nezha/template.sh:542
249+
#: nezha/template.sh:577
240250
msgid "./nezha.sh restart_and_update - Restart and Update the Dashboard"
241251
msgstr ""
242252

243-
#: nezha/template.sh:543
253+
#: nezha/template.sh:578
244254
msgid "./nezha.sh show_log - View Dashboard Log"
245255
msgstr ""
246256

247-
#: nezha/template.sh:544
257+
#: nezha/template.sh:579
248258
msgid "./nezha.sh uninstall - Uninstall Dashboard"
249259
msgstr ""
250260

251-
#: nezha/template.sh:549
261+
#: nezha/template.sh:584
252262
msgid "${green}Nezha Monitor Management Script${plain}"
253263
msgstr ""
254264

255-
#: nezha/template.sh:551
265+
#: nezha/template.sh:586
256266
msgid "${green}1.${plain} Install Dashboard"
257267
msgstr ""
258268

259-
#: nezha/template.sh:552
269+
#: nezha/template.sh:587
260270
msgid "${green}2.${plain} Modify Dashboard Configuration"
261271
msgstr ""
262272

263-
#: nezha/template.sh:553
273+
#: nezha/template.sh:588
264274
msgid "${green}3.${plain} Restart and Update Dashboard"
265275
msgstr ""
266276

267-
#: nezha/template.sh:554
277+
#: nezha/template.sh:589
268278
msgid "${green}4.${plain} View Dashboard Log"
269279
msgstr ""
270280

271-
#: nezha/template.sh:555
281+
#: nezha/template.sh:590
272282
msgid "${green}5.${plain} Uninstall Dashboard"
273283
msgstr ""
274284

275-
#: nezha/template.sh:557
285+
#: nezha/template.sh:592
276286
msgid "${green}6.${plain} Update Script"
277287
msgstr ""
278288

279-
#: nezha/template.sh:559
289+
#: nezha/template.sh:594
280290
msgid "${green}0.${plain} Exit Script"
281291
msgstr ""
282292

283-
#: nezha/template.sh:561
293+
#: nezha/template.sh:596
284294
msgid "Please enter [0-6]: "
285295
msgstr ""
286296

287-
#: nezha/template.sh:585
297+
#: nezha/template.sh:620
288298
msgid "Please enter the correct number [0-6]"
289299
msgstr ""

0 commit comments

Comments
 (0)