-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved install script for packaged telegraf:
* Start/stop service on Debian/Ubuntu * Disable init-script/Systemd-unit on package removal
- Loading branch information
Showing
4 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash | ||
|
||
function disable_systemd { | ||
systemctl disable telegraf | ||
rm -f /lib/systemd/system/telegraf.service | ||
} | ||
|
||
function disable_update_rcd { | ||
update-rc.d -f telegraf remove | ||
rm -f /etc/init.d/telegraf | ||
} | ||
|
||
function disable_chkconfig { | ||
chkconfig --del telegraf | ||
rm -f /etc/init.d/telegraf | ||
} | ||
|
||
if [[ -f /etc/redhat-release ]]; then | ||
# RHEL-variant logic | ||
if [[ "$1" = "0" ]]; then | ||
# InfluxDB is no longer installed, remove from init system | ||
rm -f /etc/default/telegraf | ||
|
||
which systemctl &>/dev/null | ||
if [[ $? -eq 0 ]]; then | ||
disable_systemd | ||
else | ||
# Assuming sysv | ||
disable_chkconfig | ||
fi | ||
fi | ||
elif [[ -f /etc/debian_version ]]; then | ||
# Debian/Ubuntu logic | ||
if [[ "$1" != "upgrade" ]]; then | ||
# Remove/purge | ||
rm -f /etc/default/telegraf | ||
|
||
which systemctl &>/dev/null | ||
if [[ $? -eq 0 ]]; then | ||
disable_systemd | ||
else | ||
# Assuming sysv | ||
disable_update_rcd | ||
fi | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
BIN_DIR=/usr/bin | ||
|
||
# Distribution-specific logic | ||
if [[ -f /etc/debian_version ]]; then | ||
# Debian/Ubuntu logic | ||
which systemctl &>/dev/null | ||
if [[ $? -eq 0 ]]; then | ||
deb-systemd-invoke stop telegraf.service | ||
else | ||
# Assuming sysv | ||
invoke-rc.d telegraf stop | ||
fi | ||
fi |