forked from arkime/arkime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
easybutton-build.sh
executable file
·203 lines (173 loc) · 5.2 KB
/
easybutton-build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/sh
# Use this script to install OS dependencies, downloading and compile moloch dependencies, and compile moloch capture.
# This script will
# * use apt-get/yum to install OS dependancies
# * download known working versions of moloch dependancies
# * build them statically
# * configure moloch-capture to use them
# * build moloch-capture
GLIB=2.42.0
YARA=1.7
GEOIP=1.6.0
PCAP=1.7.2
NIDS=1.24
PFRING=6.0.2
TDIR="/data/moloch"
DOPFRING=0
while :
do
case $1 in
-p | --pf_ring | --pfring)
DOPFRING=1
shift
;;
-d | --dir)
TDIR=$2
shift 2
;;
-*)
echo "Unknown option '$1'"
exit 1
;;
*)
break
;;
esac
done
MAKE=make
# Installing dependencies
echo "MOLOCH: Installing Dependencies"
if [ -f "/etc/redhat-release" ]; then
yum -y install wget curl pcre pcre-devel pkgconfig flex bison gcc-c++ zlib-devel e2fsprogs-devel openssl-devel file-devel make gettext libuuid-devel perl-JSON bzip2-libs bzip2-devel perl-libwww-perl libpng-devel xz libffi-devel
if [ $? -ne 0 ]; then
echo "MOLOCH - yum failed"
exit 1
fi
fi
if [ -f "/etc/debian_version" ]; then
apt-get -y install wget curl libpcre3-dev uuid-dev libmagic-dev pkg-config g++ flex bison zlib1g-dev libffi-dev gettext libgeoip-dev make libjson-perl libbz2-dev libwww-perl libpng-dev xz-utils libffi-dev
if [ $? -ne 0 ]; then
echo "MOLOCH - apt-get failed"
exit 1
fi
fi
if [ $(uname) == "FreeBSD" ]; then
pkg_add -Fr wget curl pcre flex bison gettext e2fsprogs-libuuid glib gmake libexecinfo
MAKE=gmake
fi
echo "MOLOCH: Downloading and building static thirdparty libraries"
if [ ! -d "thirdparty" ]; then
mkdir thirdparty
fi
cd thirdparty
# glib
if [ $(uname) == "FreeBSD" ]; then
#Screw it, use whatever the OS has
WITHGLIB=" "
else
WITHGLIB="--with-glib2=thirdparty/glib-$GLIB"
if [ ! -f "glib-$GLIB.tar.xz" ]; then
wget http://ftp.gnome.org/pub/gnome/sources/glib/2.42/glib-$GLIB.tar.xz
fi
if [ ! -f "glib-$GLIB/gio/.libs/libgio-2.0.a" -o ! -f "glib-$GLIB/glib/.libs/libglib-2.0.a" ]; then
xzcat glib-$GLIB.tar.xz | tar xf -
(cd glib-$GLIB ; ./configure --disable-xattr --disable-shared --enable-static --disable-libelf --disable-selinux; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
else
echo "MOLOCH: Not rebuilding glib"
fi
fi
# yara
if [ ! -f "yara-$YARA.tar.gz" ]; then
wget http://yara-project.googlecode.com/files/yara-$YARA.tar.gz
fi
if [ ! -f "yara-$YARA/libyara/.libs/libyara.a" ]; then
tar zxf yara-$YARA.tar.gz
(cd yara-$YARA; ./configure --enable-static; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
else
echo "MOLOCH: Not rebuilding yara"
fi
# GeoIP
if [ ! -f "GeoIP-$GEOIP.tar.gz" ]; then
wget http://www.maxmind.com/download/geoip/api/c/GeoIP-$GEOIP.tar.gz
fi
if [ ! -f "GeoIP-$GEOIP/libGeoIP/.libs/libGeoIP.a" ]; then
tar zxf GeoIP-$GEOIP.tar.gz
# Crossing fingers, this is no longer needed
# Not sure why this is required on some platforms
# if [ -f "/usr/bin/libtoolize" ]; then
# (cd GeoIP-$GEOIP ; libtoolize -f)
# fi
(cd GeoIP-$GEOIP ; ./configure --enable-static; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
else
echo "MOLOCH: Not rebuilding libGeoIP"
fi
if [ $DOPFRING -eq 1 ]; then
# pfring
echo "MOLOCH: Building libpcap with pfring";
if [ ! -f "PF_RING-$PFRING.tar.gz" ]; then
wget -O PF_RING-$PFRING.tar.gz http://sourceforge.net/projects/ntop/files/PF_RING/PF_RING-$PFRING.tar.gz/download
fi
tar zxf PF_RING-$PFRING.tar.gz
(cd PF_RING-$PFRING; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: pfring failed to build"
exit 1
fi
PFRINGDIR=`pwd`/PF_RING-$PFRING
PCAPDIR=$PFRINGDIR/userland/libpcap
PCAPBUILD="--with-pfring=$PFRINGDIR"
else
echo "MOLOCH: Building libpcap without pfring";
# libpcap
if [ ! -f "libpcap-$PCAP.tar.gz" ]; then
wget http://www.tcpdump.org/release/libpcap-$PCAP.tar.gz
fi
tar zxf libpcap-$PCAP.tar.gz
(cd libpcap-$PCAP; ./configure --disable-dbus; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
PCAPDIR=`pwd`/libpcap-$PCAP
PCAPBUILD="--with-libpcap=$PCAPDIR"
fi
# libnids
if [ ! -f "libnids-$NIDS.tar.gz" ]; then
wget http://downloads.sourceforge.net/project/libnids/libnids/$NIDS/libnids-$NIDS.tar.gz
fi
if [ ! -f "libnids-$NIDS/src/libnids.a" ]; then
tar zxf libnids-$NIDS.tar.gz
if [ $(uname) == "FreeBSD" ]; then
( cd libnids-$NIDS; cp ../yara-$YARA/config.sub . ; touch src/alloca.h )
fi
( cd libnids-$NIDS; ./configure --enable-static --disable-libnet --with-libpcap=$PCAPDIR --disable-libglib; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
else
echo "MOLOCH: Not rebuilding libnids"
fi
# Now build moloch
echo "MOLOCH: Building capture"
cd ..
echo "./configure --prefix=$TDIR $PCAPBUILD --with-libnids=thirdparty/libnids-$NIDS --with-yara=thirdparty/yara-$YARA --with-GeoIP=thirdparty/GeoIP-$GEOIP $WITHGLIB"
./configure --prefix=$TDIR $PCAPBUILD --with-libnids=thirdparty/libnids-$NIDS --with-yara=thirdparty/yara-$YARA --with-GeoIP=thirdparty/GeoIP-$GEOIP $WITHGLIB
$MAKE
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
exit 0