2017-10-27 21:31:56 +02:00
#!/bin/bash
2019-05-29 06:15:49 +02:00
## disable -e for production systems
#set -e
## Debug mode
2018-07-13 15:37:10 +02:00
#set -x
2017-10-27 21:31:56 +02:00
2019-07-01 08:15:00 +02:00
# Functions
get_distribution( ) {
lsb_dist = ""
# Every system that we officially support has /etc/os-release
if [ -r /etc/os-release ] ; then
lsb_dist = " $( . /etc/os-release && echo " $ID " ) "
fi
# Returning an empty string here should be alright since the
# case statements don't act unless you provide an actual value
echo " $lsb_dist " | tr '[:upper:]' '[:lower:]'
}
2019-06-21 12:35:53 +02:00
sudo chmod -R g+w .
if ! id zmqs >/dev/null 2>& 1; then
2019-07-01 08:15:00 +02:00
if [ " $( get_distribution) " = = "rhel" ] ; then
# Create zmq user
sudo useradd -U -G apache -m -s /usr/bin/bash zmqs
# Adds right to www-data to run ./start-zmq as zmq
echo "apache ALL=(zmqs) NOPASSWD:/bin/bash /var/www/misp-dashboard/start_zmq.sh" | sudo tee /etc/sudoers.d/apache
else
# Create zmq user
sudo useradd -U -G www-data -m -s /bin/bash zmqs
# Adds right to www-data to run ./start-zmq as zmq
echo "www-data ALL=(zmqs) NOPASSWD:/bin/bash /var/www/misp-dashboard/start_zmq.sh" | sudo tee /etc/sudoers.d/www-data
fi
2019-06-21 12:35:53 +02:00
fi
2019-07-02 09:14:35 +02:00
sudo apt-get install python3-virtualenv virtualenv screen redis-server unzip net-tools -y
2017-10-27 21:31:56 +02:00
if [ -z " $VIRTUAL_ENV " ] ; then
2019-05-29 06:15:49 +02:00
virtualenv -p python3 DASHENV ; DASH_VENV = $?
if [ [ " $DASH_VENV " != "0" ] ] ; then
echo "Something went wrong with either the update or install of the virtualenv."
echo "Please investigate manually."
exit $DASH_VENV
fi
2017-10-30 09:17:57 +01:00
2017-10-27 21:31:56 +02:00
. ./DASHENV/bin/activate
fi
2018-11-21 04:33:04 +01:00
pip3 install -U -r requirements.txt
2017-10-27 21:31:56 +02:00
2017-10-30 09:17:57 +01:00
## config
2018-03-15 16:17:57 +01:00
if [ -e "config/config.cfg" ] ; then
diff -u config/config.cfg.default config/config.cfg
if [ " $? " = = "0" ] ; then
cp -f config/config.cfg.default config/config.cfg
else
echo "Your config has changes, giving you a chance to see the changes and decide if you want to overwrite"
cp -i config/config.cfg.default config/config.cfg
fi
2018-03-15 17:02:53 +01:00
else
cp -i config/config.cfg.default config/config.cfg
2018-04-06 07:52:34 +02:00
echo "Sanitizing MaxMindDB Path"
sed -i " s|pathMaxMindDB=./data/GeoLite2-City/GeoLite2-City.mmdb|pathMaxMindDB= $PWD /data/GeoLite2-City/GeoLite2-City.mmdb| " config/config.cfg
sed -i " s|path_countrycode_to_coord_JSON=./data/country_code_lat_long.json|path_countrycode_to_coord_JSON= $PWD /data/country_code_lat_long.json| " config/config.cfg
2018-03-15 16:17:57 +01:00
fi
2017-11-10 13:25:38 +01:00
2017-10-27 21:31:56 +02:00
## Web stuff
pushd static/
2017-11-10 11:50:32 +01:00
mkdir -p css fonts js
2017-10-27 21:31:56 +02:00
popd
mkdir -p temp
2019-05-29 06:15:49 +02:00
NET_WGET = $( wget --no-cache -q https://www.misp-project.org/assets/images/misp-small.png -O static/pics/MISP.png; echo $? )
if [ [ " $NET_WGET " != "0" ] ] ; then
echo "The first wget we tried failed, please investigate manually."
exit $NET_WGET
fi
2019-05-29 04:18:32 +02:00
wget https://www.misp-project.org/favicon.ico -O static/favicon.ico
2017-10-27 21:31:56 +02:00
# jquery
JQVERSION = "3.2.1"
wget http://code.jquery.com/jquery-${ JQVERSION } .min.js -O ./static/js/jquery.min.js
2017-11-10 13:25:38 +01:00
# jquery flot
2017-10-27 21:31:56 +02:00
FLOTVERSION = "0.8.3"
wget http://www.flotcharts.org/downloads/flot-${ FLOTVERSION } .zip -O ./temp/flot-${ FLOTVERSION } .zip
unzip -o temp/flot-${ FLOTVERSION } .zip -d temp/
2017-11-10 11:50:32 +01:00
mv temp/flot/jquery.flot.js ./static/js
mv temp/flot/jquery.flot.pie.min.js ./static/js
mv temp/flot/jquery.flot.resize.js ./static/js
2017-11-10 13:25:38 +01:00
mv temp/flot/jquery.flot.time.js ./static/js
2017-10-27 21:31:56 +02:00
2017-11-10 13:25:38 +01:00
# jquery UI
2017-10-27 21:31:56 +02:00
JQUERYUIVERSION = "1.12.1"
wget https://jqueryui.com/resources/download/jquery-ui-${ JQUERYUIVERSION } .zip -O temp/jquery-ui.zip
unzip -o temp/jquery-ui.zip -d temp/
mv temp/jquery-ui-${ JQUERYUIVERSION } /jquery-ui.min.js ./static/js/jquery-ui.min.js
mv temp/jquery-ui-${ JQUERYUIVERSION } /jquery-ui.min.css ./static/css/jquery-ui.min.css
2017-10-27 21:36:22 +02:00
mkdir -p static/css/images
mv -f temp/jquery-ui-${ JQUERYUIVERSION } /images/* ./static/css/images/
2017-10-27 21:31:56 +02:00
# boostrap
2017-10-27 22:24:14 +02:00
#BOOTSTRAP_VERSION='4.0.0-beta.2'
#wget https://github.com/twbs/bootstrap/releases/download/v${BOOTSTRAP_VERSION}/bootstrap-${BOOTSTRAP_VERSION}-dist.zip -O temp/bootstrap-${BOOTSTRAP_VERSION}.zip
#unzip -o temp/bootstrap-${BOOTSTRAP_VERSION}.zip -d temp/bootstrap-${BOOTSTRAP_VERSION}-dist/
#mv temp/bootstrap-${BOOTSTRAP_VERSION}-dist/js/* ./static/js/
#mv temp/bootstrap-${BOOTSTRAP_VERSION}-dist/css/* ./static/css/
2017-10-27 22:05:12 +02:00
# sb-admin2
2017-10-27 21:31:56 +02:00
SBADMIN_VERSION = '3.3.7'
wget https://github.com/BlackrockDigital/startbootstrap-sb-admin-2/archive/v${ SBADMIN_VERSION } .zip -O temp/${ SBADMIN_VERSION } -2.zip
unzip -o temp/${ SBADMIN_VERSION } -2.zip -d temp/
mv temp/startbootstrap-sb-admin-2-${ SBADMIN_VERSION } /dist/js/* ./static/js/
mv temp/startbootstrap-sb-admin-2-${ SBADMIN_VERSION } /dist/css/* ./static/css/
mv temp/startbootstrap-sb-admin-2-${ SBADMIN_VERSION } /bower_components/font-awesome/fonts/* ./static/fonts
2017-11-10 13:25:38 +01:00
mv temp/startbootstrap-sb-admin-2-${ SBADMIN_VERSION } /bower_components/font-awesome/css/* ./static/css
mv temp/startbootstrap-sb-admin-2-${ SBADMIN_VERSION } /bower_components/bootstrap/fonts/* ./static/fonts
2017-10-27 21:31:56 +02:00
# leaflet
LEAFLET_VERSION = "1.2.0"
wget http://cdn.leafletjs.com/leaflet/v${ LEAFLET_VERSION } /leaflet.zip -O temp/leaflet.zip
unzip -o temp/leaflet.zip -d temp/
mv temp/leaflet.js ./static/js/
mv temp/leaflet.css ./static/css/
2017-10-30 09:55:50 +01:00
mv temp/images/* ./static/css/images/
2017-10-27 21:31:56 +02:00
# jvectormap
JVECTORMAP_VERSION = "2.0.3"
wget http://jvectormap.com/binary/jquery-jvectormap-${ JVECTORMAP_VERSION } .zip -O temp/jquery-jvectormap-${ JVECTORMAP_VERSION }
unzip -o temp/jquery-jvectormap-${ JVECTORMAP_VERSION } -d temp/
mv temp/jquery-jvectormap-2.0.3.css ./static/css
mv temp/jquery-jvectormap-2.0.3.min.js ./static/js
wget http://jvectormap.com/js/jquery-jvectormap-world-mill.js -O ./static/js/jquery-jvectormap-world-mill.js
2017-11-10 11:50:32 +01:00
# maxmind DB
2018-03-15 17:02:53 +01:00
rm -rf data/GeoLite2-City*
2017-11-08 17:12:58 +01:00
mkdir -p data
2017-10-28 10:27:31 +02:00
pushd data
wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz -O GeoLite2-City.tar.gz
tar xvfz GeoLite2-City.tar.gz
2018-03-15 17:02:53 +01:00
ln -s GeoLite2-City_* GeoLite2-City
2017-10-28 10:27:31 +02:00
rm -rf GeoLite2-City.tar.gz
2017-11-10 13:25:38 +01:00
popd
2017-11-10 11:50:32 +01:00
# DataTable
DATATABLE_VERSION = "1.10.16"
2017-11-10 13:25:38 +01:00
wget https://cdn.datatables.net/${ DATATABLE_VERSION } /js/jquery.dataTables.min.js -O ./static/js/jquery.dataTables.min.js
wget https://cdn.datatables.net/${ DATATABLE_VERSION } /css/dataTables.bootstrap.css -O ./static/css/dataTables.bootstrap.css
wget https://cdn.datatables.net/${ DATATABLE_VERSION } /js/dataTables.bootstrap.js -O ./static/js/dataTables.bootstrap.js
2017-11-10 11:50:32 +01:00
#typeahead
2017-11-10 13:25:38 +01:00
git clone https://github.com/bassjobsen/Bootstrap-3-Typeahead.git temp/Bootstrap-3-Typeahead
2017-11-10 11:50:32 +01:00
mv temp/Bootstrap-3-Typeahead/bootstrap3-typeahead.min.js ./static/js
2017-11-21 15:56:27 +01:00
#punchcard
2017-11-21 16:08:29 +01:00
git clone https://github.com/melenaos/jquery-punchcard.git temp/jquery-punchcard
2017-11-21 15:56:27 +01:00
mv temp/jquery-punchcard/src/punchcard.js ./static/js
mv temp/jquery-punchcard/src/punchcard.css ./static/css
2017-11-21 16:23:28 +01:00
wget https://momentjs.com/downloads/moment.js -O ./static/js/moment.js
2017-11-21 15:56:27 +01:00
2017-12-11 12:19:11 +01:00
# timeline
VISJS_VERSION = "4.21.0"
2018-01-15 15:41:37 +01:00
wget https://cdnjs.cloudflare.com/ajax/libs/vis/${ VISJS_VERSION } /vis.min.js -O ./static/js/vis.min.js
wget https://cdnjs.cloudflare.com/ajax/libs/vis/${ VISJS_VERSION } /vis.min.css -O ./static/css/vis.min.css
2017-12-11 12:19:11 +01:00
2017-10-27 21:31:56 +02:00
rm -rf ./temp