forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-uninstall.sh
80 lines (71 loc) · 2.06 KB
/
post-uninstall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
function uninstall_init {
rm -f /etc/init.d/kapacitor
}
function uninstall_systemd {
rm -f /lib/systemd/system/kapacitor.service
}
function disable_systemd {
systemctl disable kapacitor
}
function disable_update_rcd {
update-rc.d -f kapacitor remove
}
function disable_chkconfig {
chkconfig --del 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
uninstall_systemd
else
# Assuming SysV
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
disable_update_rcd
else
disable_chkconfig
fi
uninstall_init
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
uninstall_systemd
else
# Assuming SysV
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
disable_update_rcd
else
disable_chkconfig
fi
uninstall_init
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
# Run update-rc.d or fallback to chkconfig if not available
if which update-rc.d &>/dev/null; then
disable_update_rcd
else
disable_chkconfig
fi
uninstall_init
fi
fi
fi