forked from fluent/fluent-bit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·84 lines (79 loc) · 2.59 KB
/
install.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
81
82
83
84
#!/usr/bin/env bash
set -e
echo "================================"
echo " Fluent Bit Installation Script "
echo "================================"
echo "This script requires superuser access to install packages."
echo "You will be prompted for your password by sudo."
# Determine package type to install: https://unix.stackexchange.com/a/6348
# OS used by all - for Debs it must be Ubuntu or Debian
# CODENAME only used for Debs
if [ -f /etc/os-release ]; then
# Debian uses Dash which does not support source
# shellcheck source=/dev/null
. /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
# Clear any previous sudo permission
sudo -k
# Now set up repos and install dependent on OS, version, etc.
# Will require sudo
case ${OS} in
amzn|amazonlinux)
sudo sh <<'SCRIPT'
rpm --import https://packages.fluentbit.io/fluentbit.key
cat > /etc/yum.repos.d/fluent-bit.repo <<EOF
[fluent-bit]
name = Fluent Bit
baseurl = https://packages.fluentbit.io/amazonlinux/\$releasever/\$basearch/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.fluentbit.io/fluentbit.key
enabled=1
EOF
yum -y install fluent-bit || yum -y install td-agent-bit
SCRIPT
;;
centos|centoslinux|rhel|redhatenterpriselinuxserver|fedora|rocky|almalinux)
sudo sh <<'SCRIPT'
rpm --import https://packages.fluentbit.io/fluentbit.key
cat > /etc/yum.repos.d/fluent-bit.repo <<EOF
[fluent-bit]
name = Fluent Bit
baseurl = https://packages.fluentbit.io/centos/\$releasever/\$basearch/
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.fluentbit.io/fluentbit.key
enabled=1
EOF
yum -y install fluent-bit || yum -y install td-agent-bit
SCRIPT
;;
ubuntu|debian)
# Remember apt-key add is deprecated
# https://wiki.debian.org/DebianRepository/UseThirdParty#OpenPGP_Key_distribution
sudo sh <<SCRIPT
export DEBIAN_FRONTEND=noninteractive
mkdir -p /usr/share/keyrings/
curl https://packages.fluentbit.io/fluentbit.key | gpg --dearmor > /usr/share/keyrings/fluentbit-keyring.gpg
cat > /etc/apt/sources.list.d/fluent-bit.list <<EOF
deb [signed-by=/usr/share/keyrings/fluentbit-keyring.gpg] https://packages.fluentbit.io/${OS}/${CODENAME} ${CODENAME} main
EOF
apt-get -y update
apt-get -y install fluent-bit || apt-get -y install td-agent-bit
SCRIPT
;;
*)
echo "${OS} not supported."
exit 1
;;
esac
echo ""
echo "Installation completed. Happy Logging!"
echo ""