From bd7a0a039ae19d592fb6f0b80ee65272abfc288b Mon Sep 17 00:00:00 2001 From: xiaoz Date: Wed, 5 Jan 2022 10:43:19 +0800 Subject: [PATCH] fix bug --- node_exporter.sh | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/node_exporter.sh b/node_exporter.sh index f990238..0de0e86 100644 --- a/node_exporter.sh +++ b/node_exporter.sh @@ -3,8 +3,10 @@ ##### authro:xiaoz ##### ##### update:2021/12/09 ##### +#获取action +ACTION=$1 #获取版本号 -VERSION=$1 +VERSION=$2 #instance名称 #INSTANCE=$2 #用户名、密码 @@ -108,5 +110,30 @@ clean_work() { rm -rf /opt/node_exporter-${VERSION}.linux-amd64.tar.gz } -depend && download && setting && release_port && reg_systemd && clean_work && install_success +#卸载node_exporter +uninstall(){ + #停止服务 + systemctl stop node_exporter + systemctl disable node_exporter + #删除服务 + rm -rf /etc/systemd/system/node_exporter.service + systemctl daemon-reload + #删除安装目录 + rm -rf ${INSTALL_PATH} +} + +#根据参数一判断执行动作 +case $ACTION in +"install") + depend && download && setting && release_port && reg_systemd && clean_work && install_success + ;; +"uninstall") + uninstall + ;; +*) + echo "Parameter error!" + ;; +esac + +