Skip to content

Instantly share code, notes, and snippets.

@JustinAzoff
Created February 6, 2017 18:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save JustinAzoff/3ed61c16cf78f51566b99614076d2421 to your computer and use it in GitHub Desktop.
Save JustinAzoff/3ed61c16cf78f51566b99614076d2421 to your computer and use it in GitHub Desktop.
#!/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