50 lines
1.2 KiB
Bash
50 lines
1.2 KiB
Bash
#!/bin/sh
|
|
|
|
service_exists(){
|
|
local n=$1
|
|
if [[ $(systemctl list-units --all -t service --full --no-legend "$n.service" | sed 's/^\s*//g' | cut -f1 -d' ') == $n.service ]]; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
if [ 0 -eq $1 ];then
|
|
|
|
echo 'start remove nz-talon module from disk...'
|
|
|
|
systemctl stop nz-talon.service
|
|
systemctl stop nz-telegraf.service
|
|
|
|
rm -rf /opt/nezha/nz-talon
|
|
rm -rf /opt/nezha/telegraf
|
|
|
|
systemctl disable nz-talon.service
|
|
systemctl disable nz-telegraf.service
|
|
|
|
# promtail.service
|
|
if service_exists promtail; then
|
|
systemctl stop promtail.service
|
|
rm -rf /opt/nezha/promtail
|
|
systemctl disable promtail.service
|
|
fi
|
|
|
|
# nz-promtail.service
|
|
if service_exists nz-promtail; then
|
|
systemctl stop nz-promtail.service
|
|
rm -rf /opt/nezha/promtail
|
|
systemctl disable nz-promtail.service
|
|
fi
|
|
|
|
rm -rf /usr/lib/systemd/system/{nz-talon.service,promtail.service,nz-promtail.service,nz-telegraf.service}
|
|
rm -rf /etc/rsyslog.d/{promtail.conf,telegraf.conf}
|
|
rm -rf /etc/logrotate.d/{promtail,telegraf}
|
|
|
|
systemctl daemon-reload
|
|
systemctl restart rsyslog
|
|
|
|
echo 'uninstall success!'
|
|
fi
|
|
|
|
|