forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed install/remove of kapacitor on non-systemd Debian/Ubuntu systems
Also added distribution-specific install/remove logic with code copied from telegraf/influxdb scripts. For more rationale, see: influxdata/telegraf#2360
- Loading branch information
1 parent
15d9a38
commit ac36203
Showing
3 changed files
with
110 additions
and
27 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 |
---|---|---|
@@ -1,17 +1,54 @@ | ||
#!/bin/sh | ||
#!/bin/bash | ||
|
||
rm -f /etc/default/kapacitor | ||
|
||
# Systemd | ||
if which systemctl > /dev/null 2>&1 ; then | ||
function disable_systemd { | ||
systemctl disable kapacitor | ||
rm -f /lib/systemd/system/kapacitor.service | ||
# Sysv | ||
else | ||
if which update-rc.d > /dev/null 2>&1 ; then | ||
update-rc.d -f kapacitor remove | ||
else | ||
chkconfig --del kapacitor | ||
fi | ||
} | ||
|
||
function disable_update_rcd { | ||
update-rc.d kapacitor remove | ||
rm -f /etc/init.d/kapacitor | ||
} | ||
|
||
function disable_chkconfig { | ||
chkconfig --del kapacitor | ||
rm -f /etc/init.d/kapacitor | ||
} | ||
|
||
if [[ -f /etc/redhat-release ]]; then | ||
# RHEL-variant logic | ||
if [[ "$1" = "0" ]]; then | ||
# Kapacitor is no longer installed, remove from init system | ||
rm -f /etc/default/kapacitor | ||
|
||
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; 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/kapacitor | ||
|
||
if [[ "$(readlink /proc/1/exe)" == */systemd ]]; then | ||
disable_systemd | ||
else | ||
# Assuming sysv | ||
disable_update_rcd | ||
fi | ||
fi | ||
elif [[ -f /etc/os-release ]]; then | ||
source /etc/os-release | ||
if [[ $ID = "amzn" ]]; then | ||
# Amazon Linux logic | ||
if [[ "$1" = "0" ]]; then | ||
# Kapacitor is no longer installed, remove from init system | ||
rm -f /etc/default/kapacitor | ||
disable_chkconfig | ||
fi | ||
fi | ||
fi |