mirror of
https://github.com/nezhahq/nezha.git
synced 2025-01-22 12:48:14 -05:00
replace daocloud with fgit (#315)
* Update add custom mirror * Update add custom mirror * bump install version
This commit is contained in:
parent
11bcc47d49
commit
8539fb6559
@ -4,7 +4,7 @@
|
||||
<br>
|
||||
<small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
|
||||
<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"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <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"> <img src="https://img.shields.io/github/v/release/nezhahq/agent?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/actions/workflow/status/nezhahq/agent/agent.yml?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.15.5-brightgreen?style=for-the-badge&logo=linux">
|
||||
<br>
|
||||
<br>
|
||||
<p>:trollface: <b>Nezha Monitoring: Self-hostable, lightweight, servers and websites monitoring and O&M tool.</b></p>
|
||||
|
@ -14,7 +14,7 @@ NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
|
||||
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
|
||||
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
||||
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
||||
NZ_VERSION="v0.15.4"
|
||||
NZ_VERSION="v0.15.5"
|
||||
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
@ -34,15 +34,15 @@ pre_check() {
|
||||
## os_arch
|
||||
if [[ $(uname -m | grep 'x86_64') != "" ]]; then
|
||||
os_arch="amd64"
|
||||
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
|
||||
os_arch="386"
|
||||
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
|
||||
os_arch="arm64"
|
||||
elif [[ $(uname -m | grep 'arm') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'arm') != "" ]]; then
|
||||
os_arch="arm"
|
||||
elif [[ $(uname -m | grep 's390x') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 's390x') != "" ]]; then
|
||||
os_arch="s390x"
|
||||
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
|
||||
os_arch="riscv64"
|
||||
fi
|
||||
|
||||
@ -50,39 +50,57 @@ pre_check() {
|
||||
if [[ -z "${CN}" ]]; then
|
||||
if [[ $(curl -m 10 -s https://ipapi.co/json | grep 'China') != "" ]]; then
|
||||
echo "根据ipapi.co提供的信息,当前IP可能在中国"
|
||||
read -e -r -p "是否选用中国镜像完成安装? [Y/n] " input
|
||||
read -e -r -p "是否选用中国镜像完成安装? [Y/n] (自定义镜像输入 3):" input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
|
||||
[nN][oO] | [nN])
|
||||
echo "不使用中国镜像"
|
||||
[nN][oO] | [nN])
|
||||
echo "不使用中国镜像"
|
||||
;;
|
||||
|
||||
[3])
|
||||
echo "使用自定义镜像"
|
||||
read -e -r -p "请输入自定义镜像 (例如:dn-dao-github-mirror.daocloud.io),留空为不使用: " input
|
||||
case $input in
|
||||
*)
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
CUSTOM_MIRROR=$input
|
||||
;;
|
||||
esac
|
||||
|
||||
;;
|
||||
*)
|
||||
echo "使用中国镜像"
|
||||
CN=true
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "${CN}" ]]; then
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
|
||||
GITHUB_URL="github.com"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" "
|
||||
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
|
||||
GITHUB_RELEASE_URL="github.com/naiba/nezha/releases/latest/download"
|
||||
else
|
||||
if [[ -n "${CUSTOM_MIRROR}" ]]; then
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL="dn-dao-github-mirror.daocloud.io"
|
||||
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"
|
||||
GITHUB_RELEASE_URL="hub.fgit.cf/naiba/nezha/releases/latest/download"
|
||||
else
|
||||
if [[ -z "${CN}" ]]; then
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
|
||||
GITHUB_URL="github.com"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" "
|
||||
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
|
||||
else
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL="hub.fgit.cf"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" -s docker --mirror Aliyun"
|
||||
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
confirm() {
|
||||
@ -127,39 +145,39 @@ before_show_menu() {
|
||||
|
||||
install_base() {
|
||||
(command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1 && command -v getenforce >/dev/null 2>&1) ||
|
||||
(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"
|
||||
read -e -r -p "是否安装libselinux? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
useradd -m nezha-agent
|
||||
sed -i "$ a\nezha-agent ALL=(ALL ) NOPASSWD:ALL" /etc/sudoers
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys BE22091E3EF62275;
|
||||
[yY][eE][sS] | [yY])
|
||||
useradd -m nezha-agent
|
||||
sed -i "$ a\nezha-agent ALL=(ALL ) NOPASSWD:ALL" /etc/sudoers
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys BE22091E3EF62275;
|
||||
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 ..;
|
||||
rm -rf libsepol libselinux'
|
||||
sed -i '/nezha-agent/d' /etc/sudoers && sleep 30s && killall -u nezha-agent&&userdel nezha-agent
|
||||
echo -e "${red}提示: ${plain}已删除用户nezha-agent,请务必手动核查一遍!\n"
|
||||
sed -i '/nezha-agent/d' /etc/sudoers && sleep 30s && killall -u nezha-agent && userdel nezha-agent
|
||||
echo -e "${red}提示: ${plain}已删除用户nezha-agent,请务必手动核查一遍!\n"
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "不安装libselinux"
|
||||
[nN][oO] | [nN])
|
||||
echo "不安装libselinux"
|
||||
;;
|
||||
*)
|
||||
echo "不安装libselinux"
|
||||
exit 0
|
||||
*)
|
||||
echo "不安装libselinux"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_soft() {
|
||||
(command -v yum >/dev/null 2>&1 && yum makecache && yum install $* selinux-policy -y) ||
|
||||
(command -v apt >/dev/null 2>&1 && apt update && apt install $* selinux-utils -y) ||
|
||||
(command -v pacman >/dev/null 2>&1 && pacman -Syu $* base-devel --noconfirm && install_arch) ||
|
||||
(command -v apt-get >/dev/null 2>&1 && apt-get update && apt-get install $* selinux-utils -y) ||
|
||||
(command -v apk >/dev/null 2>&1 && apk update && apk add $* -f)
|
||||
(command -v apt >/dev/null 2>&1 && apt update && apt install $* selinux-utils -y) ||
|
||||
(command -v pacman >/dev/null 2>&1 && pacman -Syu $* base-devel --noconfirm && install_arch) ||
|
||||
(command -v apt-get >/dev/null 2>&1 && apt-get update && apt-get install $* selinux-utils -y) ||
|
||||
(command -v apk >/dev/null 2>&1 && apk update && apk add $* -f)
|
||||
}
|
||||
|
||||
install_dashboard() {
|
||||
@ -174,16 +192,16 @@ install_dashboard() {
|
||||
echo "您可能已经安装过面板端,重复安装会覆盖数据,请注意备份。"
|
||||
read -e -r -p "是否退出安装? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "继续安装"
|
||||
[nN][oO] | [nN])
|
||||
echo "继续安装"
|
||||
;;
|
||||
*)
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
*)
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@ -212,9 +230,9 @@ install_dashboard() {
|
||||
|
||||
install_dashboard_standalone() {
|
||||
install_base
|
||||
|
||||
|
||||
echo -e "> 安装面板"
|
||||
|
||||
|
||||
# 哪吒监控文件夹
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/app" ]; then
|
||||
mkdir -p $NZ_DASHBOARD_PATH
|
||||
@ -222,38 +240,38 @@ install_dashboard_standalone() {
|
||||
echo "您可能已经安装过面板端,重复安装会覆盖数据,请注意备份。"
|
||||
read -e -r -p "是否退出安装? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "继续安装"
|
||||
[nN][oO] | [nN])
|
||||
echo "继续安装"
|
||||
;;
|
||||
*)
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
*)
|
||||
echo "退出安装"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" ] || [ ! -d "${NZ_DASHBOARD_PATH}/resource/static/custom" ]; then
|
||||
mkdir -p "${NZ_DASHBOARD_PATH}/resource/template/theme-custom" "${NZ_DASHBOARD_PATH}/resource/static/custom" >/dev/null 2>&1
|
||||
fi
|
||||
|
||||
chmod 777 -R $NZ_DASHBOARD_PATH
|
||||
|
||||
|
||||
modify_dashboard_config_standalone 0
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
selinux(){
|
||||
selinux() {
|
||||
#判断当前的状态
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
getenforce | grep '[Ee]nfor'
|
||||
if [ $? -eq 0 ];then
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "SELinux是开启状态,正在关闭!"
|
||||
setenforce 0 &>/dev/null
|
||||
find_key="SELINUX="
|
||||
@ -297,8 +315,8 @@ install_agent() {
|
||||
fi
|
||||
|
||||
unzip -qo nezha-agent_linux_${os_arch}.zip &&
|
||||
mv nezha-agent $NZ_AGENT_PATH &&
|
||||
rm -rf nezha-agent_linux_${os_arch}.zip README.md
|
||||
mv nezha-agent $NZ_AGENT_PATH &&
|
||||
rm -rf nezha-agent_linux_${os_arch}.zip README.md
|
||||
|
||||
if [ $# -ge 3 ]; then
|
||||
modify_agent_config "$@"
|
||||
@ -314,7 +332,7 @@ install_agent() {
|
||||
modify_agent_config() {
|
||||
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
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}文件下载失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
@ -331,11 +349,11 @@ modify_agent_config() {
|
||||
|
||||
if [ $# -lt 3 ]; then
|
||||
echo "请先在管理面板上添加Agent,记录下密钥" &&
|
||||
read -ep "请输入一个解析到面板所在IP的域名(不可套CDN): " nz_grpc_host &&
|
||||
read -ep "请输入面板RPC端口 (默认值 5555): " nz_grpc_port &&
|
||||
read -ep "请输入Agent 密钥: " nz_client_secret &&
|
||||
read -ep "是否启用针对 gRPC 端口的 SSL/TLS加密 (--tls),需要请按 [y],默认是不需要,不理解用户可回车跳过: " nz_grpc_proxy
|
||||
grep -qiw 'Y' <<< "${nz_grpc_proxy}" && args='--tls'
|
||||
read -ep "请输入一个解析到面板所在IP的域名(不可套CDN): " nz_grpc_host &&
|
||||
read -ep "请输入面板RPC端口 (默认值 5555): " nz_grpc_port &&
|
||||
read -ep "请输入Agent 密钥: " nz_client_secret &&
|
||||
read -ep "是否启用针对 gRPC 端口的 SSL/TLS加密 (--tls),需要请按 [y],默认是不需要,不理解用户可回车跳过: " nz_grpc_proxy
|
||||
grep -qiw 'Y' <<<"${nz_grpc_proxy}" && args='--tls'
|
||||
if [[ -z "${nz_grpc_host}" || -z "${nz_client_secret}" ]]; then
|
||||
echo -e "${red}所有选项都不能为空${plain}"
|
||||
before_show_menu
|
||||
@ -354,7 +372,7 @@ modify_agent_config() {
|
||||
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_port/${nz_grpc_port}/" ${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}"
|
||||
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable nezha-agent
|
||||
systemctl restart nezha-agent
|
||||
@ -399,14 +417,14 @@ modify_dashboard_config() {
|
||||
fi
|
||||
|
||||
echo "关于 GitHub Oauth2 应用:在 https://github.com/settings/developers 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
|
||||
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
|
||||
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
|
||||
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
|
||||
read -ep "请输入站点标题: " nz_site_title &&
|
||||
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
|
||||
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
|
||||
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
|
||||
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
|
||||
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
|
||||
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
|
||||
read -ep "请输入站点标题: " nz_site_title &&
|
||||
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
|
||||
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
|
||||
|
||||
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
|
||||
echo -e "${red}所有选项都不能为空${plain}"
|
||||
@ -450,31 +468,31 @@ modify_dashboard_config() {
|
||||
|
||||
modify_dashboard_config_standalone() {
|
||||
echo -e "> 修改面板配置"
|
||||
|
||||
|
||||
echo -e "正在下载配置模板"
|
||||
|
||||
|
||||
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}下载文件失败,请检查本机能否连接 ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
echo "关于 GitHub Oauth2 应用:在 https://github.com/settings/developers 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
|
||||
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
|
||||
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
|
||||
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
|
||||
read -ep "请输入站点标题: " nz_site_title &&
|
||||
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
|
||||
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
|
||||
|
||||
echo "关于 Gitee Oauth2 应用:在 https://gitee.com/oauth/applications 创建,无需审核,Callback 填 http(s)://域名或IP/oauth2/callback" &&
|
||||
read -ep "请输入 OAuth2 提供商(github/gitlab/jihulab/gitee,默认 github): " nz_oauth2_type &&
|
||||
read -ep "请输入 Oauth2 应用的 Client ID: " nz_github_oauth_client_id &&
|
||||
read -ep "请输入 Oauth2 应用的 Client Secret: " nz_github_oauth_client_secret &&
|
||||
read -ep "请输入 GitHub/Gitee 登录名作为管理员,多个以逗号隔开: " nz_admin_logins &&
|
||||
read -ep "请输入站点标题: " nz_site_title &&
|
||||
read -ep "请输入站点访问端口: (默认 8008)" nz_site_port &&
|
||||
read -ep "请输入用于 Agent 接入的 RPC 端口: (默认 5555)" nz_grpc_port
|
||||
|
||||
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
|
||||
echo -e "${red}所有选项都不能为空${plain}"
|
||||
before_show_menu
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "${nz_site_port}" ]]; then
|
||||
nz_site_port=8008
|
||||
fi
|
||||
@ -484,7 +502,7 @@ modify_dashboard_config_standalone() {
|
||||
if [[ -z "${nz_oauth2_type}" ]]; then
|
||||
nz_oauth2_type=github
|
||||
fi
|
||||
|
||||
|
||||
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
|
||||
@ -493,15 +511,15 @@ modify_dashboard_config_standalone() {
|
||||
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
|
||||
|
||||
|
||||
mkdir -p $NZ_DASHBOARD_PATH/data
|
||||
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||
|
||||
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
|
||||
else
|
||||
else
|
||||
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
|
||||
chmod +x $NZ_DASHBOARD_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
@ -510,11 +528,10 @@ modify_dashboard_config_standalone() {
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo -e "面板配置 ${green}修改成功,请稍等重启生效${plain}"
|
||||
|
||||
|
||||
restart_and_update_standalone
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -550,7 +567,7 @@ restart_and_update() {
|
||||
|
||||
restart_and_update_standalone() {
|
||||
echo -e "> 重启并更新面板"
|
||||
|
||||
|
||||
cd $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
@ -559,9 +576,9 @@ restart_and_update_standalone() {
|
||||
rc-service nezha-dashboard stop
|
||||
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 enable nezha-dashboard
|
||||
systemctl restart nezha-dashboard
|
||||
@ -569,14 +586,14 @@ restart_and_update_standalone() {
|
||||
rc-update add nezha-dashboard
|
||||
rc-service nezha-dashboard restart
|
||||
fi
|
||||
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}哪吒监控 重启成功${plain}"
|
||||
echo -e "默认管理面板地址:${yellow}域名:站点访问端口${plain}"
|
||||
else
|
||||
echo -e "${red}重启失败,可能是因为启动时间超过了两秒,请稍后查看日志信息${plain}"
|
||||
fi
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -605,19 +622,19 @@ start_dashboard() {
|
||||
|
||||
start_dashboard_standalone() {
|
||||
echo -e "> 启动面板"
|
||||
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl start nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard start
|
||||
fi
|
||||
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}哪吒监控 启动成功${plain}"
|
||||
else
|
||||
echo -e "${red}启动失败,请稍后查看日志信息${plain}"
|
||||
fi
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -646,19 +663,19 @@ stop_dashboard() {
|
||||
|
||||
stop_dashboard_standalone() {
|
||||
echo -e "> 停止面板"
|
||||
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl stop nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard stop
|
||||
fi
|
||||
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}哪吒监控 停止成功${plain}"
|
||||
else
|
||||
echo -e "${red}停止失败,请稍后查看日志信息${plain}"
|
||||
fi
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -681,7 +698,7 @@ show_dashboard_log() {
|
||||
|
||||
show_dashboard_log_standalone() {
|
||||
echo -e "> 获取面板日志"
|
||||
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
journalctl -xf -u nezha-dashboard.service
|
||||
else
|
||||
@ -704,8 +721,8 @@ uninstall_dashboard() {
|
||||
fi
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
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 ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
|
||||
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
|
||||
clean_all
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@ -715,7 +732,7 @@ uninstall_dashboard() {
|
||||
|
||||
uninstall_dashboard_standalone() {
|
||||
echo -e "> 卸载管理面板"
|
||||
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
@ -731,7 +748,7 @@ uninstall_dashboard_standalone() {
|
||||
fi
|
||||
|
||||
clean_all
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -754,7 +771,7 @@ show_agent_log() {
|
||||
uninstall_agent() {
|
||||
echo -e "> 卸载Agent"
|
||||
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl disable nezha-agent.service
|
||||
systemctl stop nezha-agent.service
|
||||
rm -rf $NZ_AGENT_SERVICE
|
||||
@ -776,7 +793,7 @@ uninstall_agent() {
|
||||
restart_agent() {
|
||||
echo -e "> 重启Agent"
|
||||
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl restart nezha-agent.service
|
||||
else
|
||||
rc-service nezha-agent restart
|
||||
@ -830,16 +847,16 @@ select_version() {
|
||||
while true; do
|
||||
read -e -r -p "请输入数字 [1-2]:" option
|
||||
case "${option}" in
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
;;
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "输入有误,请重新输入"
|
||||
*)
|
||||
echo "输入有误,请重新输入"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@ -892,98 +909,98 @@ show_menu() {
|
||||
echo && read -ep "请输入选择 [0-13]: " num
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
1)
|
||||
install_dashboard
|
||||
1)
|
||||
install_dashboard
|
||||
;;
|
||||
2)
|
||||
modify_dashboard_config
|
||||
2)
|
||||
modify_dashboard_config
|
||||
;;
|
||||
3)
|
||||
start_dashboard
|
||||
3)
|
||||
start_dashboard
|
||||
;;
|
||||
4)
|
||||
stop_dashboard
|
||||
4)
|
||||
stop_dashboard
|
||||
;;
|
||||
5)
|
||||
restart_and_update
|
||||
5)
|
||||
restart_and_update
|
||||
;;
|
||||
6)
|
||||
show_dashboard_log
|
||||
6)
|
||||
show_dashboard_log
|
||||
;;
|
||||
7)
|
||||
uninstall_dashboard
|
||||
7)
|
||||
uninstall_dashboard
|
||||
;;
|
||||
8)
|
||||
install_agent
|
||||
8)
|
||||
install_agent
|
||||
;;
|
||||
9)
|
||||
modify_agent_config
|
||||
9)
|
||||
modify_agent_config
|
||||
;;
|
||||
10)
|
||||
show_agent_log
|
||||
10)
|
||||
show_agent_log
|
||||
;;
|
||||
11)
|
||||
uninstall_agent
|
||||
11)
|
||||
uninstall_agent
|
||||
;;
|
||||
12)
|
||||
restart_agent
|
||||
12)
|
||||
restart_agent
|
||||
;;
|
||||
13)
|
||||
update_script
|
||||
13)
|
||||
update_script
|
||||
;;
|
||||
*)
|
||||
echo -e "${red}请输入正确的数字 [0-13]${plain}"
|
||||
*)
|
||||
echo -e "${red}请输入正确的数字 [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
1)
|
||||
install_dashboard_standalone
|
||||
1)
|
||||
install_dashboard_standalone
|
||||
;;
|
||||
2)
|
||||
modify_dashboard_config_standalone
|
||||
2)
|
||||
modify_dashboard_config_standalone
|
||||
;;
|
||||
3)
|
||||
start_dashboard_standalone
|
||||
3)
|
||||
start_dashboard_standalone
|
||||
;;
|
||||
4)
|
||||
stop_dashboard_standalone
|
||||
4)
|
||||
stop_dashboard_standalone
|
||||
;;
|
||||
5)
|
||||
restart_and_update_standalone
|
||||
5)
|
||||
restart_and_update_standalone
|
||||
;;
|
||||
6)
|
||||
show_dashboard_log_standalone
|
||||
6)
|
||||
show_dashboard_log_standalone
|
||||
;;
|
||||
7)
|
||||
uninstall_dashboard_standalone
|
||||
7)
|
||||
uninstall_dashboard_standalone
|
||||
;;
|
||||
8)
|
||||
install_agent
|
||||
8)
|
||||
install_agent
|
||||
;;
|
||||
9)
|
||||
modify_agent_config
|
||||
9)
|
||||
modify_agent_config
|
||||
;;
|
||||
10)
|
||||
show_agent_log
|
||||
10)
|
||||
show_agent_log
|
||||
;;
|
||||
11)
|
||||
uninstall_agent
|
||||
11)
|
||||
uninstall_agent
|
||||
;;
|
||||
12)
|
||||
restart_agent
|
||||
12)
|
||||
restart_agent
|
||||
;;
|
||||
13)
|
||||
update_script
|
||||
13)
|
||||
update_script
|
||||
;;
|
||||
*)
|
||||
echo -e "${red}请输入正确的数字 [0-13]${plain}"
|
||||
*)
|
||||
echo -e "${red}请输入正确的数字 [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
else
|
||||
@ -996,126 +1013,126 @@ pre_check
|
||||
if [[ $# > 0 ]]; then
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard 0
|
||||
"install_dashboard")
|
||||
install_dashboard 0
|
||||
;;
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config 0
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config 0
|
||||
;;
|
||||
"start_dashboard")
|
||||
start_dashboard 0
|
||||
"start_dashboard")
|
||||
start_dashboard 0
|
||||
;;
|
||||
"stop_dashboard")
|
||||
stop_dashboard 0
|
||||
"stop_dashboard")
|
||||
stop_dashboard 0
|
||||
;;
|
||||
"restart_and_update")
|
||||
restart_and_update 0
|
||||
"restart_and_update")
|
||||
restart_and_update 0
|
||||
;;
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log 0
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log 0
|
||||
;;
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard 0
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard 0
|
||||
;;
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard_standalone 0
|
||||
"install_dashboard")
|
||||
install_dashboard_standalone 0
|
||||
;;
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config_standalone 0
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config_standalone 0
|
||||
;;
|
||||
"start_dashboard")
|
||||
start_dashboard_standalone 0
|
||||
"start_dashboard")
|
||||
start_dashboard_standalone 0
|
||||
;;
|
||||
"stop_dashboard")
|
||||
stop_dashboard_standalone 0
|
||||
"stop_dashboard")
|
||||
stop_dashboard_standalone 0
|
||||
;;
|
||||
"restart_and_update")
|
||||
restart_and_update_standalone 0
|
||||
"restart_and_update")
|
||||
restart_and_update_standalone 0
|
||||
;;
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log_standalone 0
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log_standalone 0
|
||||
;;
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard_standalone 0
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard_standalone 0
|
||||
;;
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
else
|
||||
case $1 in
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
|
@ -14,7 +14,7 @@ NZ_AGENT_SERVICE="/etc/systemd/system/nezha-agent.service"
|
||||
NZ_AGENT_SERVICERC="/etc/init.d/nezha-agent"
|
||||
NZ_DASHBOARD_SERVICE="/etc/systemd/system/nezha-dashboard.service"
|
||||
NZ_DASHBOARD_SERVICERC="/etc/init.d/nezha-dashboard"
|
||||
NZ_VERSION="v0.15.4"
|
||||
NZ_VERSION="v0.15.5"
|
||||
|
||||
red='\033[0;31m'
|
||||
green='\033[0;32m'
|
||||
@ -34,15 +34,15 @@ pre_check() {
|
||||
## os_arch
|
||||
if [[ $(uname -m | grep 'x86_64') != "" ]]; then
|
||||
os_arch="amd64"
|
||||
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'i386\|i686') != "" ]]; then
|
||||
os_arch="386"
|
||||
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'aarch64\|armv8b\|armv8l') != "" ]]; then
|
||||
os_arch="arm64"
|
||||
elif [[ $(uname -m | grep 'arm') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'arm') != "" ]]; then
|
||||
os_arch="arm"
|
||||
elif [[ $(uname -m | grep 's390x') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 's390x') != "" ]]; then
|
||||
os_arch="s390x"
|
||||
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
|
||||
elif [[ $(uname -m | grep 'riscv64') != "" ]]; then
|
||||
os_arch="riscv64"
|
||||
fi
|
||||
|
||||
@ -50,37 +50,54 @@ pre_check() {
|
||||
if [[ -z "${CN}" ]]; 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"
|
||||
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
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Use Chinese Mirror"
|
||||
CN=true
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Use Chinese Mirror"
|
||||
CN=true
|
||||
;;
|
||||
|
||||
[nN][oO] | [nN])
|
||||
echo "No Use Chinese Mirror"
|
||||
[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
|
||||
*)
|
||||
echo "No Use Chinese Mirror"
|
||||
CUSTOM_MIRROR=$input
|
||||
;;
|
||||
esac
|
||||
|
||||
;;
|
||||
*)
|
||||
echo "No Use Chinese Mirror"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "${CN}" ]]; then
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
|
||||
GITHUB_URL="github.com"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" "
|
||||
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
|
||||
GITHUB_RELEASE_URL="github.com/naiba/nezha/releases/latest/download"
|
||||
else
|
||||
if [[ -n "${CUSTOM_MIRROR}" ]]; then
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL="dn-dao-github-mirror.daocloud.io"
|
||||
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"
|
||||
GITHUB_RELEASE_URL="hub.fgit.cf/naiba/nezha/releases/latest/download"
|
||||
else
|
||||
if [[ -z "${CN}" ]]; then
|
||||
GITHUB_RAW_URL="raw.githubusercontent.com/naiba/nezha/master"
|
||||
GITHUB_URL="github.com"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" "
|
||||
Docker_IMG="ghcr.io\/naiba\/nezha-dashboard"
|
||||
else
|
||||
GITHUB_RAW_URL="gitee.com/naibahq/nezha/raw/master"
|
||||
GITHUB_URL="hub.fgit.cf"
|
||||
Get_Docker_URL="get.docker.com"
|
||||
Get_Docker_Argu=" -s docker --mirror Aliyun"
|
||||
Docker_IMG="registry.cn-shanghai.aliyuncs.com\/naibahq\/nezha-dashboard"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -126,39 +143,39 @@ before_show_menu() {
|
||||
|
||||
install_base() {
|
||||
(command -v git >/dev/null 2>&1 && command -v curl >/dev/null 2>&1 && command -v wget >/dev/null 2>&1 && command -v unzip >/dev/null 2>&1 && command -v getenforce >/dev/null 2>&1) ||
|
||||
(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"
|
||||
read -e -r -p "Do you need to install libselinux? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
useradd -m nezha-agent
|
||||
sed -i "$ a\nezha-agent ALL=(ALL ) NOPASSWD:ALL" /etc/sudoers
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys BE22091E3EF62275;
|
||||
[yY][eE][sS] | [yY])
|
||||
useradd -m nezha-agent
|
||||
sed -i "$ a\nezha-agent ALL=(ALL ) NOPASSWD:ALL" /etc/sudoers
|
||||
sudo -iu nezha-agent bash -c 'gpg --keyserver keys.gnupg.net --recv-keys BE22091E3EF62275;
|
||||
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 ..;
|
||||
rm -rf libsepol libselinux'
|
||||
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"
|
||||
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"
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "Libselinux will not be installed"
|
||||
[nN][oO] | [nN])
|
||||
echo "Libselinux will not be installed"
|
||||
;;
|
||||
*)
|
||||
echo "Libselinux will not be installed"
|
||||
exit 0
|
||||
*)
|
||||
echo "Libselinux will not be installed"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_soft() {
|
||||
(command -v yum >/dev/null 2>&1 && yum makecache && yum install $* selinux-policy -y) ||
|
||||
(command -v apt >/dev/null 2>&1 && apt update && apt install $* selinux-utils -y) ||
|
||||
(command -v pacman >/dev/null 2>&1 && pacman -Syu $* base-devel --noconfirm && install_arch) ||
|
||||
(command -v apt-get >/dev/null 2>&1 && apt-get update && apt-get install $* selinux-utils -y) ||
|
||||
(command -v apk >/dev/null 2>&1 && apk update && apk add $* -f)
|
||||
(command -v apt >/dev/null 2>&1 && apt update && apt install $* selinux-utils -y) ||
|
||||
(command -v pacman >/dev/null 2>&1 && pacman -Syu $* base-devel --noconfirm && install_arch) ||
|
||||
(command -v apt-get >/dev/null 2>&1 && apt-get update && apt-get install $* selinux-utils -y) ||
|
||||
(command -v apk >/dev/null 2>&1 && apk update && apk add $* -f)
|
||||
}
|
||||
|
||||
install_dashboard() {
|
||||
@ -173,16 +190,16 @@ install_dashboard() {
|
||||
echo "You may have already installed the dashboard, repeated installation will overwrite the data, please pay attention to backup."
|
||||
read -e -r -p "Exit the installation? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "Continue."
|
||||
[nN][oO] | [nN])
|
||||
echo "Continue."
|
||||
;;
|
||||
*)
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
*)
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@ -210,9 +227,9 @@ install_dashboard() {
|
||||
|
||||
install_dashboard_standalone() {
|
||||
install_base
|
||||
|
||||
|
||||
echo -e "> Install Panel"
|
||||
|
||||
|
||||
# Nezha Monitoring Folder
|
||||
if [ ! -d "${NZ_DASHBOARD_PATH}/app" ]; then
|
||||
mkdir -p $NZ_DASHBOARD_PATH
|
||||
@ -220,16 +237,16 @@ install_dashboard_standalone() {
|
||||
echo "You may have already installed the dashboard, repeated installation will overwrite the data, please pay attention to backup."
|
||||
read -e -r -p "Exit the installation? [Y/n] " input
|
||||
case $input in
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
[yY][eE][sS] | [yY])
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
;;
|
||||
[nN][oO] | [nN])
|
||||
echo "Continue."
|
||||
[nN][oO] | [nN])
|
||||
echo "Continue."
|
||||
;;
|
||||
*)
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
*)
|
||||
echo "Exit the installation."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@ -239,19 +256,19 @@ install_dashboard_standalone() {
|
||||
fi
|
||||
|
||||
chmod 777 -R $NZ_DASHBOARD_PATH
|
||||
|
||||
|
||||
modify_dashboard_config_standalone 0
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
}
|
||||
|
||||
selinux(){
|
||||
selinux() {
|
||||
#Check SELinux
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
getenforce | grep '[Ee]nfor'
|
||||
if [ $? -eq 0 ];then
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "SELinux running,closing now!"
|
||||
setenforce 0 &>/dev/null
|
||||
find_key="SELINUX="
|
||||
@ -295,8 +312,8 @@ install_agent() {
|
||||
fi
|
||||
|
||||
unzip -qo nezha-agent_linux_${os_arch}.zip &&
|
||||
mv nezha-agent $NZ_AGENT_PATH &&
|
||||
rm -rf nezha-agent_linux_${os_arch}.zip README.md
|
||||
mv nezha-agent $NZ_AGENT_PATH &&
|
||||
rm -rf nezha-agent_linux_${os_arch}.zip README.md
|
||||
|
||||
if [ $# -ge 3 ]; then
|
||||
modify_agent_config "$@"
|
||||
@ -312,7 +329,7 @@ install_agent() {
|
||||
modify_agent_config() {
|
||||
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
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}Fail to download service, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
@ -329,11 +346,11 @@ modify_agent_config() {
|
||||
|
||||
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'
|
||||
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
|
||||
@ -352,7 +369,7 @@ modify_agent_config() {
|
||||
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_port/${nz_grpc_port}/" ${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}"
|
||||
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl daemon-reload
|
||||
systemctl enable nezha-agent
|
||||
systemctl restart nezha-agent
|
||||
@ -397,14 +414,14 @@ modify_dashboard_config() {
|
||||
fi
|
||||
|
||||
echo "About the GitHub Oauth2 application: create it at https://github.com/settings/developers, no review required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
echo "(Not recommended) About the Gitee Oauth2 application: create it at https://gitee.com/oauth/applications, no auditing required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
read -ep "Please enter the OAuth2 provider (github/gitlab/jihulab/gitee, default github): " nz_oauth2_type &&
|
||||
read -ep "Please enter the Client ID of the Oauth2 application: " nz_github_oauth_client_id &&
|
||||
read -ep "Please enter the Client Secret of the Oauth2 application: " nz_github_oauth_client_secret &&
|
||||
read -ep "Please enter your GitHub/Gitee login name as the administrator, separated by commas: " nz_admin_logins &&
|
||||
read -ep "Please enter the site title: " nz_site_title &&
|
||||
read -ep "Please enter the site access port: (default 8008)" nz_site_port &&
|
||||
read -ep "Please enter the RPC port to be used for Agent access: (default 5555)" nz_grpc_port
|
||||
echo "(Not recommended) About the Gitee Oauth2 application: create it at https://gitee.com/oauth/applications, no auditing required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
read -ep "Please enter the OAuth2 provider (github/gitlab/jihulab/gitee, default github): " nz_oauth2_type &&
|
||||
read -ep "Please enter the Client ID of the Oauth2 application: " nz_github_oauth_client_id &&
|
||||
read -ep "Please enter the Client Secret of the Oauth2 application: " nz_github_oauth_client_secret &&
|
||||
read -ep "Please enter your GitHub/Gitee login name as the administrator, separated by commas: " nz_admin_logins &&
|
||||
read -ep "Please enter the site title: " nz_site_title &&
|
||||
read -ep "Please enter the site access port: (default 8008)" nz_site_port &&
|
||||
read -ep "Please enter the RPC port to be used for Agent access: (default 5555)" nz_grpc_port
|
||||
|
||||
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
|
||||
echo -e "${red}All options cannot be empty${plain}"
|
||||
@ -448,31 +465,31 @@ modify_dashboard_config() {
|
||||
|
||||
modify_dashboard_config_standalone() {
|
||||
echo -e "> Modify Panel Configuration"
|
||||
|
||||
|
||||
echo -e "Download configuration template"
|
||||
|
||||
|
||||
wget -t 2 -T 10 -O /tmp/nezha-config.yaml https://${GITHUB_RAW_URL}/script/config.yaml >/dev/null 2>&1
|
||||
if [[ $? != 0 ]]; then
|
||||
echo -e "${red}File failed to get, please check if the network can link ${GITHUB_RAW_URL}${plain}"
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
echo "About the GitHub Oauth2 application: create it at https://github.com/settings/developers, no review required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
echo "(Not recommended) About the Gitee Oauth2 application: create it at https://gitee.com/oauth/applications, no auditing required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
read -ep "Please enter the OAuth2 provider (github/gitlab/jihulab/gitee, default github): " nz_oauth2_type &&
|
||||
read -ep "Please enter the Client ID of the Oauth2 application: " nz_github_oauth_client_id &&
|
||||
read -ep "Please enter the Client Secret of the Oauth2 application: " nz_github_oauth_client_secret &&
|
||||
read -ep "Please enter your GitHub/Gitee login name as the administrator, separated by commas: " nz_admin_logins &&
|
||||
read -ep "Please enter the site title: " nz_site_title &&
|
||||
read -ep "Please enter the site access port: (default 8008)" nz_site_port &&
|
||||
read -ep "Please enter the RPC port to be used for Agent access: (default 5555)" nz_grpc_port
|
||||
|
||||
echo "(Not recommended) About the Gitee Oauth2 application: create it at https://gitee.com/oauth/applications, no auditing required, and fill in the http(s)://domain_or_IP/oauth2/callback" &&
|
||||
read -ep "Please enter the OAuth2 provider (github/gitlab/jihulab/gitee, default github): " nz_oauth2_type &&
|
||||
read -ep "Please enter the Client ID of the Oauth2 application: " nz_github_oauth_client_id &&
|
||||
read -ep "Please enter the Client Secret of the Oauth2 application: " nz_github_oauth_client_secret &&
|
||||
read -ep "Please enter your GitHub/Gitee login name as the administrator, separated by commas: " nz_admin_logins &&
|
||||
read -ep "Please enter the site title: " nz_site_title &&
|
||||
read -ep "Please enter the site access port: (default 8008)" nz_site_port &&
|
||||
read -ep "Please enter the RPC port to be used for Agent access: (default 5555)" nz_grpc_port
|
||||
|
||||
if [[ -z "${nz_admin_logins}" || -z "${nz_github_oauth_client_id}" || -z "${nz_github_oauth_client_secret}" || -z "${nz_site_title}" ]]; then
|
||||
echo -e "${red}All options cannot be empty${plain}"
|
||||
before_show_menu
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
if [[ -z "${nz_site_port}" ]]; then
|
||||
nz_site_port=8008
|
||||
fi
|
||||
@ -482,7 +499,7 @@ modify_dashboard_config_standalone() {
|
||||
if [[ -z "${nz_oauth2_type}" ]]; then
|
||||
nz_oauth2_type=github
|
||||
fi
|
||||
|
||||
|
||||
sed -i "s/nz_oauth2_type/${nz_oauth2_type}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_admin_logins/${nz_admin_logins}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_grpc_port/${nz_grpc_port}/" /tmp/nezha-config.yaml
|
||||
@ -491,15 +508,15 @@ modify_dashboard_config_standalone() {
|
||||
sed -i "s/nz_language/zh-CN/" /tmp/nezha-config.yaml
|
||||
sed -i "s/nz_site_title/${nz_site_title}/" /tmp/nezha-config.yaml
|
||||
sed -i "s/80/${nz_site_port}/" /tmp/nezha-config.yaml
|
||||
|
||||
|
||||
mkdir -p $NZ_DASHBOARD_PATH/data
|
||||
mv -f /tmp/nezha-config.yaml ${NZ_DASHBOARD_PATH}/data/config.yaml
|
||||
|
||||
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
|
||||
else
|
||||
else
|
||||
wget -t 2 -T 10 -O $NZ_DASHBOARD_SERVICERC https://${GITHUB_RAW_URL}/script/nezha-dashboard >/dev/null 2>&1
|
||||
chmod +x $NZ_DASHBOARD_SERVICERC
|
||||
if [[ $? != 0 ]]; then
|
||||
@ -508,11 +525,10 @@ modify_dashboard_config_standalone() {
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
echo -e "Dashboard configuration ${green} modified successfully, please wait for Dashboard self-restart to take effect${plain}"
|
||||
|
||||
|
||||
restart_and_update_standalone
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -548,7 +564,7 @@ restart_and_update() {
|
||||
|
||||
restart_and_update_standalone() {
|
||||
echo -e "> Restart and Update the Panel"
|
||||
|
||||
|
||||
cd $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
@ -557,9 +573,9 @@ restart_and_update_standalone() {
|
||||
rc-service nezha-dashboard stop
|
||||
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 enable nezha-dashboard
|
||||
systemctl restart nezha-dashboard
|
||||
@ -567,14 +583,14 @@ restart_and_update_standalone() {
|
||||
rc-update add nezha-dashboard
|
||||
rc-service nezha-dashboard restart
|
||||
fi
|
||||
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}Nezha Monitoring Restart Successful${plain}"
|
||||
echo -e "Default panel address: ${yellow}domain:Site_access_port${plain}"
|
||||
else
|
||||
echo -e "${red}The restart failed, probably because the boot time exceeded two seconds, please check the log information later${plain}"
|
||||
fi
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -603,19 +619,19 @@ start_dashboard() {
|
||||
|
||||
start_dashboard_standalone() {
|
||||
echo -e "> Start Panel"
|
||||
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl start nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard start
|
||||
fi
|
||||
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}Nezha Monitoring Start Successful${plain}"
|
||||
else
|
||||
echo -e "${red}Failed to start, please check the log message later${plain}"
|
||||
fi
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -644,19 +660,19 @@ stop_dashboard() {
|
||||
|
||||
stop_dashboard_standalone() {
|
||||
echo -e "> Stop Panel"
|
||||
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl stop nezha-dashboard
|
||||
else
|
||||
rc-service nezha-dashboard stop
|
||||
fi
|
||||
|
||||
|
||||
if [[ $? == 0 ]]; then
|
||||
echo -e "${green}Nezha Monitoring Stop Successful${plain}"
|
||||
else
|
||||
echo -e "${red}Failed to stop, please check the log message later${plain}"
|
||||
fi
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -679,7 +695,7 @@ show_dashboard_log() {
|
||||
|
||||
show_dashboard_log_standalone() {
|
||||
echo -e "> View Panel Log"
|
||||
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
journalctl -xf -u nezha-dashboard.service
|
||||
else
|
||||
@ -702,8 +718,8 @@ uninstall_dashboard() {
|
||||
fi
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
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 ghcr.io/naiba/nezha-dashboard >/dev/null 2>&1
|
||||
docker rmi -f registry.cn-shanghai.aliyuncs.com/naibahq/nezha-dashboard >/dev/null 2>&1
|
||||
clean_all
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
@ -713,7 +729,7 @@ uninstall_dashboard() {
|
||||
|
||||
uninstall_dashboard_standalone() {
|
||||
echo -e "> Uninstall Panel"
|
||||
|
||||
|
||||
rm -rf $NZ_DASHBOARD_PATH
|
||||
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
@ -729,7 +745,7 @@ uninstall_dashboard_standalone() {
|
||||
fi
|
||||
|
||||
clean_all
|
||||
|
||||
|
||||
if [[ $# == 0 ]]; then
|
||||
before_show_menu
|
||||
fi
|
||||
@ -752,7 +768,7 @@ show_agent_log() {
|
||||
uninstall_agent() {
|
||||
echo -e "> Uninstall Agent"
|
||||
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl disable nezha-agent.service
|
||||
systemctl stop nezha-agent.service
|
||||
rm -rf $NZ_AGENT_SERVICE
|
||||
@ -774,7 +790,7 @@ uninstall_agent() {
|
||||
restart_agent() {
|
||||
echo -e "> Restart Agent"
|
||||
|
||||
if [ "$os_alpine" != 1 ];then
|
||||
if [ "$os_alpine" != 1 ]; then
|
||||
systemctl restart nezha-agent.service
|
||||
else
|
||||
rc-service nezha-agent restart
|
||||
@ -828,16 +844,16 @@ select_version() {
|
||||
while true; do
|
||||
read -e -r -p "Input a number [1-2]: " option
|
||||
case "${option}" in
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
1)
|
||||
IS_DOCKER_NEZHA=1
|
||||
break
|
||||
;;
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
2)
|
||||
IS_DOCKER_NEZHA=0
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Wrong input, try again"
|
||||
*)
|
||||
echo "Wrong input, try again"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@ -890,98 +906,98 @@ show_menu() {
|
||||
echo && read -ep "Please enter [0-13]: " num
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
1)
|
||||
install_dashboard
|
||||
1)
|
||||
install_dashboard
|
||||
;;
|
||||
2)
|
||||
modify_dashboard_config
|
||||
2)
|
||||
modify_dashboard_config
|
||||
;;
|
||||
3)
|
||||
start_dashboard
|
||||
3)
|
||||
start_dashboard
|
||||
;;
|
||||
4)
|
||||
stop_dashboard
|
||||
4)
|
||||
stop_dashboard
|
||||
;;
|
||||
5)
|
||||
restart_and_update
|
||||
5)
|
||||
restart_and_update
|
||||
;;
|
||||
6)
|
||||
show_dashboard_log
|
||||
6)
|
||||
show_dashboard_log
|
||||
;;
|
||||
7)
|
||||
uninstall_dashboard
|
||||
7)
|
||||
uninstall_dashboard
|
||||
;;
|
||||
8)
|
||||
install_agent
|
||||
8)
|
||||
install_agent
|
||||
;;
|
||||
9)
|
||||
modify_agent_config
|
||||
9)
|
||||
modify_agent_config
|
||||
;;
|
||||
10)
|
||||
show_agent_log
|
||||
10)
|
||||
show_agent_log
|
||||
;;
|
||||
11)
|
||||
uninstall_agent
|
||||
11)
|
||||
uninstall_agent
|
||||
;;
|
||||
12)
|
||||
restart_agent
|
||||
12)
|
||||
restart_agent
|
||||
;;
|
||||
13)
|
||||
update_script
|
||||
13)
|
||||
update_script
|
||||
;;
|
||||
*)
|
||||
echo -e "${red}Please enter the correct number [0-13]${plain}"
|
||||
*)
|
||||
echo -e "${red}Please enter the correct number [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case "${num}" in
|
||||
0)
|
||||
exit 0
|
||||
0)
|
||||
exit 0
|
||||
;;
|
||||
1)
|
||||
install_dashboard_standalone
|
||||
1)
|
||||
install_dashboard_standalone
|
||||
;;
|
||||
2)
|
||||
modify_dashboard_config_standalone
|
||||
2)
|
||||
modify_dashboard_config_standalone
|
||||
;;
|
||||
3)
|
||||
start_dashboard_standalone
|
||||
3)
|
||||
start_dashboard_standalone
|
||||
;;
|
||||
4)
|
||||
stop_dashboard_standalone
|
||||
4)
|
||||
stop_dashboard_standalone
|
||||
;;
|
||||
5)
|
||||
restart_and_update_standalone
|
||||
5)
|
||||
restart_and_update_standalone
|
||||
;;
|
||||
6)
|
||||
show_dashboard_log_standalone
|
||||
6)
|
||||
show_dashboard_log_standalone
|
||||
;;
|
||||
7)
|
||||
uninstall_dashboard_standalone
|
||||
7)
|
||||
uninstall_dashboard_standalone
|
||||
;;
|
||||
8)
|
||||
install_agent
|
||||
8)
|
||||
install_agent
|
||||
;;
|
||||
9)
|
||||
modify_agent_config
|
||||
9)
|
||||
modify_agent_config
|
||||
;;
|
||||
10)
|
||||
show_agent_log
|
||||
10)
|
||||
show_agent_log
|
||||
;;
|
||||
11)
|
||||
uninstall_agent
|
||||
11)
|
||||
uninstall_agent
|
||||
;;
|
||||
12)
|
||||
restart_agent
|
||||
12)
|
||||
restart_agent
|
||||
;;
|
||||
13)
|
||||
update_script
|
||||
13)
|
||||
update_script
|
||||
;;
|
||||
*)
|
||||
echo -e "${red}Please enter the correct number [0-13]${plain}"
|
||||
*)
|
||||
echo -e "${red}Please enter the correct number [0-13]${plain}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
@ -992,126 +1008,126 @@ pre_check
|
||||
if [[ $# > 0 ]]; then
|
||||
if [[ $IS_DOCKER_NEZHA == 1 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard 0
|
||||
"install_dashboard")
|
||||
install_dashboard 0
|
||||
;;
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config 0
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config 0
|
||||
;;
|
||||
"start_dashboard")
|
||||
start_dashboard 0
|
||||
"start_dashboard")
|
||||
start_dashboard 0
|
||||
;;
|
||||
"stop_dashboard")
|
||||
stop_dashboard 0
|
||||
"stop_dashboard")
|
||||
stop_dashboard 0
|
||||
;;
|
||||
"restart_and_update")
|
||||
restart_and_update 0
|
||||
"restart_and_update")
|
||||
restart_and_update 0
|
||||
;;
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log 0
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log 0
|
||||
;;
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard 0
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard 0
|
||||
;;
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
elif [[ $IS_DOCKER_NEZHA == 0 ]]; then
|
||||
case $1 in
|
||||
"install_dashboard")
|
||||
install_dashboard_standalone 0
|
||||
"install_dashboard")
|
||||
install_dashboard_standalone 0
|
||||
;;
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config_standalone 0
|
||||
"modify_dashboard_config")
|
||||
modify_dashboard_config_standalone 0
|
||||
;;
|
||||
"start_dashboard")
|
||||
start_dashboard_standalone 0
|
||||
"start_dashboard")
|
||||
start_dashboard_standalone 0
|
||||
;;
|
||||
"stop_dashboard")
|
||||
stop_dashboard_standalone 0
|
||||
"stop_dashboard")
|
||||
stop_dashboard_standalone 0
|
||||
;;
|
||||
"restart_and_update")
|
||||
restart_and_update_standalone 0
|
||||
"restart_and_update")
|
||||
restart_and_update_standalone 0
|
||||
;;
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log_standalone 0
|
||||
"show_dashboard_log")
|
||||
show_dashboard_log_standalone 0
|
||||
;;
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard_standalone 0
|
||||
"uninstall_dashboard")
|
||||
uninstall_dashboard_standalone 0
|
||||
;;
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
else
|
||||
case $1 in
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
"install_agent")
|
||||
shift
|
||||
if [ $# -ge 3 ]; then
|
||||
install_agent "$@"
|
||||
else
|
||||
install_agent 0
|
||||
fi
|
||||
;;
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
"modify_agent_config")
|
||||
modify_agent_config 0
|
||||
;;
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
"show_agent_log")
|
||||
show_agent_log 0
|
||||
;;
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
"uninstall_agent")
|
||||
uninstall_agent 0
|
||||
;;
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
"restart_agent")
|
||||
restart_agent 0
|
||||
;;
|
||||
"update_script")
|
||||
update_script 0
|
||||
"update_script")
|
||||
update_script 0
|
||||
;;
|
||||
*) show_usage ;;
|
||||
*) show_usage ;;
|
||||
esac
|
||||
fi
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user