replace daocloud with fgit (#315)

* Update add custom mirror

* Update add custom mirror

* bump install version
This commit is contained in:
黑歌 2024-01-18 13:34:58 +08:00 committed by GitHub
parent 11bcc47d49
commit 8539fb6559
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 574 additions and 541 deletions

View File

@ -4,7 +4,7 @@
<br> <br>
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small> <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
<br><br> <br><br>
<img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&style=for-the-badge&logo=github&label=Dashboard">&nbsp;<img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.15.4-brightgreen?style=for-the-badge&logo=linux"> <img alt="GitHub release (with filter)" src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&style=for-the-badge&logo=github&label=Dashboard">&nbsp;<img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github">&nbsp;<img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge">&nbsp;<img src="https://img.shields.io/badge/Installer-v0.15.5-brightgreen?style=for-the-badge&logo=linux">
<br> <br>
<br> <br>
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p> <p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>

View File

@ -14,7 +14,7 @@ NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent" NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service" NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard" NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
NZ_VERSION="v0.15.4" NZ_VERSION="v0.15.5"
red='\033[0;31m' red='\033[0;31m'
green='\033[0;32m' green='\033[0;32m'
@ -50,7 +50,7 @@ pre_check() {
if [[ -z "${CN}" ]]; then if [[ -z "${CN}" ]]; then
if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
echo "根据ipapi.co提供的信息当前IP可能在中国" echo "根据ipapi.co提供的信息当前IP可能在中国"
read -e -r -p "是否选用中国镜像完成安装? [Y/n] " input read -e -r -p "是否选用中国镜像完成安装? [Y/n] (自定义镜像输入 3):" input
case $input in case $input in
[yY][eE][sS] | [yY]) [yY][eE][sS] | [yY])
echo "使用中国镜像" echo "使用中国镜像"
@ -60,6 +60,17 @@ pre_check() {
[nN][oO] | [nN]) [nN][oO] | [nN])
echo "不使用中国镜像" echo "不使用中国镜像"
;; ;;
[3])
echo "使用自定义镜像"
read -e -r -p "请输入自定义镜像 (例如:dn-dao-github-mirror.daocloud.io),留空为不使用: " input
case $input in
*)
CUSTOM_MIRROR=$input
;;
esac
;;
*) *)
echo "使用中国镜像" echo "使用中国镜像"
CN=true CN=true
@ -68,21 +79,28 @@ pre_check() {
fi fi
fi fi
if [[ -n "${CUSTOM_MIRROR}" ]]; then
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
GITHUB_URL=$CUSTOM_MIRROR
Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" -s docker --mirror Aliyun"
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
else
if [[ -z "${CN}" ]]; then if [[ -z "${CN}" ]]; then
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master" GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
GITHUB_URL="github.com" GITHUB_URL="github.com"
Get_Docker_URL="get.docker.com" Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" " Get_Docker_Argu=" "
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard" Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
GITHUB_RELEASE_URL="github.com/naiba/nezha/releases/latest/download"
else else
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master" GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
GITHUB_URL="dn-dao-github-mirror.daocloud.io" GITHUB_URL="hub.fgit.cf"
Get_Docker_URL="get.docker.com" Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" -s docker --mirror Aliyun" Get_Docker_Argu=" -s docker --mirror Aliyun"
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard" Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
GITHUB_RELEASE_URL="hub.fgit.cf/naiba/nezha/releases/latest/download"
fi fi
fi
} }
confirm() { confirm() {
@ -130,7 +148,7 @@ install_base() {
(install_soft curl wget git unzip) (install_soft curl wget git unzip)
} }
install_arch(){ install_arch() {
echo -e "${green}提示: ${plain} Arch安装libselinux需添加nezha-agent用户安装完会自动删除建议手动检查一次\n" echo -e "${green}提示: ${plain} Arch安装libselinux需添加nezha-agent用户安装完会自动删除建议手动检查一次\n"
read -e -r -p "是否安装libselinux? [Y/n] " input read -e -r -p "是否安装libselinux? [Y/n] " input
case $input in case $input in
@ -141,7 +159,7 @@ install_arch(){
cd /tmp; git clone https://aur.archlinux.org/libsepol.git; cd libsepol; makepkg -si --noconfirm --asdeps; cd ..; cd /tmp; git clone https://aur.archlinux.org/libsepol.git; cd libsepol; makepkg -si --noconfirm --asdeps; cd ..;
git clone https://aur.archlinux.org/libselinux.git; cd libselinux; makepkg -si --noconfirm; cd ..; git clone https://aur.archlinux.org/libselinux.git; cd libselinux; makepkg -si --noconfirm; cd ..;
rm -rf libsepol libselinux' rm -rf libsepol libselinux'
sed -i '/nezha-agent/d' /etc/sudoers && sleep 30s && killall -u nezha-agent&&userdel nezha-agent sed -i '/nezha-agent/d' /etc/sudoers && sleep 30s && killall -u nezha-agent && userdel nezha-agent
echo -e "${red}提示: ${plain}已删除用户nezha-agent请务必手动核查一遍\n" echo -e "${red}提示: ${plain}已删除用户nezha-agent请务必手动核查一遍\n"
;; ;;
[nN][oO] | [nN]) [nN][oO] | [nN])
@ -249,11 +267,11 @@ install_dashboard_standalone() {
fi fi
} }
selinux(){ selinux() {
#判断当前的状态 #判断当前的状态
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
getenforce | grep '[Ee]nfor' getenforce | grep '[Ee]nfor'
if [ $? -eq 0 ];then if [ $? -eq 0 ]; then
echo -e "SELinux是开启状态正在关闭" echo -e "SELinux是开启状态正在关闭"
setenforce 0 &>/dev/null setenforce 0 &>/dev/null
find_key="SELINUX=" find_key="SELINUX="
@ -314,7 +332,7 @@ install_agent() {
modify_agent_config() { modify_agent_config() {
echo -e "> 修改Agent配置" echo -e "> 修改Agent配置"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
wget -t 2 -T 10 -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/script/nezha-agent.service >/dev/null 2>&1 wget -t 2 -T 10 -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/script/nezha-agent.service >/dev/null 2>&1
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}" echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
@ -335,7 +353,7 @@ modify_agent_config() {
read -ep "请输入面板RPC端口 (默认值 5555): " nz_grpc_port && read -ep "请输入面板RPC端口 (默认值 5555): " nz_grpc_port &&
read -ep "请输入Agent 密钥: " nz_client_secret && read -ep "请输入Agent 密钥: " nz_client_secret &&
read -ep "是否启用针对 gRPC 端口的 SSL/TLS加密 (--tls),需要请按 [y],默认是不需要,不理解用户可回车跳过: " nz_grpc_proxy read -ep "是否启用针对 gRPC 端口的 SSL/TLS加密 (--tls),需要请按 [y],默认是不需要,不理解用户可回车跳过: " nz_grpc_proxy
grep -qiw 'Y' <<< "${nz_grpc_proxy}" && args='--tls' grep -qiw 'Y' <<<"${nz_grpc_proxy}" && args='--tls'
if [[ -z "${nz_grpc_host}" || -z "${nz_client_secret}" ]]; then if [[ -z "${nz_grpc_host}" || -z "${nz_client_secret}" ]]; then
echo -e "${red}所有选项都不能为空${plain}" echo -e "${red}所有选项都不能为空${plain}"
before_show_menu before_show_menu
@ -354,7 +372,7 @@ modify_agent_config() {
fi fi
fi fi
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICE} sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICE}
sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICE} sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICE}
sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICE} sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICE}
@ -368,7 +386,7 @@ modify_agent_config() {
echo -e "Agent配置 ${green}修改成功,请稍等重启生效${plain}" echo -e "Agent配置 ${green}修改成功,请稍等重启生效${plain}"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl daemon-reload systemctl daemon-reload
systemctl enable nezha-agent systemctl enable nezha-agent
systemctl restart nezha-agent systemctl restart nezha-agent
@ -499,7 +517,7 @@ modify_dashboard_config_standalone() {
echo -e "正在下载服务文件" echo -e "正在下载服务文件"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1 wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
else else
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1 wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
@ -510,7 +528,6 @@ modify_dashboard_config_standalone() {
fi fi
fi fi
echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}" echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}"
restart_and_update_standalone restart_and_update_standalone
@ -559,9 +576,9 @@ restart_and_update_standalone() {
rc-service nezha-dashboard stop rc-service nezha-dashboard stop
fi fi
wget -qO app.zip $GITHUB_RELEASE_URL/dashboard-linux-$os_arch.zip >/dev/null 2>&1 && unzip -qq app.zip && mv dist/dashboard-linux-$os_arch app && rm -r app.zip dist wget -qO app.zip https://${GITHUB_URL}/naiba/nezha/releases/latest/download/dashboard-linux-$os_arch.zip >/dev/null 2>&1 && unzip -qq app.zip && mv dist/dashboard-linux-$os_arch app && rm -r app.zip dist
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl daemon-reload systemctl daemon-reload
systemctl enable nezha-dashboard systemctl enable nezha-dashboard
systemctl restart nezha-dashboard systemctl restart nezha-dashboard
@ -704,8 +721,8 @@ uninstall_dashboard() {
fi fi
rm -rf $NZ_DASHBOARD_PATH rm -rf $NZ_DASHBOARD_PATH
docker rmi -f ghcr.io/naiba/nezha-dashboard > /dev/null 2>&1 docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard > /dev/null 2>&1 docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
clean_all clean_all
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@ -754,7 +771,7 @@ show_agent_log() {
uninstall_agent() { uninstall_agent() {
echo -e "> 卸载Agent" echo -e "> 卸载Agent"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl disable nezha-agent.service systemctl disable nezha-agent.service
systemctl stop nezha-agent.service systemctl stop nezha-agent.service
rm -rf $NZ_AGENT_SERVICE rm -rf $NZ_AGENT_SERVICE
@ -776,7 +793,7 @@ uninstall_agent() {
restart_agent() { restart_agent() {
echo -e "> 重启Agent" echo -e "> 重启Agent"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl restart nezha-agent.service systemctl restart nezha-agent.service
else else
rc-service nezha-agent restart rc-service nezha-agent restart

View File

@ -14,7 +14,7 @@ NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent" NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service" NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard" NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
NZ_VERSION="v0.15.4" NZ_VERSION="v0.15.5"
red='\033[0;31m' red='\033[0;31m'
green='\033[0;32m' green='\033[0;32m'
@ -50,7 +50,7 @@ pre_check() {
if [[ -z "${CN}" ]]; then if [[ -z "${CN}" ]]; then
if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
echo "According to the information provided by ipapi.co, the current IP may be in China" echo "According to the information provided by ipapi.co, the current IP may be in China"
read -e -r -p "Is the installation done with a Chinese Mirror? [Y/n] " input read -e -r -p "Is the installation done with a Chinese Mirror? [Y/n] (Custom Mirror Input 3):" input
case $input in case $input in
[yY][eE][sS] | [yY]) [yY][eE][sS] | [yY])
echo "Use Chinese Mirror" echo "Use Chinese Mirror"
@ -60,6 +60,17 @@ pre_check() {
[nN][oO] | [nN]) [nN][oO] | [nN])
echo "No Use Chinese Mirror" 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" echo "No Use Chinese Mirror"
;; ;;
@ -67,20 +78,26 @@ pre_check() {
fi fi
fi fi
if [[ -n "${CUSTOM_MIRROR}" ]]; then
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
GITHUB_URL=$CUSTOM_MIRROR
Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" -s docker --mirror Aliyun"
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
else
if [[ -z "${CN}" ]]; then if [[ -z "${CN}" ]]; then
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master" GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
GITHUB_URL="github.com" GITHUB_URL="github.com"
Get_Docker_URL="get.docker.com" Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" " Get_Docker_Argu=" "
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard" Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
GITHUB_RELEASE_URL="github.com/naiba/nezha/releases/latest/download"
else else
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master" GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
GITHUB_URL="dn-dao-github-mirror.daocloud.io" GITHUB_URL="hub.fgit.cf"
Get_Docker_URL="get.docker.com" Get_Docker_URL="get.docker.com"
Get_Docker_Argu=" -s docker --mirror Aliyun" Get_Docker_Argu=" -s docker --mirror Aliyun"
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard" Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
GITHUB_RELEASE_URL="hub.fgit.cf/naiba/nezha/releases/latest/download" fi
fi fi
} }
@ -129,7 +146,7 @@ install_base() {
(install_soft curl wget git unzip tzdata) (install_soft curl wget git unzip tzdata)
} }
install_arch(){ install_arch() {
echo -e "${green}Info: ${plain} Archlinux needs to add nezha-agent user to install libselinux. It will be deleted automatically after installation. It is recommended to check manually\n" echo -e "${green}Info: ${plain} Archlinux needs to add nezha-agent user to install libselinux. It will be deleted automatically after installation. It is recommended to check manually\n"
read -e -r -p "Do you need to install libselinux? [Y/n] " input read -e -r -p "Do you need to install libselinux? [Y/n] " input
case $input in case $input in
@ -140,7 +157,7 @@ install_arch(){
cd /tmp; git clone https://aur.archlinux.org/libsepol.git; cd libsepol; makepkg -si --noconfirm --asdeps; cd ..; cd /tmp; git clone https://aur.archlinux.org/libsepol.git; cd libsepol; makepkg -si --noconfirm --asdeps; cd ..;
git clone https://aur.archlinux.org/libselinux.git; cd libselinux; makepkg -si --noconfirm; cd ..; git clone https://aur.archlinux.org/libselinux.git; cd libselinux; makepkg -si --noconfirm; cd ..;
rm -rf libsepol libselinux' rm -rf libsepol libselinux'
sed -i '/nezha-agent/d' /etc/sudoers && sleep 30s && killall -u nezha-agent&&userdel nezha-agent sed -i '/nezha-agent/d' /etc/sudoers && sleep 30s && killall -u nezha-agent && userdel nezha-agent
echo -e "${red}Info: ${plain}user nezha-agent has been deleted, Be sure to check it manually!\n" echo -e "${red}Info: ${plain}user nezha-agent has been deleted, Be sure to check it manually!\n"
;; ;;
[nN][oO] | [nN]) [nN][oO] | [nN])
@ -247,11 +264,11 @@ install_dashboard_standalone() {
fi fi
} }
selinux(){ selinux() {
#Check SELinux #Check SELinux
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
getenforce | grep '[Ee]nfor' getenforce | grep '[Ee]nfor'
if [ $? -eq 0 ];then if [ $? -eq 0 ]; then
echo -e "SELinux runningclosing now" echo -e "SELinux runningclosing now"
setenforce 0 &>/dev/null setenforce 0 &>/dev/null
find_key="SELINUX=" find_key="SELINUX="
@ -312,7 +329,7 @@ install_agent() {
modify_agent_config() { modify_agent_config() {
echo -e "> Modify Agent Configuration" echo -e "> Modify Agent Configuration"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
wget -t 2 -T 10 -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/script/nezha-agent.service >/dev/null 2>&1 wget -t 2 -T 10 -O $NZ_AGENT_SERVICE https://${GITHUB_RAW_URL}/script/nezha-agent.service >/dev/null 2>&1
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
echo -e "${red}Fail to download service, please check if the network can link ${GITHUB_RAW_URL}${plain}" echo -e "${red}Fail to download service, please check if the network can link ${GITHUB_RAW_URL}${plain}"
@ -333,7 +350,7 @@ modify_agent_config() {
read -ep "Please enter the panel RPC port (default 5555): " nz_grpc_port && 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 "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 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' grep -qiw 'Y' <<<"${nz_grpc_proxy}" && args='--tls'
if [[ -z "${nz_grpc_host}" || -z "${nz_client_secret}" ]]; then if [[ -z "${nz_grpc_host}" || -z "${nz_client_secret}" ]]; then
echo -e "${red}All options cannot be empty${plain}" echo -e "${red}All options cannot be empty${plain}"
before_show_menu before_show_menu
@ -352,7 +369,7 @@ modify_agent_config() {
fi fi
fi fi
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICE} sed -i "s/nz_grpc_host/${nz_grpc_host}/" ${NZ_AGENT_SERVICE}
sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICE} sed -i "s/nz_grpc_port/${nz_grpc_port}/" ${NZ_AGENT_SERVICE}
sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICE} sed -i "s/nz_client_secret/${nz_client_secret}/" ${NZ_AGENT_SERVICE}
@ -366,7 +383,7 @@ modify_agent_config() {
echo -e "Agent configuration ${green} modified successfully, please wait for agent self-restart to take effect${plain}" echo -e "Agent configuration ${green} modified successfully, please wait for agent self-restart to take effect${plain}"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl daemon-reload systemctl daemon-reload
systemctl enable nezha-agent systemctl enable nezha-agent
systemctl restart nezha-agent systemctl restart nezha-agent
@ -497,7 +514,7 @@ modify_dashboard_config_standalone() {
echo -e "Downloading service file" echo -e "Downloading service file"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1 wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICE https://${GITHUB_RAW_URL}/script/nezha-dashboard.service >/dev/null 2>&1
else else
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1 wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
@ -508,7 +525,6 @@ modify_dashboard_config_standalone() {
fi fi
fi fi
echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}" echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
restart_and_update_standalone restart_and_update_standalone
@ -557,9 +573,9 @@ restart_and_update_standalone() {
rc-service nezha-dashboard stop rc-service nezha-dashboard stop
fi fi
wget -qO app.zip $GITHUB_RELEASE_URL/dashboard-linux-$os_arch.zip >/dev/null 2>&1 && unzip -qq app.zip && mv dist/dashboard-linux-$os_arch app && rm -r app.zip dist wget -qO app.zip https://${GITHUB_URL}/naiba/nezha/releases/latest/download/dashboard-linux-$os_arch.zip >/dev/null 2>&1 && unzip -qq app.zip && mv dist/dashboard-linux-$os_arch app && rm -r app.zip dist
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl daemon-reload systemctl daemon-reload
systemctl enable nezha-dashboard systemctl enable nezha-dashboard
systemctl restart nezha-dashboard systemctl restart nezha-dashboard
@ -702,8 +718,8 @@ uninstall_dashboard() {
fi fi
rm -rf $NZ_DASHBOARD_PATH rm -rf $NZ_DASHBOARD_PATH
docker rmi -f ghcr.io/naiba/nezha-dashboard > /dev/null 2>&1 docker rmi -f ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard > /dev/null 2>&1 docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
clean_all clean_all
if [[ $# == 0 ]]; then if [[ $# == 0 ]]; then
@ -752,7 +768,7 @@ show_agent_log() {
uninstall_agent() { uninstall_agent() {
echo -e "> Uninstall Agent" echo -e "> Uninstall Agent"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl disable nezha-agent.service systemctl disable nezha-agent.service
systemctl stop nezha-agent.service systemctl stop nezha-agent.service
rm -rf $NZ_AGENT_SERVICE rm -rf $NZ_AGENT_SERVICE
@ -774,7 +790,7 @@ uninstall_agent() {
restart_agent() { restart_agent() {
echo -e "> Restart Agent" echo -e "> Restart Agent"
if [ "$os_alpine" != 1 ];then if [ "$os_alpine" != 1 ]; then
systemctl restart nezha-agent.service systemctl restart nezha-agent.service
else else
rc-service nezha-agent restart rc-service nezha-agent restart