forked from endgameinc/binarypig
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-ubuntu-vagrant.sh
executable file
·231 lines (192 loc) · 4.61 KB
/
install-ubuntu-vagrant.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
if [ $(whoami) != "root" ];
then
echo "This script needs to run as root"
exit 1
fi
set -e
# Change these to suit you environment, they are configured for a vagrant install
PACKAGE_DIR=/vagrant/packages
ES_CLUSTERNAME="binary-pig-dev-$(date +%s)"
cd $PACKAGE_DIR
./get_packages.sh
# basic requirements
apt-get update
apt-get install -y python-pip
apt-get install -y curl
apt-get install -y git
apt-get install -y python-dev
#
# Install binarypig
#
cd /opt/
git clone https://github.com/jt6211/binarypig.git
cd /opt/binarypig
#
# Install Oracle's Java 7
#
apt-get install -y python-software-properties
add-apt-repository ppa:webupd8team/java
apt-get update
apt-get install -y oracle-java7-installer
apt-get install oracle-java7-set-default
#
# Install ES
#
dpkg -i $PACKAGE_DIR/elasticsearch-1.2.1.deb
mkdir /usr/share/elasticsearch/plugins
sed -i'.orig' "s/^.*cluster.name.*/cluster.name: ${ES_CLUSTERNAME}/" /etc/elasticsearch/elasticsearch.yml
update-rc.d elasticsearch defaults 95 10
/etc/init.d/elasticsearch start
# TODO: give ES more RAM
while true;
do
curl -s http://localhost:9200 > /dev/null && break || (echo ES seems to still be starting; sleep 3)
done
echo "ES Started and Responsive"
cd /opt/binarypig/elasticsearch
. put_settings.sh
#
# Install Hadoop
#
dpkg -i $PACKAGE_DIR/hadoop_1.2.1-1_x86_64.deb
sed -i'' 's#export JAVA_HOME=.*#export JAVA_HOME=/usr/lib/jvm/java-7-oracle#' /etc/hadoop/hadoop-env.sh
ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
cat > /etc/hadoop/core-site.xml <<EOF
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/var/hadoop/hadoop-\${user.name}</value>
</property>
</configuration>
EOF
cat > /etc/hadoop/hdfs-site.xml <<EOF
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
EOF
cat > /etc/hadoop/mapred-site.xml <<EOF
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
EOF
hadoop namenode -format
start-all.sh
hadoop fs -mkdir /tmp/
hadoop fs -mkdir /user
hadoop fs -mkdir /user/root
#
# Install Pig
#
cd /opt/
tar zxvf $PACKAGE_DIR/pig-0.12.1.tar.gz
echo "export PIG_HOME=/opt/pig-0.12.1" >> /root/.bashrc
cd /usr/local/bin
ln -s /opt/pig-0.12.1/bin/pig
echo 'export JAVA_HOME=/usr/lib/jvm/java-7-oracle' >> /root/.bashrc
#
# Maven
#
cd /opt
tar zxvf $PACKAGE_DIR/apache-maven-3.2.2-bin.tar.gz
cd /usr/local/bin
ln -s /opt/apache-maven-3.2.2/bin/mvn
# Binary Pig Scripts deps
# yara
apt-get install -y yara
pip install yara
# clamscan
apt-get install -y clamav
# hasher
pip install bitstring
pip install pefile
pip install anyjson
# peframe
cd /opt/
git clone git://github.com/jt6211/peframe.git
cp -r peframe/* /opt/binarypig/scripts/
# pehashd
cd /opt
git clone https://github.com/endgameinc/pehashd.git
cd pehashd
apt-get install -y build-essential libffi-dev python-dev automake autoconf
BUILD_LIB=1 pip install ssdeep
pip install -r requirements.txt
cat > pehashd.cfg <<EOF
[server]
daemon = 1
pidfile = /tmp/pehashd.pid
host = 127.0.0.1
port = 3370
max_size_mb = 5
EOF
python pehashd.py > /tmp/pehashd.log
# yara daemon
cd /opt
git clone git://github.com/jt6211/yarad.git
cd yarad
pip install -r requirements.txt
cat >yarad.cfg <<EOF
[server]
daemon = 1
pidfile = /tmp/yarad.pid
rules_dir = yara_rules
host = 127.0.0.1
port = 3369
max_size_mb = 5
EOF
python yarad.py > /tmp/yarad.log
# Build Java libs
cd /opt/binarypig/
./build.sh
./install_wonderdog.sh
#
# install the webapp
#
apt-get install -y mysql-server python-mysqldb libmysqlclient-dev
# enter password123 when prompted
cd /opt/binarypig/webapp
pip install virtualenv
virtualenv env
. env/bin/activate
pip install -r requirements.txt
echo -n "Database root password: "
read DBPASS
cat > project/local_settings.py <<EOF
#!/usr/bin/env python
ES_SETTINGS = {
'ES_HOSTS':['localhost:9200',],
'INDEX':"binarypig",
'FACET_SIZE':100
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'binarypig',
'USER': 'root',
'PASSWORD': '$DBPASS',
'HOST': 'localhost',
'PORT': '3306',
}
}
EOF
echo 'create database binarypig;' | mysql -p --password=$DBPASS
./manage.py syncdb
echo "Install complete! Run this to start the dev webserver."
echo ""
echo " cd /opt/binarypig/webapp"
echo " . env/bin/activate"
echo " ./manage.py runserver 0.0.0.0:8000"
echo ""
echo "After running the above, you can visit http://10.254.254.100:8000/search/ in your web browser"