Skip to content

Commit

Permalink
add install_host & tls prompt for dashboard script (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
uubulb authored Dec 2, 2024
1 parent 8b13399 commit c6c7dd5
Show file tree
Hide file tree
Showing 9 changed files with 240 additions and 158 deletions.
2 changes: 2 additions & 0 deletions extras/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ debug: false
listenport: nz_port
language: nz_language
sitename: "nz_site_title"
installhost: nz_hostport
tls: nz_tls
28 changes: 22 additions & 6 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,29 @@ modify_config() {
return 0
fi


printf "请输入站点标题: "
read -r nz_site_title
printf "请输入暴露端口: (默认 8008)"
read -r nz_port
info "请指定后台语言"
info "1. 中文(简体)"
info "2. 中文(台灣)"
info "3. English"
printf "请指定安装命令中预设的 nezha-agent 连接地址 (例如 example.com:443)"
read -r nz_hostport
printf "是否希望通过 TLS 连接 Agent?(影响安装命令)[y/N]"
read -r input
case $input in
[yY][eE][sS] | [yY])
nz_tls=true
;;
[nN][oO] | [nN])
nz_tls=false
;;
*)
nz_tls=false
;;
esac
println "请指定后台语言"
println "1. 中文(简体)"
println "2. 中文(台灣)"
println "3. English"
while true; do
printf "请输入选项 [1-3]"
read -r option
Expand All @@ -361,7 +375,7 @@ modify_config() {
esac
done

if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ]; then
if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ] || [ -z "$nz_hostport" ]; then
err ""所有选项都不能为空""
before_show_menu
return 1
Expand All @@ -374,6 +388,8 @@ modify_config() {
sed -i "s/nz_port/${nz_port}/" /tmp/nezha-config.yaml
sed -i "s/nz_language/${nz_lang}/" /tmp/nezha-config.yaml
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
sed -i "s/nz_hostport/${nz_hostport}/" /tmp/nezha-config.yaml
sed -i "s/nz_tls/${nz_tls}/" /tmp/nezha-config.yaml
if [ "$IS_DOCKER_NEZHA" = 1 ]; then
sed -i "s/nz_port/${nz_port}/g" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
Expand Down
28 changes: 22 additions & 6 deletions install_en.sh
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,29 @@ modify_config() {
return 0
fi


printf "Please enter the site title: "
read -r nz_site_title
printf "Please enter the exposed port: (default 8008)"
read -r nz_port
info "Please specify the backend locale"
info "1. 中文(简体)"
info "2. 中文(台灣)"
info "3. English"
printf "Please specify the preset nezha-agent host in install commands: (e.g. example.com:443)"
read -r nz_hostport
printf "Do you prefer to connect Agent via TLS? [y/N]"
read -r input
case $input in
[yY][eE][sS] | [yY])
nz_tls=true
;;
[nN][oO] | [nN])
nz_tls=false
;;
*)
nz_tls=false
;;
esac
println "Please specify the backend locale"
println "1. 中文(简体)"
println "2. 中文(台灣)"
println "3. English"
while true; do
printf "Please enter [1-3]: "
read -r option
Expand All @@ -361,7 +375,7 @@ modify_config() {
esac
done

if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ]; then
if [ -z "$nz_lang" ] || [ -z "$nz_site_title" ] || [ -z "$nz_hostport" ]; then
err "All options cannot be empty"
before_show_menu
return 1
Expand All @@ -374,6 +388,8 @@ modify_config() {
sed -i "s/nz_port/${nz_port}/" /tmp/nezha-config.yaml
sed -i "s/nz_language/${nz_lang}/" /tmp/nezha-config.yaml
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
sed -i "s/nz_hostport/${nz_hostport}/" /tmp/nezha-config.yaml
sed -i "s/nz_tls/${nz_tls}/" /tmp/nezha-config.yaml
if [ "$IS_DOCKER_NEZHA" = 1 ]; then
sed -i "s/nz_port/${nz_port}/g" /tmp/nezha-docker-compose.yaml
sed -i "s/nz_image_url/${Docker_IMG}/" /tmp/nezha-docker-compose.yaml
Expand Down
102 changes: 56 additions & 46 deletions nezha/template.pot
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-11-29 21:03+0800\n"
"POT-Creation-Date: 2024-12-02 13:39+0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
Expand Down Expand Up @@ -96,194 +96,204 @@ msgstr ""
msgid "https://${GITHUB_RAW_URL}/install_en.sh"
msgstr ""

#: nezha/template.sh:249
#: nezha/template.sh:249 nezha/template.sh:266
msgid "Execute new script after 3s"
msgstr ""

#: nezha/template.sh:257
#: nezha/template.sh:274
msgid "* Press Enter to return to the main menu *"
msgstr ""

#: nezha/template.sh:262
#: nezha/template.sh:279
msgid "> Install"
msgstr ""

#: nezha/template.sh:268
#: nezha/template.sh:285
msgid ""
"You may have already installed the dashboard, repeated installation will "
"overwrite the data, please pay attention to backup."
msgstr ""

#: nezha/template.sh:269
#: nezha/template.sh:286
msgid "Exit the installation? [Y/n]"
msgstr ""

#: nezha/template.sh:273 nezha/template.sh:281
#: nezha/template.sh:290 nezha/template.sh:297
msgid "Exit the installation"
msgstr ""

#: nezha/template.sh:277
#: nezha/template.sh:294
msgid "Continue"
msgstr ""

#: nezha/template.sh:295
#: nezha/template.sh:311
msgid "Modify Configuration"
msgstr ""

#: nezha/template.sh:299
#: nezha/template.sh:315
msgid "Download Docker Script"
msgstr ""

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

#: nezha/template.sh:306
#: nezha/template.sh:322
msgid ""
"Please install docker-compose manually. https://docs.docker.com/compose/"
"install/linux/"
msgstr ""

#: nezha/template.sh:318
#: nezha/template.sh:334
msgid "Please enter the site title: "
msgstr ""

#: nezha/template.sh:320
#: nezha/template.sh:336
msgid "Please enter the exposed port: (default 8008)"
msgstr ""

#: nezha/template.sh:322
#: nezha/template.sh:338
msgid ""
"Please specify the preset nezha-agent host in install commands: (e.g. "
"example.com:443)"
msgstr ""

#: nezha/template.sh:340
msgid "Do you prefer to connect Agent via TLS? [y/N]"
msgstr ""

#: nezha/template.sh:355
msgid "Please specify the backend locale"
msgstr ""

#: nezha/template.sh:327
#: nezha/template.sh:360
msgid "Please enter [1-3]: "
msgstr ""

#: nezha/template.sh:343
#: nezha/template.sh:376
msgid "Please enter the correct number [1-3]"
msgstr ""

#: nezha/template.sh:349
#: nezha/template.sh:382
msgid "All options cannot be empty"
msgstr ""

#: nezha/template.sh:373
#: nezha/template.sh:408
msgid "Downloading service file"
msgstr ""

#: nezha/template.sh:377 nezha/template.sh:383
#: nezha/template.sh:412 nezha/template.sh:418
msgid ""
"File failed to get, please check if the network can link ${GITHUB_RAW_URL}"
msgstr ""

#: nezha/template.sh:391
#: nezha/template.sh:426
msgid ""
"Dashboard configuration modified successfully, please wait for Dashboard "
"self-restart to take effect"
msgstr ""

#: nezha/template.sh:401
#: nezha/template.sh:436
msgid "> Restart and Update"
msgstr ""

#: nezha/template.sh:410
#: nezha/template.sh:445
msgid "Nezha Monitoring Restart Successful"
msgstr ""

#: nezha/template.sh:411
#: nezha/template.sh:446
msgid "Default address: domain:site_access_port"
msgstr ""

#: nezha/template.sh:413
#: nezha/template.sh:448
msgid ""
"The restart failed, probably because the boot time exceeded two seconds, "
"please check the log information later"
msgstr ""

#: nezha/template.sh:440
#: nezha/template.sh:475
msgid ""
"Fail to obtain Dashboard version, please check if the network can link "
"https://api.github.com/repos/nezhahq/nezha/releases/latest"
msgstr ""

#: nezha/template.sh:443
#: nezha/template.sh:478
msgid "The current latest version is: ${_version}"
msgstr ""

#: nezha/template.sh:472
#: nezha/template.sh:507
msgid "> View Log"
msgstr ""

#: nezha/template.sh:498
#: nezha/template.sh:533
msgid "> Uninstall"
msgstr ""

#: nezha/template.sh:537
#: nezha/template.sh:572
msgid "Nezha Monitor Management Script Usage: "
msgstr ""

#: nezha/template.sh:539
#: nezha/template.sh:574
msgid "./nezha.sh - Show Menu"
msgstr ""

#: nezha/template.sh:540
#: nezha/template.sh:575
msgid "./nezha.sh install - Install Dashboard"
msgstr ""

#: nezha/template.sh:541
#: nezha/template.sh:576
msgid "./nezha.sh modify_config - Modify Dashboard Configuration"
msgstr ""

#: nezha/template.sh:542
#: nezha/template.sh:577
msgid "./nezha.sh restart_and_update - Restart and Update the Dashboard"
msgstr ""

#: nezha/template.sh:543
#: nezha/template.sh:578
msgid "./nezha.sh show_log - View Dashboard Log"
msgstr ""

#: nezha/template.sh:544
#: nezha/template.sh:579
msgid "./nezha.sh uninstall - Uninstall Dashboard"
msgstr ""

#: nezha/template.sh:549
#: nezha/template.sh:584
msgid "${green}Nezha Monitor Management Script${plain}"
msgstr ""

#: nezha/template.sh:551
#: nezha/template.sh:586
msgid "${green}1.${plain} Install Dashboard"
msgstr ""

#: nezha/template.sh:552
#: nezha/template.sh:587
msgid "${green}2.${plain} Modify Dashboard Configuration"
msgstr ""

#: nezha/template.sh:553
#: nezha/template.sh:588
msgid "${green}3.${plain} Restart and Update Dashboard"
msgstr ""

#: nezha/template.sh:554
#: nezha/template.sh:589
msgid "${green}4.${plain} View Dashboard Log"
msgstr ""

#: nezha/template.sh:555
#: nezha/template.sh:590
msgid "${green}5.${plain} Uninstall Dashboard"
msgstr ""

#: nezha/template.sh:557
#: nezha/template.sh:592
msgid "${green}6.${plain} Update Script"
msgstr ""

#: nezha/template.sh:559
#: nezha/template.sh:594
msgid "${green}0.${plain} Exit Script"
msgstr ""

#: nezha/template.sh:561
#: nezha/template.sh:596
msgid "Please enter [0-6]: "
msgstr ""

#: nezha/template.sh:585
#: nezha/template.sh:620
msgid "Please enter the correct number [0-6]"
msgstr ""
Loading

0 comments on commit c6c7dd5

Please sign in to comment.