From b370130b151d2d22ae9a3627be55dc6e94d74fbb Mon Sep 17 00:00:00 2001 From: xiaoz Date: Fri, 10 Dec 2021 09:57:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=80=E4=BA=9B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- node_exporter.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/node_exporter.sh b/node_exporter.sh index 39dd0d8..b7766e4 100644 --- a/node_exporter.sh +++ b/node_exporter.sh @@ -51,8 +51,12 @@ release_port(){ which firewall-cmd if [ $? -eq 0 ] then - firewall-cmd --zone=public --add-port=29100/tcp --permanent - firewall-cmd --reload + firewall_status=$(firewall-cmd --state) + if[[ "firewall_status" == "running" ]] + then + firewall-cmd --zone=public --add-port=29100/tcp --permanent + firewall-cmd --reload + fi fi which ufw if [ $? -eq 0 ] @@ -79,11 +83,13 @@ WantedBy=default.target" > /etc/systemd/system/node_exporter.service systemctl daemon-reload #启动服务 systemctl start node_exporter.service + #设置开机自启 + systemctl enable node_exporter.service } #安装完成 install_success(){ - myip=$(curl ip.sb) + myip=$(curl -s ip.sb) echo "Installation is complete, please visit http://${myip}:29100" } @@ -93,5 +99,4 @@ clean_work() { rm -rf /opt/node_exporter-${VERSION}.linux-amd64.tar.gz } -depend && download && setting && release_port && reg_systemd && install_success -clean_work \ No newline at end of file +depend && download && setting && release_port && reg_systemd && clean_work && install_success