osquery-1/tools/lib.sh
2014-09-25 02:00:16 -07:00

47 lines
890 B
Bash
Executable File

#!/usr/bin/env bash
function platform() {
local __resultvar=$1
if [[ -f "/etc/yum.conf" ]]; then
eval $__resultvar="centos"
elif [[ -f "/etc/dpkg/dpkg.cfg" ]]; then
eval $__resultvar="ubuntu"
elif [[ -f "/etc/pf.conf" ]]; then
eval $__resultvar="darwin"
fi
}
function threads() {
local __resultvar=$1
platform OS
if [ $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
}