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 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
#!/bin/bash
#
# Copyright (C) 2013-2022 Draios Inc dba Sysdig.
#
# This file is part of Sysdig.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set -e
SYSDIG_REPOSITORY_NAME="stable"
function install_rpm {
if ! hash curl > /dev/null 2>&1; then
echo "* Installing curl"
yum -q -y install curl
fi
if ! yum -q list dkms > /dev/null 2>&1; then
echo "* Installing EPEL repository (for DKMS)"
if [ $VERSION -eq 8 ]; then
rpm --quiet -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
elif [ $VERSION -eq 7 ]; then
rpm --quiet -i https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
else
rpm --quiet -i https://mirrors.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
fi
fi
echo "* Installing Sysdig public key"
rpm --quiet --import https://download.sysdig.com/DRAIOS-GPG-KEY.public
echo "* Installing Sysdig repository"
curl -s -o /etc/yum.repos.d/draios.repo "https://download.sysdig.com/$SYSDIG_REPOSITORY_NAME/rpm/draios.repo"
echo "* Installing kernel headers"
KERNEL_VERSION=$(uname -r)
if [[ $KERNEL_VERSION == *PAE* ]]; then
yum -q -y install kernel-PAE-devel-${KERNEL_VERSION%.PAE} || kernel_warning
elif [[ $KERNEL_VERSION == *stab* ]]; then
# It's OpenVZ kernel and we should install another package
yum -q -y install vzkernel-devel-$KERNEL_VERSION || kernel_warning
elif [[ $KERNEL_VERSION == *uek* ]]; then
yum -q -y install kernel-uek-devel-$KERNEL_VERSION || kernel_warning
else
yum -q -y install kernel-devel-$KERNEL_VERSION || kernel_warning
fi
echo "* Installing Sysdig"
yum -q -y install sysdig
}
function install_deb {
export DEBIAN_FRONTEND=noninteractive
if ! hash curl > /dev/null 2>&1; then
echo "* Installing curl"
apt-get -qq -y install curl < /dev/null
fi
echo "* Installing Sysdig public key"
curl -s https://download.sysdig.com/DRAIOS-GPG-KEY.public | apt-key add -
echo "* Installing Sysdig repository"
curl -s -o /etc/apt/sources.list.d/draios.list "https://download.sysdig.com/$SYSDIG_REPOSITORY_NAME/deb/draios.list"
apt-get -qq update < /dev/null
echo "* Installing kernel headers"
apt-get -qq -y install linux-headers-$(uname -r) < /dev/null || kernel_warning
echo "* Installing Sysdig"
apt-get -qq -y install sysdig < /dev/null
}
function unsupported {
echo 'Unsupported operating system. Please consider writing to the mailing list at'
echo 'https://groups.google.com/forum/#!forum/sysdig or trying the manual'
echo 'installation.'
exit 1
}
function kernel_warning {
echo "Unable to find kernel development files for the current kernel version" $(uname -r)
echo "This usually means that your system is not up-to-date or you installed a custom kernel version."
echo "The installation will continue but you'll need to install these yourself in order to use Sysdig."
echo 'Please write to the mailing list at https://groups.google.com/forum/#!forum/sysdig'
echo "if you need further assistance."
}
if [ $(id -u) != 0 ]; then
echo "Installer must be run as root (or with sudo)."
exit 1
fi
echo "* Detecting operating system"
ARCH=$(uname -m)
if [[ ! $ARCH = *86 ]] && [ ! $ARCH = "x86_64" ] && [ ! $ARCH = "s390x" ]; then
unsupported
fi
if [ $ARCH = "s390x" ]; then
echo "------------"
echo "WARNING: A Docker container is the only officially supported platform on s390x"
echo "------------"
fi
if [ -f /etc/debian_version ]; then
if [ -f /etc/lsb-release ]; then
. /etc/lsb-release
DISTRO=$DISTRIB_ID
VERSION=${DISTRIB_RELEASE%%.*}
else
DISTRO="Debian"
VERSION=$(cat /etc/debian_version | cut -d'.' -f1)
fi
case "$DISTRO" in
"Ubuntu")
if [ $VERSION -ge 10 ]; then
install_deb
else
unsupported
fi
;;
"LinuxMint")
if [ $VERSION -ge 9 ]; then
install_deb
else
unsupported
fi
;;
"Debian")
if [ $VERSION -ge 6 ]; then
install_deb
elif [[ $VERSION == *sid* ]]; then
install_deb
else
unsupported
fi
;;
*)
unsupported
;;
esac
elif [ -f /etc/system-release-cpe ]; then
DISTRO=$(cat /etc/system-release-cpe | cut -d':' -f3)
# New Amazon Linux 2 distro
if [[ -f /etc/image-id ]]; then
AMZ_AMI_VERSION=$(cat /etc/image-id | grep 'image_name' | cut -d"=" -f2 | tr -d "\"")
fi
if [[ "${DISTRO}" == "o" ]] && [[ ${AMZ_AMI_VERSION} = *"amzn2"* ]]; then
DISTRO=$(cat /etc/system-release-cpe | cut -d':' -f4)
fi
VERSION=$(cat /etc/system-release-cpe | cut -d':' -f5 | cut -d'.' -f1 | sed 's/[^0-9]*//g')
case "$DISTRO" in
"oracle" | "centos" | "redhat")
if [ $VERSION -ge 6 ]; then
install_rpm
else
unsupported
fi
;;
"amazon")
install_rpm
;;
"fedoraproject")
if [ $VERSION -ge 13 ]; then
install_rpm
else
unsupported
fi
;;
*)
unsupported
;;
esac
else
unsupported
fi
modprobe -r scap
|