-
Notifications
You must be signed in to change notification settings - Fork 4
/
uninstall.sh
80 lines (69 loc) · 1.97 KB
/
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
uninstall_yum() {
local td_agent="$1"
sudo service osqueryd stop
sudo yum erase osquery -y
sudo rm /etc/pki/rpm-gpg/RPM-GPG-KEY-osquery
sudo rm /etc/osquery/osquery.conf
sudo rm /etc/osquery/osquery.flags
if [ "$td_agent" = true ]; then
sudo service td-agent-bit stop
sudo yum erase td-agent-bit -y
sudo rm /etc/yum.repos.d/td-agent-bit.repo
sudo rm /etc/td-agent-bit/td-agent-bit.conf
else
sudo service fluent-bit stop
sudo yum erase fluent-bit -y
sudo rm /etc/yum.repos.d/fluent-bit.repo
sudo rm /etc/fluent-bit/fluent-bit.conf
fi
sudo service telegraf stop
sudo yum erase telegraf -y
sudo rm /etc/yum.repos.d/influxdb.repo
sudo rm /etc/telegraf/telegraf.conf
}
uninstall_apt() {
sudo service osqueryd stop
sudo apt-get remove osquery -y
sudo rm /etc/osquery/osquery.conf
sudo rm /etc/osquery/osquery.flags
sudo service td-agent-bit stop
sudo apt-get remove td-agent-bit -y
sudo rm /etc/td-agent-bit/td-agent-bit.conf
sudo service telegraf stop
sudo apt-get remove telegraf -y
sudo rm /etc/telegraf/telegraf.conf
}
# identify OS and architecture
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$( echo "${ID}" | tr '[:upper:]' '[:lower:]')
CODENAME=$( echo "${VERSION_CODENAME}" | tr '[:upper:]' '[:lower:]')
elif lsb_release &>/dev/null; then
OS=$(lsb_release -is | tr '[:upper:]' '[:lower:]')
CODENAME=$(lsb_release -cs)
else
OS=$(uname -s)
fi
SYS_ARCH=$(uname -m)
if [[ $SYS_ARCH = "aarch64" ]]; then
ARCH="arm64"
else
ARCH="amd64"
fi
case ${OS} in
amzn|amazonlinux)
AL_VERSION=$(awk -F= '$1=="VERSION" { print $2 ;}' /etc/os-release | xargs)
if [[ $AL_VERSION == "2023" ]]; then
uninstall_yum
else
uninstall_yum true
fi
;;
rhel|centos)
uninstall_yum true
;;
ubuntu|debian)
uninstall_apt
;;
esac