diff options
| author | shizhendong <[email protected]> | 2023-04-26 18:13:36 +0800 |
|---|---|---|
| committer | shizhendong <[email protected]> | 2023-04-26 18:13:36 +0800 |
| commit | d07d63fa64d5d954a99d19336632ddadc1287a4d (patch) | |
| tree | d19058417154296a29327402e5af8ff5f69b6bf5 | |
| parent | 5f7d1942eddeb73592016361ecba5ada12ca96ea (diff) | |
fix: NEZ-2138 修复 rpm 更新缺少 nz-telegraf.service 问题
| -rw-r--r-- | tools/afterinstall.sh | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/tools/afterinstall.sh b/tools/afterinstall.sh index 93773fa..a487e9a 100644 --- a/tools/afterinstall.sh +++ b/tools/afterinstall.sh @@ -41,8 +41,10 @@ restoreComponentConfig(){ for i in $(ls $2);do if [ 1 -eq `compareMD5 $1/$i $2/$i` ];then - echo 'return config file '$1/${i} - cp -f $2/$i $1/$i + if [ -f $1/${i} ];then + echo 'return config file '$1/${i} + cp -f $2/$i $1/$i + fi fi done } @@ -164,5 +166,35 @@ EOF systemctl daemon-reload systemctl enable nz-promtail && systemctl restart nz-promtail fi + + # nz-telegraf.service + if service_exists nz-telegraf; then + systemctl restart nz-telegraf + else + cat > /usr/lib/systemd/system/nz-telegraf.service <<"EOF" +[Unit] +Description=Telegraf +Documentation=https://github.com/influxdata/telegraf +After=network-online.target +Wants=network-online.target + +[Service] +WorkingDirectory=/opt/nezha/telegraf +Type=notify +EnvironmentFile=/opt/nezha/telegraf/config.conf +ExecStart=/opt/nezha/telegraf/telegraf $OPTION +ExecReload=/bin/kill -HUP $MAINPID +Restart=on-failure +RestartForceExitStatus=SIGPIPE +KillMode=control-group +LimitMEMLOCK=8M:8M + +[Install] +WantedBy=multi-user.target +EOF + + systemctl daemon-reload + systemctl enable nz-telegraf && systemctl restart nz-telegraf + fi fi |
