master
sh 76 lines 2.1 KB
Raw
1 #!/usr/bin/env bash
2
3 get_kernel_version() {
4 r="$(uname -r | cut -f 1 -d '-')"
5
6 read -r -a p <<< "$(echo "${r}" | tr '.' ' ')"
7
8 printf "%03d%03d%03d" "${p[0]}" "${p[1]}" "${p[2]}"
9 }
10
11 get_rh_version() {
12 if [ ! -f /etc/redhat-release ]; then
13 printf "000000000"
14 return
15 fi
16
17 r="$(cut -f 4 -d ' ' < /etc/redhat-release)"
18
19 read -r -a p <<< "$(echo "${r}" | tr '.' ' ')"
20
21 printf "%03d%03d%03d" "${p[0]}" "${p[1]}" "${p[2]}"
22 }
23
24 if [ "$(uname -s)" != "Linux" ]; then
25 echo >&2 "This does not appear to be a Linux system."
26 exit 1
27 fi
28
29 KERNEL_VERSION="$(uname -r)"
30
31 if [ "$(get_kernel_version)" -lt 004014000 ] && [ "$(get_rh_version)" -lt 0070061810 ]; then
32 echo >&2 "WARNING: Your kernel appears to be older than 4.11 or you are using RH version older than 7.6.1810. This may still work in some cases, but probably won't."
33 fi
34
35 CONFIG_PATH=""
36 MODULE_LOADED=""
37
38 if modprobe configs 2> /dev/null; then
39 MODULE_LOADED=1
40 fi
41
42 if [ -r /proc/config.gz ]; then
43 CONFIG_PATH="/proc/config.gz"
44 elif [ -r "/lib/modules/${KERNEL_VERSION}/source/.config" ]; then
45 CONFIG_PATH="/lib/modules/${KERNEL_VERSION}/source/.config"
46 elif [ -r "/lib/modules/${KERNEL_VERSION}.x86_64/source/.config" ]; then
47 CONFIG_PATH="/lib/modules/${KERNEL_VERSION}.x86_64/source/.config"
48 elif [ -n "$(find /boot -name "config-${KERNEL_VERSION}*")" ]; then
49 CONFIG_PATH="$(find /boot -name "config-${KERNEL_VERSION}*" | head -n 1)"
50 fi
51
52 if [ -n "${CONFIG_PATH}" ]; then
53 GREP='grep'
54 CAT='cat'
55
56 if echo "${CONFIG_PATH}" | grep -q '.gz'; then
57 CAT='zcat'
58 fi
59
60 REQUIRED_CONFIG="KPROBES KPROBES_ON_FTRACE HAVE_KPROBES BPF BPF_SYSCALL BPF_JIT"
61
62 for required_config in ${REQUIRED_CONFIG}; do
63 # Fix issue https://github.com/netdata/netdata/issues/14668
64 # if ! "${GREP}" -q "CONFIG_${required_config}=y" "${CONFIG_PATH}"; then
65 if ! { "${CAT}" "${CONFIG_PATH}" | "${GREP}" -q "CONFIG_${required_config}=y" >&2 >/dev/null; } ;then
66 echo >&2 " Missing Kernel Config: ${required_config}"
67 exit 1
68 fi
69 done
70 fi
71
72 if [ -n "${MODULE_LOADED}" ]; then
73 modprobe -r configs 2> /dev/null || true # Ignore failures from CONFIGS being builtin
74 fi
75
76 exit 0