Created
February 6, 2017 18:35
-
-
Save JustinAzoff/3ed61c16cf78f51566b99614076d2421 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
REPO=git://git.bro.org/bro | |
STATE_FILE=/usr/local/bro/INSTALLED_VERSION | |
function die { | |
echo $* | |
exit 1 | |
} | |
function install_prereqs { | |
yum install -y caf || true #not needed for 2.4.1 and ealier, so ok to fail. | |
yum install -y git cmake cmake28 make gcc gcc-c++ flex bison libpcap-devel openssl-devel python-devel swig file-devel jemalloc-devel GeoIP-devel | |
} | |
function checkout_version { | |
VERSION=$1 | |
git fetch | |
git checkout -f $VERSION | |
git submodule update --recursive -f || git submodule update --recursive | |
} | |
function install_bro { | |
VERSION=$1 | |
if [ -e $STATE_FILE ] && grep -wq $VERSION $STATE_FILE ; then | |
echo "bro ${VERSION} already installed" | |
return | |
fi | |
install_prereqs | |
cd /usr/src | |
if [ ! -e bro ] ; then | |
git clone --recursive $REPO | |
fi | |
cd bro | |
checkout_version $VERSION | |
pcap="" | |
if [ -e /opt/snf ]; then | |
pcap="--with-pcap=/opt/snf" | |
fi | |
if [ -e /opt/pfring ] ; then | |
pcap="--with-pcap=/opt/pfring" | |
fi | |
malloc="" | |
if [ -e /usr/bin/jemalloc.sh -a $VERSION != "v2.2" ] ; then | |
malloc="--with-jemalloc=/usr/" | |
fi | |
broker="" | |
if grep -q -- --enable-broker configure ; then | |
broker="--enable-broker" | |
fi | |
./configure --prefix=/usr/local/bro $pcap $malloc $broker || die "configure failed" | |
make -j 8 -l 8 || die "build failed" | |
make install || die "install failed" | |
echo $VERSION > $STATE_FILE | |
/usr/local/bro/bin/broctl install || die "broctl install failed" | |
} | |
function main { | |
if [[ $# -ne 1 ]]; then | |
echo "Usage $0 version" | |
exit 1 | |
fi | |
VERSION=$1 | |
echo "Installing bro $VERSION" | |
install_bro $VERSION | |
} | |
main $* | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment