osquery-1/tools/provision.sh

100 lines
2.7 KiB
Bash
Raw Normal View History

2014-09-24 05:14:28 +00:00
#!/usr/bin/env bash
# Copyright (c) 2014-present, 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
# of patent rights can be found in the PATENTS file in the same directory.
set -e
2016-03-04 20:06:42 +00:00
CFLAGS="-fPIE -fPIC -Os -DNDEBUG -march=x86-64 -mno-avx"
2016-02-23 05:40:00 +00:00
CXXFLAGS="$CFLAGS"
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"
DEPS_URL=https://osquery-packages.s3.amazonaws.com/deps
export PATH="$PATH:/usr/local/bin"
source "$SCRIPT_DIR/lib.sh"
source "$SCRIPT_DIR/provision/lib.sh"
2014-11-09 00:55:19 +00:00
function main() {
platform OS
distro $OS DISTRO
2015-05-10 00:32:24 +00:00
threads THREADS
if ! hash sudo 2>/dev/null; then
2015-10-14 23:05:12 +00:00
echo "Please install sudo in this machine"
exit 0
fi
if [[ $1 = "get_platform" ]]; then
echo "$OS;$DISTRO"
return 0
fi
mkdir -p "$WORKING_DIR"
2014-11-13 06:33:27 +00:00
if [[ ! -z "$SUDO_USER" ]]; then
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
cd "$WORKING_DIR"
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
log "detected centos ($DISTRO)"
source "$SCRIPT_DIR/provision/centos.sh"
main_centos
elif [[ $OS = "rhel" ]]; then
log "detected rhel ($DISTRO)"
source "$SCRIPT_DIR/provision/rhel.sh"
main_rhel
elif [[ $OS = "amazon" ]]; then
log "detected amazon ($DISTRO)"
source "$SCRIPT_DIR/provision/amazon.sh"
main_amazon
elif [[ $OS = "ubuntu" ]]; then
log "detected ubuntu ($DISTRO)"
source "$SCRIPT_DIR/provision/ubuntu.sh"
main_ubuntu
elif [[ $OS = "darwin" ]]; then
log "detected mac os x ($DISTRO)"
source "$SCRIPT_DIR/provision/darwin.sh"
main_darwin
2014-11-12 19:15:17 +00:00
elif [[ $OS = "freebsd" ]]; then
log "detected freebsd ($DISTRO)"
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
elif [[ $OS = "debian" ]]; then
log "detected debian ($DISTRO)"
source "$SCRIPT_DIR/provision/debian.sh"
main_debian
else
fatal "could not detect the current operating system. exiting."
fi
cd "$SCRIPT_DIR/../"
2014-11-16 09:31:59 +00:00
sudo pip install --upgrade pip
sudo pip install -r requirements.txt
2015-04-01 08:10:28 +00:00
2016-01-21 10:32:53 +00:00
initialize $OS
}
2014-11-09 00:55:19 +00:00
check $1 $2
main $1