forked from arkime/arkime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasybutton-build.sh
executable file
·186 lines (156 loc) · 4.64 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
#!/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.47.4
YARA=1.7
GEOIP=1.6.0
PCAP=1.7.4
CURL=7.42.1
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 libssl-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
GLIBDIR=$(echo $GLIB | cut -d. -f 1-2)
wget http://ftp.gnome.org/pub/gnome/sources/glib/$GLIBDIR/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 https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/yara-project/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
echo "MOLOCH: Building libpcap";
# 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 --disable-usb --disable-canusb --disable-bluetooth; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
PCAPDIR=`pwd`/libpcap-$PCAP
PCAPBUILD="--with-libpcap=$PCAPDIR"
# curl
if [ ! -f "curl-$CURL.tar.gz" ]; then
wget http://curl.haxx.se/download/curl-$CURL.tar.gz
fi
if [ ! -f "curl-$CURL/lib/.libs/libcurl.a" ]; then
tar zxf curl-$CURL.tar.gz
( cd curl-$CURL; ./configure --disable-ldap --disable-ldaps --without-libidn --without-librtmp; $MAKE)
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
else
echo "MOLOCH: Not rebuilding curl"
fi
# Now build moloch
echo "MOLOCH: Building capture"
cd ..
echo "./configure --prefix=$TDIR $PCAPBUILD --with-yara=thirdparty/yara-$YARA --with-GeoIP=thirdparty/GeoIP-$GEOIP $WITHGLIB --with-curl=thirdparty/curl-$CURL"
./configure --prefix=$TDIR $PCAPBUILD --with-yara=thirdparty/yara-$YARA --with-GeoIP=thirdparty/GeoIP-$GEOIP $WITHGLIB --with-curl=thirdparty/curl-$CURL
$MAKE
if [ $? -ne 0 ]; then
echo "MOLOCH: $MAKE failed"
exit 1
fi
if [ $DOPFRING -eq 1 ]; then
(cd capture/plugins/pfring; $MAKE)
fi
exit 0