1export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/share/bcc/tools/
2export TMPDIR=/tmp/
3
4psk=/proc/sys/kernel/kptr_restrict
5if [ -f $psk ]; then echo 0 > $psk; fi
6
7override_vers=1
8this_vers=$(/get_kvers.sh)
9if [ -d /kernel-headers/ ]; then
10	export BCC_KERNEL_SOURCE=/kernel-headers/;
11
12	h_vers=0
13	vers_line=$(grep LINUX_VERSION_CODE /kernel-headers/include/generated/uapi/linux/version.h)
14	if [ "x$vers_line" != "x" ]; then
15		h_vers=$(echo $vers_line | cut -d ' ' -f3)
16	fi
17
18	if [ $this_vers -eq $h_vers ]; then
19		override_vers=0
20	else
21		this_major=$(($this_vers / (256 * 256)))
22		this_minor=$(($this_vers / 256 % 256))
23		h_major=$(($h_vers / (256 * 256)))
24		h_minor=$(($h_vers / 256 % 256))
25		if [ $this_major -ne $h_major ] || [ $this_minor -ne $h_minor ]; then
26			echo "Error: kernel version does not match installed headers ($this_major.$this_minor <> $h_major.$h_minor)"
27			echo "BCC will not work"
28			override_vers=0
29		fi
30	fi
31fi
32
33# Override kernel version if we haven't found headers with them.
34# Needed for BCC to work on slightly mismatched kernels.
35if [ $override_vers -eq 1 ]; then
36	export BCC_LINUX_VERSION_CODE=$this_vers
37fi
38