mirror of
https://github.com/valitydev/osquery-1.git
synced 2024-11-08 10:23:54 +00:00
525a3b79a0
* The OS/DISTRO are available as defines when writing tables: UBUNTU, UBUNTU_14_04, UBUNTU_12_04 CENTOS, CENTOS_6_6 DARWIN, DARWIN_10_10, DARWIN_10_9 * The table generation tooling now grabs virtual tables templates from ./osquery/tables/templates/<name>.cpp.in. * The table generation tooling will detect reserved column names. * suid_bin uses the new UBUNTU to restrict calls to root (fix #362).
70 lines
1.5 KiB
Bash
Executable File
70 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
function platform() {
|
|
local __resultvar=$1
|
|
if [[ -f "/etc/redhat-release" ]]; then
|
|
eval $__resultvar="centos"
|
|
elif [[ -f "/etc/lsb-release" ]]; then
|
|
eval $__resultvar="ubuntu"
|
|
elif [[ -f "/etc/pf.conf" ]]; then
|
|
eval $__resultvar="darwin"
|
|
fi
|
|
}
|
|
|
|
function distro() {
|
|
local __resultvar=$2
|
|
if [[ $1 = "centos" ]]; then
|
|
eval $__resultvar="centos"`cat /etc/redhat-release | awk '{print $3}'`
|
|
elif [[ $1 = "ubuntu" ]]; then
|
|
eval $__resultvar=`cat /etc/*-release | grep DISTRIB_CODENAME | awk -F '=' '{print $2}'`
|
|
elif [[ $1 = "darwin" ]]; then
|
|
eval $__resultvar=`sw_vers -productVersion | awk -F '.' '{print $1 "." $2}'`
|
|
else
|
|
eval $__resultvar="unknown_version"
|
|
fi
|
|
}
|
|
|
|
function threads() {
|
|
local __resultvar=$1
|
|
platform OS
|
|
if [[ $TRAVIS_ENV = true ]]; then
|
|
log "running in travis"
|
|
eval $__resultvar=2
|
|
elif [ $OS = "centos" ] || [ $OS = "ubuntu" ]; then
|
|
eval $__resultvar=`cat /proc/cpuinfo | grep processor | wc -l`
|
|
elif [[ $OS = "darwin" ]]; then
|
|
eval $__resultvar=`sysctl hw.ncpu | awk '{print $2}'`
|
|
fi
|
|
}
|
|
|
|
function log() {
|
|
echo "[+] $1"
|
|
}
|
|
|
|
function fatal() {
|
|
echo "[!] $1"
|
|
exit 1
|
|
}
|
|
|
|
function set_cxx() {
|
|
export CXX=$1
|
|
export CMAKE_CXX_COMPILER=$1
|
|
}
|
|
|
|
function add_cxx_flag() {
|
|
export CXXFLAGS="$CXXFLAGS $1"
|
|
export CMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS $1"
|
|
}
|
|
|
|
function set_cc() {
|
|
export CC=$1
|
|
export CMAKE_C_COMPILER=$1
|
|
}
|
|
|
|
function contains_element() {
|
|
local e
|
|
for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
|
|
return 1
|
|
}
|
|
|