forked from dradis/meta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify.sh
executable file
·237 lines (216 loc) · 6.62 KB
/
verify.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
231
232
233
234
235
236
237
#!/bin/bash
#
# Dradis Framework dependencies verification script
#
# Description:
# This script will try to determine whether all the dependencies required to
# use the Dradis Framework are present in the system providing hints on how to
# install the missing dependencies. The system will NOT be modified by the
# script.
#
# License:
# This file may be used under the terms of the GNU General Public
# License version 2.0 as published by the Free Software Foundation
# and appearing in the file LICENSE.txt included in the packaging of
# this file.
#
# Copyright: Daniel Martin Gomez <etd[-at-]nomejortu.com>
echo
echo "Dradis Framework dependencies verification script"
echo "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --"
echo
echo " This script will try to determine whether all the dependencies required to"
echo "use the Dradis Framework are present in the system providing hints on how to"
echo "install the missing dependencies. The system will NOT be modified by the"
echo "script."
echo
echo -e "Please send your feedback about this script to:\n\tfeedback [you-know-what] dradisframework.org"
echo
echo
EXTENDED=0
#echo "There are a number of verifications you can perform:"
#echo " 1) Standard: Ruby interpreter and database drivers (recommended)"
#echo " 2) Extended: Ruby interpreter, database drivers and GUI libraries"
#
#echo -e "What set of checks do you want to run? [1] \c"
#read CHOICE
#
#case $CHOICE in
# 2) EXTENDED=1
#esac
#
#echo
if [ $EXTENDED -eq 1 ]; then
echo "Running Extended checks."
else
echo "Running Standard checks."
fi;
echo
# verify ruby
echo -n "Looking for Ruby interpreter... "
which ruby > /dev/null
if [ $? -eq 0 ]; then
RUBY_EXEC=`which ruby`
echo -e 'found [\E[32;40m' $RUBY_EXEC '\E[0m].'
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "Ruby interpreter not found. Try:"
echo " apt-get install ruby irb rdoc ruby-dev libopenssl-ruby"
echo
exit 1
fi;
# verify ruby-dev (mkmf) for native extension support
echo -n "Checking for support to compile native extensions... "
ruby -rmkmf -e nil 2> /dev/null
if [ $? -eq 0 ]; then
echo "found."
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "Ruby development libraries not found. Try:"
echo " apt-get install ruby-dev libopenssl-ruby"
echo
exit 2
fi;
# verify gems
echo -n "Looking for RubyGems and the 'gem' command... "
which gem > /dev/null
if [ $? -eq 0 ]; then
GEM_EXEC=`which gem`
echo -e 'found [\E[32;40m' $GEM_EXEC '\E[0m].'
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "RubyGems not found. Try:"
echo " apt-get install rubygems"
echo
exit 3
fi;
# verify Bundler gem
echo -n "Looking for the Ruby Bundler gem [bundler]... "
ruby -rrubygems -e "gem 'bundler', '~> 1.0'" 2> /dev/null
if [ $? -eq 0 ]; then
BUNDLER_VERSION=`ruby -rrubygems -e "require 'bundler/version'; puts Bundler::VERSION"`
echo -e 'found [ \E[32;40mv'$BUNDLER_VERSION'\E[0m ].'
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "Bundler ruby gem (bundler [~> 1.0]) not found. Try: "
echo " gem install bundler"
echo
exit 4
fi;
# verify Bundler binary
echo "Looking for the Ruby Bundler binary... "
echo -e -n ' ** locating using the PATH variable... '
which bundle > /dev/null
if [ $? -eq 0 ]; then
BUNDLER_EXEC=`which bundle`
BUNDLER_IN_PATH=1
echo -e 'found [\E[32;40m' $BUNDLER_EXEC '\E[0m].'
else
BUNDLER_IN_PATH=0
echo -e '\E[31;40mNOT found\E[0m'
echo -e -n ' ** locating using RubyGems... '
GEM_BINDIR=`ruby -rrubygems -e "puts Gem::bindir"`
if [ -x $GEM_BINDIR'/bundle' ]; then
BUNDLER_EXEC=$GEM_BINDIR'/bundle'
echo -e 'found [\E[32;40m' $BUNDLER_EXEC '\E[0m].'
else
echo '\E[31;40mNOT found.\E[0m Unable to locate Bundler binary.'
echo
exit 5
fi;
fi;
# verify SQLite3 libraries
echo -n "Looking for the SQLite3 libraries... "
ruby -rmkmf -e "if (have_header( 'sqlite3.h' ) && have_library( 'sqlite3', 'sqlite3_open' )) then exit 0 else exit 1 end" > /dev/null
if [ $? -eq 0 ]; then
echo "found."
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "SQLite3 libraries not found. Try: "
echo " apt-get install libsqlite3-0 libsqlite3-dev"
echo
exit 6
fi;
# verify SQLite3 bindings for Ruby
echo -n "Looking for the SQLite3 ruby gem [sqlite3]... "
ruby -rrubygems -e "gem 'sqlite3', '>=1.2.4'" 2> /dev/null
if [ $? -eq 0 ]; then
SQLITERUBY_VERSION=`ruby -rrubygems -e "require 'sqlite3/version'; puts SQLite3::Version::STRING"`
echo -e 'found [ \E[32;40mv'$SQLITERUBY_VERSION'\E[0m ].'
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "SQLite3 ruby gem (sqlite3 [>= 1.2.4]) not found. Try: "
echo " gem install sqlite3"
echo
exit 7
fi;
if [ $EXTENDED -eq 1 ]; then
# verify wxWidgets libraries
echo -n "Looking for wxWidgets 2.8 (GTK backend) libraries... "
# TODO: the full list should be whatever `wx-config --libs` returns, however
# wx-config only comes with libwxgtk2.8-dev which is not required
# because the gem is not compiled. We assume having the main
# 'wx_baseu-2.8' component will be good enough
#wx_gtk2u_core-2.8
#ruby -rmkmf -e "if (have_library( 'wx_baseu-2.8' )) then exit 0 else exit 1 end" > /dev/null
ruby -rmkmf -e "if (have_library( 'wx_gtk2u_core-2.8' )) then exit 0 else exit 1 end" > /dev/null
if [ $? -eq 0 ]; then
echo "found."
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "wxWidgets 2.8 (GTK) libraries not found. Try: "
echo " apt-get install libwxgtk2.8-0 libwxgtk2.8-dev"
echo
exit 8
fi;
# verify wxWidgets bindings for Ruby
echo -n "Looking for the wxWidgets ruby gem [wxruby]... "
ruby -rrubygems -e "gem 'wxruby', '>=1.9.9'" 2> /dev/null
if [ $? -eq 0 ]; then
WXRUBY_VERSION=`ruby -rrubygems -e "require 'wx'; puts Wxruby2::WXRUBY_VERSION"`
echo -e 'found (\E[32;40mv'$WXRUBY_VERSION'\E[0m).'
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "wxWidgets ruby gem (wxruby [>=1.9.9]) not found. Try: "
echo " gem install wxruby"
echo
exit 9
fi;
fi;
# verify LibXML2 libraries and headers
echo -n "Looking for the LibXML2 libraries and headers... "
which xml2-config > /dev/null
if [ $? -eq 0 ]; then
echo "found."
else
echo -e '\E[31;40mNOT found\E[0m'
echo
echo "LibXML2 libraries not found. Try: "
echo " apt-get install libxml2-dev libxslt1-dev"
echo
exit 10
fi;
# clean up
if [ -e "mkmf.log" ]; then
rm mkmf.log
fi;
echo
echo "Congratulations. You seem to be ready to run the Dradis Framework."
echo
echo "Remember that you still need to go to the server/ folder and run:"
if [ $BUNDLER_IN_PATH -eq 1 ]; then
echo -e "\tbundle install"
else
echo -e "\t$BUNDLER_EXEC install"
fi;
echo
echo "Enjoy!"
echo