2014-09-24 05:14:28 +00:00
|
|
|
#!/usr/bin/env bash
|
2014-09-17 08:22:14 +00:00
|
|
|
|
2014-12-18 18:50:47 +00:00
|
|
|
# Copyright (c) 2014, Facebook, Inc.
|
|
|
|
# All rights reserved.
|
|
|
|
#
|
|
|
|
# This source code is licensed under the BSD-style license found in the
|
2014-12-30 22:24:49 +00:00
|
|
|
# LICENSE file in the root directory of this source tree. An additional grant
|
2014-12-18 18:50:47 +00:00
|
|
|
# of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
2014-09-17 08:22:14 +00:00
|
|
|
set -e
|
|
|
|
|
2015-08-07 00:09:26 +00:00
|
|
|
CFLAGS="-fPIE -fPIC -O2 -DNDEBUG -march=x86-64 -mno-avx"
|
2014-09-17 08:22:14 +00:00
|
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
2014-11-13 06:33:27 +00:00
|
|
|
BUILD_DIR="$SCRIPT_DIR/../build"
|
2015-05-13 07:31:02 +00:00
|
|
|
WORKING_DIR="/tmp/osquery-provisioning"
|
2015-04-30 22:47:33 +00:00
|
|
|
FILES_DIR="$SCRIPT_DIR/provision/files"
|
2015-05-29 00:21:20 +00:00
|
|
|
DEPS_URL=https://osquery-packages.s3.amazonaws.com/deps
|
2014-09-17 08:22:14 +00:00
|
|
|
export PATH="$PATH:/usr/local/bin"
|
|
|
|
|
2014-10-30 19:59:10 +00:00
|
|
|
source "$SCRIPT_DIR/lib.sh"
|
2015-04-03 04:34:55 +00:00
|
|
|
source "$SCRIPT_DIR/provision/lib.sh"
|
2014-11-09 00:55:19 +00:00
|
|
|
|
2014-09-17 08:22:14 +00:00
|
|
|
function main() {
|
|
|
|
platform OS
|
2014-11-12 05:34:59 +00:00
|
|
|
distro $OS DISTRO
|
2015-05-10 00:32:24 +00:00
|
|
|
threads THREADS
|
2014-11-12 05:34:59 +00:00
|
|
|
|
|
|
|
if [[ $1 = "get_platform" ]]; then
|
|
|
|
echo "$OS;$DISTRO"
|
|
|
|
return 0
|
|
|
|
fi
|
2014-09-17 08:22:14 +00:00
|
|
|
|
2014-10-30 19:59:10 +00:00
|
|
|
mkdir -p "$WORKING_DIR"
|
2014-11-13 06:33:27 +00:00
|
|
|
if [[ ! -z "$SUDO_USER" ]]; then
|
2014-11-16 21:59:19 +00:00
|
|
|
echo "chown -h $SUDO_USER $BUILD_DIR/*"
|
|
|
|
chown -h $SUDO_USER:$SUDO_GID "$BUILD_DIR" || true
|
|
|
|
if [[ $OS = "linux" ]]; then
|
|
|
|
chown -h $SUDO_USER:$SUDO_GID "$BUILD_DIR/linux" || true
|
|
|
|
fi
|
|
|
|
chown $SUDO_USER:$SUDO_GID "$WORKING_DIR" > /dev/null 2>&1 || true
|
2014-11-13 06:33:27 +00:00
|
|
|
fi
|
2014-10-30 19:59:10 +00:00
|
|
|
cd "$WORKING_DIR"
|
2014-09-17 08:22:14 +00:00
|
|
|
|
2015-04-30 22:47:33 +00:00
|
|
|
if [[ $OS = "oracle" ]]; then
|
|
|
|
log "detected oracle ($DISTRO)"
|
|
|
|
source "$SCRIPT_DIR/provision/oracle.sh"
|
|
|
|
main_oracle
|
|
|
|
elif [[ $OS = "centos" ]]; then
|
2014-11-12 05:34:59 +00:00
|
|
|
log "detected centos ($DISTRO)"
|
2015-04-03 04:34:55 +00:00
|
|
|
source "$SCRIPT_DIR/provision/centos.sh"
|
|
|
|
main_centos
|
|
|
|
elif [[ $OS = "rhel" ]]; then
|
|
|
|
log "detected rhel ($DISTRO)"
|
|
|
|
source "$SCRIPT_DIR/provision/rhel.sh"
|
|
|
|
main_rhel
|
2015-05-10 18:42:30 +00:00
|
|
|
elif [[ $OS = "amazon" ]]; then
|
|
|
|
log "detected amazon ($DISTRO)"
|
|
|
|
source "$SCRIPT_DIR/provision/amazon.sh"
|
|
|
|
main_amazon
|
2014-09-17 08:22:14 +00:00
|
|
|
elif [[ $OS = "ubuntu" ]]; then
|
2014-11-12 05:34:59 +00:00
|
|
|
log "detected ubuntu ($DISTRO)"
|
2015-04-03 04:34:55 +00:00
|
|
|
source "$SCRIPT_DIR/provision/ubuntu.sh"
|
|
|
|
main_ubuntu
|
2014-09-17 08:22:14 +00:00
|
|
|
elif [[ $OS = "darwin" ]]; then
|
2014-11-12 05:34:59 +00:00
|
|
|
log "detected mac os x ($DISTRO)"
|
2015-04-03 04:34:55 +00:00
|
|
|
source "$SCRIPT_DIR/provision/darwin.sh"
|
|
|
|
main_darwin
|
2014-11-12 19:15:17 +00:00
|
|
|
elif [[ $OS = "freebsd" ]]; then
|
|
|
|
log "detected freebsd ($DISTRO)"
|
2015-04-03 04:34:55 +00:00
|
|
|
source "$SCRIPT_DIR/provision/freebsd.sh"
|
|
|
|
main_freebsd
|
2015-08-19 04:50:30 +00:00
|
|
|
elif [[ $OS = "fedora" ]]; then
|
|
|
|
log "detected fedora ($DISTRO)"
|
|
|
|
source "$SCRIPT_DIR/provision/fedora.sh"
|
|
|
|
main_fedora
|
2015-08-14 20:23:08 +00:00
|
|
|
elif [[ $OS = "debian" ]]; then
|
|
|
|
log "detected debian ($DISTRO)"
|
|
|
|
source "$SCRIPT_DIR/provision/debian.sh"
|
|
|
|
main_debian
|
2014-09-17 08:22:14 +00:00
|
|
|
else
|
|
|
|
fatal "could not detect the current operating system. exiting."
|
|
|
|
fi
|
|
|
|
|
2014-10-30 19:59:10 +00:00
|
|
|
cd "$SCRIPT_DIR/../"
|
2014-11-16 09:31:59 +00:00
|
|
|
|
2015-04-03 07:44:27 +00:00
|
|
|
sudo pip install -r requirements.txt
|
2015-04-01 08:10:28 +00:00
|
|
|
|
|
|
|
# Reset any work or artifacts from build tests in TP.
|
|
|
|
(cd third-party && git reset --hard HEAD)
|
2014-09-24 04:22:42 +00:00
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2015-01-10 21:52:20 +00:00
|
|
|
|
|
|
|
# Remove any previously-cached variables
|
2015-01-11 06:12:38 +00:00
|
|
|
rm build/$OS/CMakeCache.txt >/dev/null 2>&1 || true
|
2014-09-17 08:22:14 +00:00
|
|
|
}
|
|
|
|
|
2014-11-09 00:55:19 +00:00
|
|
|
check $1 $2
|
2014-11-12 05:34:59 +00:00
|
|
|
main $1
|