diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1b3a239
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,6 @@
+LOCALES := zh_CN en_US
+
+run:
+ @for locale in $(LOCALES); do \
+ go run ./cmd/scriptgen/main.go locale.json $$locale; \
+ done
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3a132be
--- /dev/null
+++ b/README.md
@@ -0,0 +1,21 @@
+这里存放着所有关于哪吒监控官方安装脚本的文件。
+
+如何贡献:
+1. 仅更新 `template.sh`,不要编辑 `install.sh` 或者 `install_en.sh`,因为它们是生成的文件。如果你需要文本输出,请使用 Go 模板(比如 `{{.Placeholder}}`)。
+2. `template.sh` 必须兼容 POSIX sh,可以使用 确认。
+2. 如果你在 `template.sh` 添加了任何模板,请同步更新 `locale.json`。
+3. 运行 `make`。如果不能运行,请检查是否安装了 `go` 和 `make`。
+
+对于其它没有本地化的脚本(比如 Windows 和 macOS 的),请直接更改。
+
+---
+
+Here lies everything related to the official Nezha installation script.
+
+How to contribute:
+1. Update `template.sh` only. Do not edit `install.sh` or `install_en.sh`, for they're generated files. Use Go templates (e.g. `{{.Placeholder}}`) if printing text is needed.
+2. `template.sh` must be POSIX-compliant. To confirm it, you can use .
+3. Update `locale.json` if any template is added in `template.sh`.
+4. Run `make`. Remember to have `go` and `make` installed.
+
+For other scripts that don't have localization (like the Windows or macOS one), edit them directly.
diff --git a/extras/config.yaml b/extras/config.yaml
new file mode 100644
index 0000000..b1f1cdf
--- /dev/null
+++ b/extras/config.yaml
@@ -0,0 +1,14 @@
+debug: false
+httpport: 80
+language: nz_language
+grpcport: nz_grpc_port
+oauth2:
+ type: "nz_oauth2_type" #Oauth2 登录接入类型,github/gitlab/jihulab/gitee/gitea
+ admin: "nz_admin_logins" #管理员列表,半角逗号隔开
+ clientid: "nz_github_oauth_client_id" # 在 https://github.com/settings/developers 创建,无需审核 Callback 填 http(s)://域名或IP/oauth2/callback
+ clientsecret: "nz_github_oauth_client_secret"
+ endpoint: "" # 如gitea自建需要设置
+site:
+ brand: "nz_site_title"
+ cookiename: "nezha-dashboard" #浏览器 Cookie 字段名,可不改
+ theme: "default"
diff --git a/extras/docker-compose.yaml b/extras/docker-compose.yaml
new file mode 100644
index 0000000..80de003
--- /dev/null
+++ b/extras/docker-compose.yaml
@@ -0,0 +1,14 @@
+version: "3.3"
+
+services:
+ dashboard:
+ image: nz_image_url
+ restart: always
+ volumes:
+ - ./data:/dashboard/data
+ - ./static-custom/static:/dashboard/resource/static/custom:ro
+ - ./theme-custom/template:/dashboard/resource/template/theme-custom:ro
+ - ./dashboard-custom/template:/dashboard/resource/template/dashboard-custom:ro
+ ports:
+ - nz_site_port:80
+ - nz_grpc_port:nz_grpc_port
diff --git a/extras/install.command b/extras/install.command
new file mode 100644
index 0000000..375b2a7
--- /dev/null
+++ b/extras/install.command
@@ -0,0 +1,293 @@
+#!/bin/bash
+
+#========================================================
+# System Required: macOS 10.13+
+# Description: Nezha Agent Install Script (macOS)
+# Github: https://github.com/naiba/nezha
+#========================================================
+
+NZ_BASE_PATH="/opt/nezha"
+NZ_AGENT_PATH="${NZ_BASE_PATH}/agent"
+
+red='\033[0;31m'
+green='\033[0;32m'
+yellow='\033[0;33m'
+plain='\033[0m'
+export PATH=$PATH:/usr/local/bin
+
+pre_check() {
+ # check root
+ [[ $EUID -ne 0 ]] && echo -e "${red}ERROR: ${plain} This script must be run with the root user!\n" && exit 1
+
+ ## os_arch
+ if [[ $(uname -m | grep 'x86_64') != "" ]]; then
+ os_arch="amd64"
+ elif [[ $(uname -m | grep 'arm64\|arm64e') != "" ]]; then
+ os_arch="arm64"
+ fi
+
+ ## China_IP
+ if [[ -z "${CN}" ]]; then
+ if [[ $(curl -m 10 -s http://ip-api.com/json |grep 'country' |grep -q 'China') != "" ]]; then
+ echo "According to the information provided by ip-api.com, the current IP may be in China"
+ read -e -r -p "Is the installation done with a Chinese Mirror? [Y/n] (Custom Mirror Input 3):" input
+ case $input in
+ [yY][eE][sS] | [yY])
+ echo "Use Chinese Mirror"
+ CN=true
+ ;;
+
+ [nN][oO] | [nN])
+ echo "No Use Chinese Mirror"
+ ;;
+
+ [3])
+ echo "Use Custom Mirror"
+ read -e -r -p "Please enter a custom image (e.g. :dn-dao-github-mirror.daocloud.io), leave blank to nouse: " input
+ case $input in
+ *)
+ CUSTOM_MIRROR=$input
+ ;;
+ esac
+
+ ;;
+ *)
+ echo "No Use Chinese Mirror"
+ ;;
+ esac
+ fi
+ fi
+
+ if [[ -n "${CUSTOM_MIRROR}" ]]; then
+ GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
+ GITHUB_URL=$CUSTOM_MIRROR
+ else
+ if [[ -z "${CN}" ]]; then
+ GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
+ GITHUB_URL="github.com"
+ else
+ GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
+ GITHUB_URL="gitee.com"
+ fi
+ fi
+}
+
+before_show_menu() {
+ echo && echo -n -e "${yellow}* Press Enter to return to the main menu *${plain}" && read temp
+ show_menu
+}
+
+install_agent() {
+ echo -e "> Install Nezha Agent"
+
+ echo -e "Obtaining Agent version"
+
+ local version=$(curl -m 10 -sL "https://api.github.com/repos/nezhahq/agent/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
+ if [ ! -n "$version" ]; then
+ version=$(curl -m 10 -sL "https://gitee.com/api/v5/repos/naibahq/agent/releases/latest" | awk -F '"' '{for(i=1;i<=NF;i++){if($i=="tag_name"){print $(i+2)}}}')
+ fi
+ if [ ! -n "$version" ]; then
+ version=$(curl -m 10 -sL "https://fastly.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
+ fi
+ if [ ! -n "$version" ]; then
+ version=$(curl -m 10 -sL "https://gcore.jsdelivr.net/gh/nezhahq/agent/" | grep "option\.value" | awk -F "'" '{print $2}' | sed 's/nezhahq\/agent@/v/g')
+ fi
+
+ if [ ! -n "$version" ]; then
+ echo -e "Fail to obtaine agent version, please check if the network can link https://api.github.com/repos/nezhahq/agent/releases/latest"
+ return 0
+ else
+ echo -e "The current latest version is: ${version}"
+ fi
+
+ # Nezha Agent Folder
+ mkdir -p $NZ_AGENT_PATH
+ chmod -R 777 $NZ_AGENT_PATH
+
+ echo -e "Downloading Agent"
+ if [[ -z $CN ]]; then
+ NZ_AGENT_URL="https://${GITHUB_URL}/nezhahq/agent/releases/download/${version}/nezha-agent_darwin_${os_arch}.zip"
+ else
+ NZ_AGENT_URL="https://${GITHUB_URL}/naibahq/agent/releases/download/${version}/nezha-agent_darwin_${os_arch}.zip"
+ fi
+ curl -o nezha-agent_darwin_${os_arch}.zip -L -f --retry 2 --retry-max-time 60 $NZ_AGENT_URL >/dev/null 2>&1
+ if [[ $? != 0 ]]; then
+ echo -e "${red}Fail to download agent, please check if the network can link ${GITHUB_URL}${plain}"
+ return 0
+ fi
+
+ unzip -qo nezha-agent_darwin_${os_arch}.zip &&
+ mv nezha-agent $NZ_AGENT_PATH &&
+ rm -rf nezha-agent_darwin_${os_arch}.zip README.md
+
+ if [ $# -ge 3 ]; then
+ modify_agent_config "$@"
+ else
+ modify_agent_config 0
+ fi
+
+ if [[ $# == 0 ]]; then
+ before_show_menu
+ fi
+}
+
+modify_agent_config() {
+ echo -e "> Modify Agent Configuration"
+
+ if [ $# -lt 3 ]; then
+ echo "Please add Agent in the admin panel first, record the secret" &&
+ read -ep "Please enter a domain that resolves to the IP where the panel is located (no CDN sets): " nz_grpc_host &&
+ read -ep "Please enter the panel RPC port (default 5555): " nz_grpc_port &&
+ read -ep "Please enter the Agent secret: " nz_client_secret &&
+ read -ep "Do you want to enable SSL/TLS encryption for the gRPC port (--tls)? Press [y] if yes, the default is not required, and users can press Enter to skip if you don't understand: " nz_grpc_proxy
+ grep -qiw 'Y' <<<"${nz_grpc_proxy}" && args='--tls'
+ if [[ -z "${nz_grpc_host}" || -z "${nz_client_secret}" ]]; then
+ echo -e "${red}All options cannot be empty${plain}"
+ before_show_menu
+ return 1
+ fi
+ if [[ -z "${nz_grpc_port}" ]]; then
+ nz_grpc_port=5555
+ fi
+ else
+ nz_grpc_host=$1
+ nz_grpc_port=$2
+ nz_client_secret=$3
+ shift 3
+ if [ $# -gt 0 ]; then
+ args=" $*"
+ fi
+ fi
+
+ ${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
+
+ if [ $? -ne 0 ]; then
+ ${NZ_AGENT_PATH}/nezha-agent service uninstall >/dev/null 2>&1
+ ${NZ_AGENT_PATH}/nezha-agent service install -s "$nz_grpc_host:$nz_grpc_port" -p $nz_client_secret $args >/dev/null 2>&1
+ fi
+
+ echo -e "Agent configuration ${green} modified successfully, please wait for agent self-restart to take effect${plain}"
+
+ #if [[ $# == 0 ]]; then
+ # before_show_menu
+ #fi
+}
+
+show_agent_log() {
+ echo -e "> > View Agent Log"
+
+ tail -n 10 /var/log/nezha-agent.err.log
+
+ if [[ $# == 0 ]]; then
+ before_show_menu
+ fi
+}
+
+uninstall_agent() {
+ echo -e "> Uninstall Agent"
+
+ ${NZ_AGENT_PATH}/nezha-agent service uninstall
+
+ rm -rf $NZ_AGENT_PATH
+ clean_all
+
+ if [[ $# == 0 ]]; then
+ before_show_menu
+ fi
+}
+
+restart_agent() {
+ echo -e "> Restart Agent"
+
+ ${NZ_AGENT_PATH}/nezha-agent service restart
+
+ if [[ $# == 0 ]]; then
+ before_show_menu
+ fi
+}
+
+clean_all() {
+ if [ -z "$(ls -A ${NZ_BASE_PATH})" ]; then
+ rm -rf ${NZ_BASE_PATH}
+ fi
+}
+
+show_usage() {
+ echo "Nezha Agent Management Script Usage: "
+ echo "--------------------------------------------------------"
+ echo "./nezha.sh install_agent - Install Agent"
+ echo "./nezha.sh modify_agent_config - Modify Agent Configuration"
+ echo "./nezha.sh show_agent_log - View Agent Log"
+ echo "./nezha.sh uninstall_agent - Uninstall Agent"
+ echo "./nezha.sh restart_agent - Restart Agent"
+ echo "./nezha.sh update_script - Update Script"
+ echo "--------------------------------------------------------"
+}
+
+show_menu() {
+ echo -e "
+ ${green}Nezha Agent Management Script${plain} ${red}macOS${plain}
+ --- https://github.com/naiba/nezha ---
+ ${green}1.${plain} Install Agent
+ ${green}2.${plain} Modify Agent Configuration
+ ${green}3.${plain} View Agent Log
+ ${green}4.${plain} Uninstall Agent
+ ${green}5.${plain} Restart Agent
+ ————————————————-
+ ${green}0.${plain} Exit Script
+ "
+ echo && read -ep "Please enter [0-5]: " num
+ case "${num}" in
+ 0)
+ exit 0
+ ;;
+ 1)
+ install_agent
+ ;;
+ 2)
+ modify_agent_config
+ ;;
+ 3)
+ show_agent_log
+ ;;
+ 4)
+ uninstall_agent
+ ;;
+ 5)
+ restart_agent
+ ;;
+ *)
+ echo -e "${red}Please enter the correct number [0-5]${plain}"
+ ;;
+ esac
+}
+
+pre_check
+
+if [[ $# > 0 ]]; then
+ case $1 in
+ "install_agent")
+ shift
+ if [ $# -ge 3 ]; then
+ install_agent "$@"
+ else
+ install_agent 0
+ fi
+ ;;
+ "modify_agent_config")
+ modify_agent_config 0
+ ;;
+ "show_agent_log")
+ show_agent_log 0
+ ;;
+ "uninstall_agent")
+ uninstall_agent 0
+ ;;
+ "restart_agent")
+ restart_agent 0
+ ;;
+ *) show_usage ;;
+ esac
+else
+ show_menu
+fi
diff --git a/extras/install.ps1 b/extras/install.ps1
new file mode 100644
index 0000000..778383c
--- /dev/null
+++ b/extras/install.ps1
@@ -0,0 +1,87 @@
+#Get server and key
+param($server, $key, $tls)
+# Download latest release from github
+if($PSVersionTable.PSVersion.Major -lt 5){
+ Write-Host "Require PS >= 5,your PSVersion:"$PSVersionTable.PSVersion.Major -BackgroundColor DarkGreen -ForegroundColor White
+ Write-Host "Refer to the community article and install manually! https://nyko.me/2020/12/13/nezha-windows-client.html" -BackgroundColor DarkRed -ForegroundColor Green
+ exit
+}
+$agentrepo = "nezhahq/agent"
+# x86 or x64 or arm64
+if ([System.Environment]::Is64BitOperatingSystem) {
+ if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
+ $file = "nezha-agent_windows_arm64.zip"
+ } else {
+ $file = "nezha-agent_windows_amd64.zip"
+ }
+}
+else {
+ $file = "nezha-agent_windows_386.zip"
+}
+$agentreleases = "https://api.github.com/repos/$agentrepo/releases"
+#重复运行自动更新
+if (Test-Path "C:\nezha\nezha-agent.exe") {
+ Write-Host "Nezha monitoring already exists, delete and reinstall" -BackgroundColor DarkGreen -ForegroundColor White
+ C:\nezha\nezha-agent.exe service uninstall
+ Remove-Item "C:\nezha" -Recurse
+}
+#TLS/SSL
+Write-Host "Determining latest nezha release" -BackgroundColor DarkGreen -ForegroundColor White
+[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
+$agenttag = (Invoke-WebRequest -Uri $agentreleases -UseBasicParsing | ConvertFrom-Json)[0].tag_name
+if ([string]::IsNullOrWhiteSpace($agenttag)) {
+ $optionUrl = "https://fastly.jsdelivr.net/gh/nezhahq/agent/"
+ Try {
+ $response = Invoke-WebRequest -Uri $optionUrl -UseBasicParsing -TimeoutSec 10
+ if ($response.StatusCode -eq 200) {
+ $versiontext = $response.Content | findstr /c:"option.value"
+ $version = [regex]::Match($versiontext, "@(\d+\.\d+\.\d+)").Groups[1].Value
+ $agenttag = "v" + $version
+ }
+ } Catch {
+ $optionUrl = "https://gcore.jsdelivr.net/gh/nezhahq/agent/"
+ $response = Invoke-WebRequest -Uri $optionUrl -UseBasicParsing -TimeoutSec 10
+ if ($response.StatusCode -eq 200) {
+ $versiontext = $response.Content | findstr /c:"option.value"
+ $version = [regex]::Match($versiontext, "@(\d+\.\d+\.\d+)").Groups[1].Value
+ $agenttag = "v" + $version
+ }
+ }
+}
+#Region判断
+$ipapi = ""
+$region = "Unknown"
+foreach ($url in ("https://dash.cloudflare.com/cdn-cgi/trace","https://developers.cloudflare.com/cdn-cgi/trace","https://1.0.0.1/cdn-cgi/trace")) {
+ try {
+ $ipapi = Invoke-RestMethod -Uri $url -TimeoutSec 5 -UseBasicParsing
+ if ($ipapi -match "loc=(\w+)" ) {
+ $region = $Matches[1]
+ break
+ }
+ }
+ catch {
+ Write-Host "Error occurred while querying $url : $_"
+ }
+}
+echo $ipapi
+if($region -ne "CN"){
+$download = "https://github.com/$agentrepo/releases/download/$agenttag/$file"
+Write-Host "Location:$region,connect directly!" -BackgroundColor DarkRed -ForegroundColor Green
+}else{
+$download = "https://gitee.com/naibahq/agent/releases/download/$agenttag/$file"
+Write-Host "Location:CN,use mirror address" -BackgroundColor DarkRed -ForegroundColor Green
+}
+echo $download
+Invoke-WebRequest $download -OutFile "C:\nezha.zip"
+#解压
+Expand-Archive "C:\nezha.zip" -DestinationPath "C:\temp" -Force
+if (!(Test-Path "C:\nezha")) { New-Item -Path "C:\nezha" -type directory }
+#整理文件
+Move-Item -Path "C:\temp\nezha-agent.exe" -Destination "C:\nezha\nezha-agent.exe"
+#清理垃圾
+Remove-Item "C:\nezha.zip"
+Remove-Item "C:\temp" -Recurse
+#安装部分
+C:\nezha\nezha-agent.exe service install -s $server -p $key $tls
+#enjoy
+Write-Host "Enjoy It!" -BackgroundColor DarkGreen -ForegroundColor Red
diff --git a/go.mod b/go.mod
index 9bea57e..63a6168 100644
--- a/go.mod
+++ b/go.mod
@@ -1,5 +1,3 @@
module github.com/nezhahq/scripts
-go 1.21
-
-toolchain go1.23.2
+go 1.20
diff --git a/install.sh b/install.sh
index 6d0b62d..10473d2 100644
--- a/install.sh
+++ b/install.sh
@@ -125,7 +125,7 @@ pre_check() {
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
else
if [ -z "$CN" ]; then
- GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
+ GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/scripts"
GITHUB_URL="github.com"
Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" "
@@ -205,7 +205,7 @@ select_version() {
update_script() {
echo "> 更新脚本"
- curl -sL https://${GITHUB_RAW_URL}/script/install.sh -o /tmp/nezha.sh
+ curl -sL https://${GITHUB_RAW_URL}/install.sh -o /tmp/nezha.sh
mv -f /tmp/nezha.sh ./nezha.sh && chmod a+x ./nezha.sh
echo "3s后执行新脚本"
@@ -448,7 +448,7 @@ modify_dashboard_config() {
if [ "$IS_DOCKER_NEZHA" = 1 ]; then
if [ -n "$DOCKER_COMPOSE_COMMAND" ]; then
echo "正在下载 Docker 脚本"
- _cmd="wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1"
+ _cmd="wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/extras/docker-compose.yaml >/dev/null 2>&1"
if ! eval "$_cmd"; then
err "脚本获取失败,请检查本机能否链接 ${GITHUB_RAW_URL}"
return 0
@@ -459,7 +459,7 @@ modify_dashboard_config() {
fi
fi
- _cmd="wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1"
+ _cmd="wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/extras/config.yaml >/dev/null 2>&1"
if ! eval "$_cmd"; then
err "脚本获取失败,请检查本机能否链接 ${GITHUB_RAW_URL}"
return 0
@@ -522,9 +522,9 @@ modify_dashboard_config() {
if [ "$IS_DOCKER_NEZHA" = 0 ]; then
echo "正在下载服务文件"
if [ "$os_alpine" != 1 ]; then
- _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1"
+ _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/services/nezha-dashboard.service >/dev/null 2>&1"
else
- _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1"
+ _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/services/nezha-dashboard >/dev/null 2>&1"
if ! eval "$_download"; then
err "文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}"
return 0
diff --git a/install_en.sh b/install_en.sh
index 0383930..c1c76f2 100644
--- a/install_en.sh
+++ b/install_en.sh
@@ -125,7 +125,7 @@ pre_check() {
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
else
if [ -z "$CN" ]; then
- GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
+ GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/scripts"
GITHUB_URL="github.com"
Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" "
@@ -205,7 +205,7 @@ select_version() {
update_script() {
echo "> Update Script"
- curl -sL https://${GITHUB_RAW_URL}/script/install_en.sh -o /tmp/nezha.sh
+ curl -sL https://${GITHUB_RAW_URL}/install_en.sh -o /tmp/nezha.sh
mv -f /tmp/nezha.sh ./nezha.sh && chmod a+x ./nezha.sh
echo "Execute new script after 3s"
@@ -448,7 +448,7 @@ modify_dashboard_config() {
if [ "$IS_DOCKER_NEZHA" = 1 ]; then
if [ -n "$DOCKER_COMPOSE_COMMAND" ]; then
echo "Download Docker Script"
- _cmd="wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1"
+ _cmd="wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/extras/docker-compose.yaml >/dev/null 2>&1"
if ! eval "$_cmd"; then
err "Script failed to get, please check if the network can link ${GITHUB_RAW_URL}"
return 0
@@ -459,7 +459,7 @@ modify_dashboard_config() {
fi
fi
- _cmd="wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1"
+ _cmd="wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/extras/config.yaml >/dev/null 2>&1"
if ! eval "$_cmd"; then
err "Script failed to get, please check if the network can link ${GITHUB_RAW_URL}"
return 0
@@ -522,9 +522,9 @@ modify_dashboard_config() {
if [ "$IS_DOCKER_NEZHA" = 0 ]; then
echo "Downloading service file"
if [ "$os_alpine" != 1 ]; then
- _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1"
+ _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/services/nezha-dashboard.service >/dev/null 2>&1"
else
- _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1"
+ _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/services/nezha-dashboard >/dev/null 2>&1"
if ! eval "$_download"; then
err "File failed to get, please check if the network can link ${GITHUB_RAW_URL}"
return 0
diff --git a/services/nezha-dashboard b/services/nezha-dashboard
new file mode 100755
index 0000000..ebd5e1a
--- /dev/null
+++ b/services/nezha-dashboard
@@ -0,0 +1,18 @@
+#!/sbin/openrc-run
+supervisor=supervise-daemon
+name=nezha-dashboard
+output_log=/var/log/${name}.log
+error_log=/var/log/${name}.err
+pidfile="/run/${RC_SVCNAME}.pid"
+command="/opt/nezha/dashboard/app"
+command_args=""
+command_background=true
+directory="/opt/nezha/dashboard"
+
+depend() {
+ need net
+}
+
+start_pre() {
+ checkpath -f -m 0644 -o root:root "/var/log/${name}.log"
+}
diff --git a/services/nezha-dashboard.service b/services/nezha-dashboard.service
new file mode 100644
index 0000000..f20a079
--- /dev/null
+++ b/services/nezha-dashboard.service
@@ -0,0 +1,30 @@
+[Unit]
+Description=Nezha Dashboard
+After=syslog.target
+After=network.target
+After=mariadb.service mysqld.service postgresql.service memcached.service redis.service
+
+[Service]
+# Modify these two values and uncomment them if you have
+# repos with lots of files and get an HTTP error 500 because
+# of that
+###
+#LimitMEMLOCK=infinity
+#LimitNOFILE=65535
+Type=simple
+#User=root
+#Group=root
+WorkingDirectory=/opt/nezha/dashboard/
+ExecStart=/opt/nezha/dashboard/app
+Restart=always
+#Environment=DEBUG=true
+
+# Some distributions may not support these hardening directives. If you cannot start the service due
+# to an unknown option, comment out the ones not supported by your version of systemd.
+ProtectSystem=full
+PrivateDevices=yes
+PrivateTmp=yes
+NoNewPrivileges=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/template.sh b/template.sh
index 8bedd70..24d925d 100644
--- a/template.sh
+++ b/template.sh
@@ -125,7 +125,7 @@ pre_check() {
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
else
if [ -z "$CN" ]; then
- GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
+ GITHUB_RAW_URL="raw.githubusercontent.com/nezhahq/scripts"
GITHUB_URL="github.com"
Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" "
@@ -205,7 +205,7 @@ select_version() {
update_script() {
echo "> {{.UpdateScript}}"
- curl -sL https://${GITHUB_RAW_URL}/script/{{.script}} -o /tmp/nezha.sh
+ curl -sL https://${GITHUB_RAW_URL}/{{.script}} -o /tmp/nezha.sh
mv -f /tmp/nezha.sh ./nezha.sh && chmod a+x ./nezha.sh
echo "{{.ExecuteScriptInfo}}"
@@ -448,7 +448,7 @@ modify_dashboard_config() {
if [ "$IS_DOCKER_NEZHA" = 1 ]; then
if [ -n "$DOCKER_COMPOSE_COMMAND" ]; then
echo "{{.DownloadDockerScript}}"
- _cmd="wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/script/docker-compose.yaml >/dev/null 2>&1"
+ _cmd="wget -t 2 -T 60 -O /tmp/nezha-docker-compose.yaml https://${GITHUB_RAW_URL}/extras/docker-compose.yaml >/dev/null 2>&1"
if ! eval "$_cmd"; then
err "{{.ErrorFetchScript}} ${GITHUB_RAW_URL}"
return 0
@@ -459,7 +459,7 @@ modify_dashboard_config() {
fi
fi
- _cmd="wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1"
+ _cmd="wget -t 2 -T 60 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/extras/config.yaml >/dev/null 2>&1"
if ! eval "$_cmd"; then
err "{{.ErrorFetchScript}} ${GITHUB_RAW_URL}"
return 0
@@ -522,9 +522,9 @@ modify_dashboard_config() {
if [ "$IS_DOCKER_NEZHA" = 0 ]; then
echo "{{.DownloadServiceScript}}"
if [ "$os_alpine" != 1 ]; then
- _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1"
+ _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/services/nezha-dashboard.service >/dev/null 2>&1"
else
- _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1"
+ _download="sudo wget -t 2 -T 60 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/services/nezha-dashboard >/dev/null 2>&1"
if ! eval "$_download"; then
err "{{.ErrorFetchFile}} ${GITHUB_RAW_URL}"
return 0