2019-02-08 10:23:43 +01:00
#!/usr/bin/env bash
############################################################
###### #
##### Please AutoGenerated... ##
#### Do NOT was ###
### Manually It ####
## Change this Script... #####
# ######
############################################################
2019-02-08 11:11:00 +01:00
############################################################
#INSTALLATION INSTRUCTIONS #
##########################################################
2021-04-01 08:32:04 +02:00
#------------------------- for Linux Distributions
2019-02-08 10:23:43 +01:00
#
2019-02-08 11:11:00 +01:00
#-------------------------------------------------------|
# 0/ Quick MISP Instance on Debian Based Linux - Status |
#-------------------------------------------------------|
#
2021-04-06 08:00:12 +02:00
# 20210406: CentOS 7.9 tested and working. -- sCl
# 20210406: CentOS 8 tested and working. -- sCl
# 20210406: CentOS Stream tested and working. -- sCl
# 20210406: Ubuntu 21.04 tested and working. -- sCl
# 20210406: Ubuntu 20.04.2 tested and working. -- sCl
# 20210406: Ubuntu 18.04.5 tested and working. -- sCl
2022-03-03 11:51:14 +01:00
# 20220303: Kali Linux 2022.1 tested and working. -- sCl
2019-03-02 09:42:28 +01:00
#
#
#-------------------------------------------------------------------------------------------------|
# 1/ For other Debian based Linux distributions, download script and run as **unprivileged** user |
#-------------------------------------------------------------------------------------------------|
#
2019-05-17 15:26:57 +02:00
# The following installs only MISP Core:
# $ wget --no-cache -O /tmp/INSTALL.sh https://raw.githubusercontent.com/MISP/MISP/2.4/INSTALL/INSTALL.sh ; bash /tmp/INSTALL.sh -c
2019-03-02 09:42:28 +01:00
#
2019-05-17 15:26:57 +02:00
# This will install MISP Core and misp-modules
# $ wget --no-cache -O /tmp/INSTALL.sh https://raw.githubusercontent.com/MISP/MISP/2.4/INSTALL/INSTALL.sh ; bash /tmp/INSTALL.sh -c -M
2019-02-08 10:23:43 +01:00
#
#
2019-02-08 11:11:00 +01:00
#-------------------------------------------------------|
2019-03-02 09:42:28 +01:00
# 2/ For Kali, download and run Installer Script |
2019-02-08 11:11:00 +01:00
#-------------------------------------------------------|
#
2020-05-13 06:40:14 +02:00
# To install MISP on Kali copy paste the following to your shell:
2019-05-17 15:26:57 +02:00
# # wget --no-cache -O /tmp/misp-kali.sh https://raw.githubusercontent.com/MISP/MISP/2.4/INSTALL/INSTALL.sh && bash /tmp/misp-kali.sh
2022-03-03 11:51:14 +01:00
# NO other version then 2022.x supported, kthxbai.
2019-02-08 10:23:43 +01:00
# /!\ Please read the installer script before randomly doing the above.
# The script is tested on a plain vanilla Kali Linux Boot CD and installs quite a few dependencies.
#
#
2019-02-08 11:11:00 +01:00
#----------------------------------------------------------|
# 3/ The following script has been partially autogenerated |
#----------------------------------------------------------|
#
2019-02-08 10:23:43 +01:00
# To generate this script yourself, the following steps need to be taken.
# $ git clone https://github.com/SteveClement/xsnippet.git
# Make sure xsnippet resides somewhere in your $PATH - It is a shell script so a simple, copy to somewhere sane is enough.
# $ git clone https://github.com/MISP/MISP.git
2019-04-18 02:49:22 +02:00
# $ cd MISP/INSTALL ; ./INSTALL.tpl.sh
2019-02-08 10:23:43 +01:00
#
2019-02-08 11:11:00 +01:00
##
###
####----------------\
## Developer Note |
####--------------------------------------------------------------------------------------------------|
## In theory the order does not matter as everything is a self-contained function. |
# That said, ideally leave the order as is and do NOT change the lines as they are place-holders. |
# Script files that do NOT have a #_name.sh are scripts that have NO functions. This is by design. |
#-----------------------------------------------------------------------------------------------------|
#
# ToC #
#
#### BEGIN AUTOMATED SECTION ####
2019-02-09 16:23:48 +01:00
#
2019-02-08 10:23:43 +01:00
## 0_global-vars.sh ##
## 0_support-functions.sh ##
2019-02-09 16:23:48 +01:00
## 0_apt-upgrade.sh ##
2019-02-08 10:23:43 +01:00
## 0_sudoKeeper.sh ##
2019-02-09 16:23:48 +01:00
## 0_installCoreDeps.sh ##
2021-04-05 10:46:36 +02:00
## 0_upgradePhp74.sh ##
2020-04-27 09:30:34 +02:00
## 0_installDepsPhp74.sh ##
2019-02-09 16:23:48 +01:00
## 0_installDepsPhp73.sh ##
## 0_installDepsPhp72.sh ##
2019-02-28 04:03:52 +01:00
## 0_installDepsPhp70.sh ##
2019-02-09 16:23:48 +01:00
## 1_prepareDB.sh ##
## 1_apacheConfig.sh ##
## 1_mispCoreInstall.sh ##
## 1_installCake.sh ##
## 2_permissions.sh ##
## 2_configMISP.sh ##
2019-02-08 10:23:43 +01:00
## 2_core-cake.sh ##
## 2_gnupg.sh ##
2019-02-09 16:23:48 +01:00
## 2_logRotation.sh ##
## 2_backgroundWorkers.sh ##
2019-02-08 10:23:43 +01:00
## 3_misp-modules.sh ##
2021-03-31 10:07:45 +02:00
## 3_misp-modules-cake.sh ##
2019-02-08 10:23:43 +01:00
## 4_misp-dashboard.sh ##
## 4_misp-dashboard-cake.sh ##
## 5_mail_to_misp.sh ##
2019-02-12 13:15:38 +01:00
## 6_ssdeep.sh ##
2019-02-08 10:23:43 +01:00
## 6_viper.sh ##
2021-04-07 07:08:14 +02:00
## 0_RHEL_register.sh ##
2021-04-02 11:59:07 +02:00
## 0_RHEL7_SCL.sh ##
2021-04-07 07:08:14 +02:00
## 0_RHEL8_SCL.sh ##
2021-04-02 11:59:07 +02:00
## 0_RHEL7_EPEL.sh ##
2020-03-18 16:16:16 +01:00
## 0_CentOS_EPEL.sh ##
2021-04-07 03:39:12 +02:00
## 0_EPEL_REMI.sh ##
2021-04-06 08:00:12 +02:00
## 0_yumInstallCoreDeps7.sh ##
## 0_yumInstallCoreDeps8.sh ##
## 0_yumInstallHaveged.sh ##
## 1_mispCoreInstall_RHEL7.sh ##
## 1_mispCoreInstall_RHEL8.sh ##
2020-03-18 16:16:16 +01:00
## 1_installCake_RHEL.sh ##
## 1_prepareDB_RHEL.sh ##
2021-04-06 08:00:12 +02:00
## 1_apacheConfig_RHEL7.sh ##
## 1_apacheConfig_RHEL8.sh ##
2020-03-18 16:16:16 +01:00
## 1_firewall_RHEL.sh ##
2021-04-07 07:08:14 +02:00
## 2_permissions_RHEL7.sh ##
## 2_permissions_RHEL8.sh ##
2020-03-18 16:16:16 +01:00
## 2_logRotation_RHEL.sh ##
## 2_configMISP_RHEL.sh ##
## 3_configWorkers_RHEL.sh ##
## 3_misp-modules_RHEL.sh ##
2019-02-08 10:23:43 +01:00
# No functions scripts:
## apt-upgrade.sh ##
## postfix.sh ##
## interfaces.sh ##
2019-02-09 16:23:48 +01:00
#
2019-02-08 10:23:43 +01:00
### END AUTOMATED SECTION ###
2019-02-08 11:11:00 +01:00
# This function will generate the main installer.
2020-05-13 06:40:14 +02:00
# It is a helper function for the maintainers of the installer.
2019-02-11 17:04:16 +01:00
colors ( ) {
# Some colors for easier debug and better UX (not colorblind compatible, PR welcome)
RED = '\033[0;31m'
GREEN = '\033[0;32m'
LBLUE = '\033[1;34m'
YELLOW = '\033[0;33m'
HIDDEN = '\e[8m'
NC = '\033[0m'
}
2019-02-08 10:23:43 +01:00
generateInstaller ( ) {
2020-05-16 10:47:14 +02:00
if [ [ ! -f $( which xsnippet) ] ] ; then
2019-02-08 10:23:43 +01:00
echo 'xsnippet is NOT installed. Clone the repository below and copy the xsnippet shell script somehwere in your $PATH'
echo "git clone https://github.com/SteveClement/xsnippet.git"
exit 1
fi
2020-05-16 10:47:14 +02:00
if [ [ " $( echo $0 | grep -e '^\.\/' ) " != "./INSTALL.tpl.sh" ] ] ; then
2019-02-11 11:50:50 +01:00
echo -e " ${ RED } iAmError! ${ NC } "
2019-04-18 02:49:22 +02:00
echo -e "To generate the installer call it with './INSTALL.tpl.sh' otherwise things will break."
2019-02-11 11:50:50 +01:00
echo -e " You called: ${ RED } $0 ${ NC } "
exit 1
fi
2019-02-08 10:23:43 +01:00
mkdir installer ; cd installer
2019-04-18 02:49:22 +02:00
cp ../INSTALL.tpl.sh .
2019-02-08 10:23:43 +01:00
2019-02-08 11:11:00 +01:00
# Pull code snippets out of Main Install Documents
2021-03-31 10:07:45 +02:00
for f in ` echo INSTALL.ubuntu2004.md INSTALL.ubuntu1804.md xINSTALL.debian10.md xINSTALL.tsurugi.md INSTALL.rhel7.md INSTALL.rhel8.md` ; do
2019-02-08 10:23:43 +01:00
xsnippet . ../../docs/${ f }
done
2019-02-08 11:11:00 +01:00
# Pull out code snippets from generic Install Documents
2021-12-25 04:39:06 +01:00
for f in ` echo globalVariables.md mail_to_misp-debian.md MISP_CAKE_init.md misp-dashboard-debian.md misp-dashboard-rhel.md misp-dashboard-cake.md misp-modules-debian.md misp-modules-rhel.md misp-modules-cake.md gnupg.md ssdeep-debian.md sudo_etckeeper.md supportFunctions.md viper-debian.md` ; do
2019-02-08 10:23:43 +01:00
xsnippet . ../../docs/generic/${ f }
done
2019-02-08 11:11:00 +01:00
# TODO: Fix the below.
2019-02-08 10:23:43 +01:00
# $ for f in `echo ls [0-9]_*`; do
2019-04-18 02:49:22 +02:00
# $ perl -pe 's/## ${f} ##/`cat ${f}`/ge' -i INSTALL.sh
2019-02-08 10:23:43 +01:00
# $ done
#
# Temporary copy/paste holder
2019-04-18 02:49:22 +02:00
perl -pe 's/^## 0_global-vars.sh ##/`cat 0_global-vars.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_apt-upgrade.sh ##/`cat 0_apt-upgrade.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_sudoKeeper.sh ##/`cat 0_sudoKeeper.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_installCoreDeps.sh ##/`cat 0_installCoreDeps.sh`/ge' -i INSTALL.tpl.sh
2021-04-05 10:46:36 +02:00
perl -pe 's/^## 0_upgradePhp74.sh ##/`cat 0_upgradePhp74.sh`/ge' -i INSTALL.tpl.sh
2020-04-27 09:30:34 +02:00
perl -pe 's/^## 0_installDepsPhp74.sh ##/`cat 0_installDepsPhp74.sh`/ge' -i INSTALL.tpl.sh
2019-04-18 02:49:22 +02:00
perl -pe 's/^## 0_installDepsPhp73.sh ##/`cat 0_installDepsPhp73.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_installDepsPhp72.sh ##/`cat 0_installDepsPhp72.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_installDepsPhp70.sh ##/`cat 0_installDepsPhp70.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 1_prepareDB.sh ##/`cat 1_prepareDB.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 1_apacheConfig.sh ##/`cat 1_apacheConfig.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 1_mispCoreInstall.sh ##/`cat 1_mispCoreInstall.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 1_installCake.sh ##/`cat 1_installCake.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_permissions.sh ##/`cat 2_permissions.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_configMISP.sh ##/`cat 2_configMISP.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_support-functions.sh ##/`cat 0_support-functions.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_gnupg.sh ##/`cat 2_gnupg.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_logRotation.sh ##/`cat 2_logRotation.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_backgroundWorkers.sh ##/`cat 2_backgroundWorkers.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_core-cake.sh ##/`cat 2_core-cake.sh`/ge' -i INSTALL.tpl.sh
2021-03-31 10:07:45 +02:00
perl -pe 's/^## 3_misp-modules-cake.sh ##/`cat 3_misp-modules-cake.sh`/ge' -i INSTALL.tpl.sh
2019-04-18 02:49:22 +02:00
perl -pe 's/^## 3_misp-modules.sh ##/`cat 3_misp-modules.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 4_misp-dashboard-cake.sh ##/`cat 4_misp-dashboard-cake.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 4_misp-dashboard.sh ##/`cat 4_misp-dashboard.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 5_mail_to_misp.sh ##/`cat 5_mail_to_misp.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 6_viper.sh ##/`cat 6_viper.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 6_ssdeep.sh ##/`cat 6_ssdeep.sh`/ge' -i INSTALL.tpl.sh
2021-04-07 07:08:14 +02:00
perl -pe 's/^## 0_RHEL_register.sh ##/`cat 0_RHEL_register.sh`/ge' -i INSTALL.tpl.sh
2021-04-05 10:46:36 +02:00
perl -pe 's/^## 0_RHEL7_SCL.sh ##/`cat 0_RHEL7_SCL.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_RHEL8_SCL.sh ##/`cat 0_RHEL8_SCL.sh`/ge' -i INSTALL.tpl.sh
2020-03-18 16:16:16 +01:00
perl -pe 's/^## 0_CentOS_EPEL.sh ##/`cat 0_CentOS_EPEL.sh`/ge' -i INSTALL.tpl.sh
2021-04-05 10:46:36 +02:00
perl -pe 's/^## 0_RHEL7_EPEL.sh ##/`cat 0_RHEL7_EPEL.sh`/ge' -i INSTALL.tpl.sh
2021-04-06 08:00:12 +02:00
perl -pe 's/^## 0_yumInstallCoreDeps7.sh ##/`cat 0_yumInstallCoreDeps7.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_yumInstallCoreDeps8.sh ##/`cat 0_yumInstallCoreDeps8.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 0_yumInstallHaveged.sh ##/`cat 0_yumInstallHaveged.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 1_mispCoreInstall_RHEL7.sh ##/`cat 1_mispCoreInstall_RHEL7.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 1_mispCoreInstall_RHEL8.sh ##/`cat 1_mispCoreInstall_RHEL8.sh`/ge' -i INSTALL.tpl.sh
2021-04-05 10:46:36 +02:00
perl -pe 's/^## 0_EPEL_REMI.sh ##/`cat 0_EPEL_REMI.sh`/ge' -i INSTALL.tpl.sh
2020-03-18 16:16:16 +01:00
perl -pe 's/^## 1_installCake_RHEL.sh ##/`cat 1_installCake_RHEL.sh`/ge' -i INSTALL.tpl.sh
2021-04-07 07:08:14 +02:00
perl -pe 's/^## 2_permissions_RHEL7.sh ##/`cat 2_permissions_RHEL7.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_permissions_RHEL8.sh ##/`cat 2_permissions_RHEL8.sh`/ge' -i INSTALL.tpl.sh
2020-03-18 16:16:16 +01:00
perl -pe 's/^## 1_prepareDB_RHEL.sh ##/`cat 1_prepareDB_RHEL.sh`/ge' -i INSTALL.tpl.sh
2021-04-06 08:00:12 +02:00
perl -pe 's/^## 1_apacheConfig_RHEL7.sh ##/`cat 1_apacheConfig_RHEL7.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 1_apacheConfig_RHEL8.sh ##/`cat 1_apacheConfig_RHEL8.sh`/ge' -i INSTALL.tpl.sh
2020-03-18 16:16:16 +01:00
perl -pe 's/^## 1_firewall_RHEL.sh ##/`cat 1_firewall_RHEL.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_logRotation_RHEL.sh ##/`cat 2_logRotation_RHEL.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 2_configMISP_RHEL.sh ##/`cat 2_configMISP_RHEL.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 3_configWorkers_RHEL.sh ##/`cat 3_configWorkers_RHEL.sh`/ge' -i INSTALL.tpl.sh
perl -pe 's/^## 3_misp-modules_RHEL.sh ##/`cat 3_misp-modules_RHEL.sh`/ge' -i INSTALL.tpl.sh
2019-04-18 02:49:22 +02:00
cp INSTALL.tpl.sh ../INSTALL.sh
2019-02-08 10:23:43 +01:00
cd ..
2019-04-18 03:12:10 +02:00
for ALGO in $( echo "1 256 384 512" ) ; do
shasum -a ${ ALGO } INSTALL.sh > INSTALL.sh.sha${ ALGO }
done
2019-05-13 03:10:57 +02:00
[ [ " $( which rhash > /dev/null 2>& 1 ; echo $? ) " = = "0" ] ] && rhash --sfv --sha1 --sha256 --sha384 --sha512 INSTALL.sh > INSTALL.sh.sfv
2019-02-08 10:23:43 +01:00
rm -rf installer
2019-04-18 02:49:22 +02:00
echo -e " ${ LBLUE } Generated INSTALL.sh ${ NC } "
2019-02-08 10:23:43 +01:00
exit 0
}
# Simple debug function with message
2019-02-09 16:23:48 +01:00
# Make sure no alias exists
2019-09-17 15:40:12 +02:00
[ [ $( type -t debug) = = "alias" ] ] && unalias debug
2019-02-08 10:23:43 +01:00
debug ( ) {
2019-02-13 14:58:45 +01:00
echo -e " ${ RED } Next step: ${ NC } ${ GREEN } $1 ${ NC } " > /dev/tty
2020-05-16 10:47:14 +02:00
if [ [ ! -z ${ DEBUG } ] ] ; then
2019-02-13 14:58:45 +01:00
NO_PROGRESS = 1
echo -e " ${ RED } Debug Mode ${ NC } , press ${ LBLUE } enter ${ NC } to continue... " > /dev/tty
2019-02-13 05:48:39 +01:00
exec 3>& 1
2019-02-08 10:23:43 +01:00
read
2019-02-13 05:48:39 +01:00
else
# [Set up conditional redirection](https://stackoverflow.com/questions/8756535/conditional-redirection-in-bash)
#exec 3>&1 &>/dev/null
:
2019-02-08 10:23:43 +01:00
fi
}
2019-02-28 04:03:52 +01:00
installSupported ( ) {
2019-02-08 10:23:43 +01:00
space
echo "Proceeding with the installation of MISP core"
space
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Check if sudo is installed and etckeeper - functionLocation('generic/sudo_etckeeper.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && checkSudoKeeper
2019-05-13 02:58:21 +02:00
[ [ ! -z ${ MISP_USER } ] ] && [ [ ! -f /etc/sudoers.d/misp ] ] && echo " % ${ MISP_USER } ALL=(ALL:ALL) NOPASSWD:ALL " | sudo tee /etc/sudoers.d/misp
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-21 08:02:05 +01:00
# Set locale if not set - functionLocation('generic/supportFunctions.md')
checkLocale
# Upgrade system to make sure we install the latest packages - functionLocation('INSTALL.ubuntu1804.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && aptUpgrade
2019-02-21 08:02:05 +01:00
progress 4
2019-02-11 06:35:11 +01:00
# TODO: Double check how the user is added and subsequently used during the install.
# TODO: Work on possibility to install as user X and install MISP for user Y
2020-01-08 05:09:08 +01:00
# TODO: Check if logout needed. (run SUDO_CMD in installer)
2019-02-09 16:23:48 +01:00
# <snippet-begin add-user.sh>
2019-02-11 06:35:11 +01:00
# TODO: Double check how to properly handle postfix
2019-02-09 16:23:48 +01:00
# <snippet-begin postfix.sh>
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Pull in all possible MISP Environment variables - functionLocation('generic/globalVariables.md')
2019-02-11 17:04:16 +01:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && MISPvars
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Check if MISP user is installed and we do not run as root - functionLocation('generic/supportFunctions.md')
2019-02-12 15:04:21 +01:00
checkID
2019-02-13 07:00:31 +01:00
progress 4
2019-02-12 15:04:21 +01:00
2019-02-13 08:06:01 +01:00
# Starting friendly UI spinner
2019-02-13 13:01:04 +01:00
#spin &
#SPIN_PID=$!
#disown
#trap "kill -9 $SPIN_PID" `seq 0 15`
2019-02-13 08:06:01 +01:00
# Install Core Dependencies - functionLocation('INSTALL.ubuntu1804.md')
2019-02-14 02:43:31 +01:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installCoreDeps
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-28 04:03:52 +01:00
if [ [ " $1 " = ~ ^PHP= ] ] ; then
PHP_VER = $( echo $1 | cut -f2 -d= )
2020-04-30 07:56:06 +02:00
if [ [ " $PHP_VER " = = 7.2 ] ] ; then
2019-02-28 04:03:52 +01:00
# Install PHP 7.2 Dependencies - functionLocation('INSTALL.ubuntu1804.md')
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installDepsPhp72
2020-04-30 07:56:06 +02:00
elif [ [ " $PHP_VER " = = 7.3 ] ] ; then
2021-02-03 06:29:12 +01:00
# Install PHP 7.3 Dependencies - functionLocation('generic/supportFunctions.md')
2019-02-28 04:03:52 +01:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installDepsPhp73
2020-04-30 07:56:06 +02:00
elif [ [ " $PHP_VER " = = 7.4 ] ] ; then
2021-02-03 06:29:12 +01:00
# Install PHP 7.4 Dependencies - functionLocation('INSTALL.ubuntu2004.md')
2020-04-30 12:41:34 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installDepsPhp74
2020-04-30 07:56:06 +02:00
elif [ [ " $PHP_VER " = = 7.0 ] ] ; then
2019-02-28 04:03:52 +01:00
# Install PHP 7.0 Dependencies - functionLocation('generic/supportFunctions.md')
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installDepsPhp70
fi
else
2020-04-30 12:41:34 +02:00
# Install PHP 7.2 Dependencies by dangerous default - functionLocation('INSTALL.ubuntu1804.md')
2019-02-28 04:03:52 +01:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installDepsPhp72
fi
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Install Core MISP - functionLocation('INSTALL.ubuntu1804.md')
2019-02-11 17:04:16 +01:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installCore
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Install PHP Cake - functionLocation('INSTALL.ubuntu1804.md')
2019-02-11 17:04:16 +01:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && installCake
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Make sure permissions are sane - functionLocation('INSTALL.ubuntu1804.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && permissions
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
# TODO: Mysql install functions, make it upgrade safe, double check
2019-02-13 08:06:01 +01:00
# Setup Databse - functionLocation('INSTALL.ubuntu1804.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && prepareDB
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Roll Apache Config - functionLocation('INSTALL.ubuntu1804.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && apacheConfig
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Setup log logrotate - functionLocation('INSTALL.ubuntu1804.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && logRotation
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Generate MISP Config files - functionLocation('INSTALL.ubuntu1804.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && configMISP
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Generate GnuPG key - functionLocation('generic/gnupg.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && setupGnuPG
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Setup and start background workers - functionLocation('INSTALL.ubuntu1804.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && backgroundWorkers
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Run cake CLI for the core installation - functionLocation('generic/MISP_CAKE_init.md')
2020-05-16 09:41:32 +02:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && coreCAKE
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Disable spinner
2019-02-13 13:01:04 +01:00
#(kill $SPIN_PID 2>&1) >/dev/null
2019-02-13 08:06:01 +01:00
# Check if /usr/local/src is writeable by target install user - functionLocation('generic/supportFunctions.md')
2019-02-11 17:04:16 +01:00
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && checkUsrLocalSrc
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 13:01:04 +01:00
## Resume spinner
#spin &
#SPIN_PID=$!
#disown
#trap "kill -9 $SPIN_PID" `seq 0 15`
2019-02-13 08:06:01 +01:00
# Install misp-modules - functionLocation('generic/misp-modules-debian.md')
2019-02-11 01:40:51 +01:00
[ [ -n $MODULES ] ] || [ [ -n $ALL ] ] && mispmodules
2019-02-13 07:00:31 +01:00
progress 4
2019-02-11 06:35:11 +01:00
2021-04-05 12:17:55 +02:00
# Update Galaxies, Template Objects, Warning Lists, Notice Lists, Taxonomies - functionLocation('generic/MISP_CAKE_init.md')
[ [ -n $CORE ] ] || [ [ -n $ALL ] ] && updateGOWNT
progress 4
2021-04-02 11:59:07 +02:00
# Install misp-modules - functionLocation('generic/misp-modules-cake.md')
[ [ -n $MODULES ] ] || [ [ -n $ALL ] ] && modulesCAKE
progress 4
2019-02-13 08:06:01 +01:00
# Install Viper - functionLocation('generic/viper-debian.md')
2020-02-20 07:53:49 +01:00
## FIXME: The current state of Viper is broken, disabling any use.
2020-02-03 05:16:16 +01:00
##[[ -n $VIPER ]] || [[ -n $ALL ]] && viper
##progress 4
2019-02-11 06:35:11 +01:00
2019-02-13 08:06:01 +01:00
# Install ssdeep - functionLocation('generic/ssdeep-debian.md')
2019-02-12 15:04:21 +01:00
[ [ -n $SSDEEP ] ] || [ [ -n $ALL ] ] && ssdeep
2019-02-13 07:00:31 +01:00
progress 4
2019-02-12 15:04:21 +01:00
2019-02-13 08:06:01 +01:00
# Install misp-dashboard - functionLocation('generic/misp-dashboard-debian.md')
2020-02-20 07:53:49 +01:00
## FIXME: The current state of misp-dashboard is broken, disabling any use.
2020-05-16 09:41:32 +02:00
##[[ -n $DASHBOARD ]] || [[ -n $ALL ]] && mispDashboard ; dashboardCAKE
2020-02-20 04:33:11 +01:00
##progress 4
2019-02-10 12:29:23 +01:00
2019-02-13 08:06:01 +01:00
# Install Mail2MISP - functionLocation('generic/mail_to_misp-debian.md')
2019-02-11 17:56:00 +01:00
[ [ -n $MAIL2 ] ] || [ [ -n $ALL ] ] && mail2misp
2019-03-01 05:58:32 +01:00
progress 2
2019-02-11 01:40:51 +01:00
2019-03-01 05:50:25 +01:00
# Run tests
runTests
2019-03-01 05:58:32 +01:00
progress 2
2019-03-01 05:50:25 +01:00
2019-02-13 08:06:01 +01:00
# Run final script to inform the User what happened - functionLocation('generic/supportFunctions.md')
2019-02-11 01:40:51 +01:00
theEnd
2019-02-08 10:23:43 +01:00
}
2020-04-27 09:30:34 +02:00
# Main Kali Install function
2019-02-08 10:23:43 +01:00
installMISPonKali ( ) {
2021-02-03 06:29:12 +01:00
# Kali might have a bug on installs where libc6 is not up to date, this forces bash and libc to update - functionLocation('generic/supportFunctions.md')
2020-05-16 09:41:32 +02:00
kaliUpgrade
2019-02-13 14:58:45 +01:00
2019-02-13 15:43:17 +01:00
# Set locale if not set - functionLocation('generic/supportFunctions.md')
2019-02-13 14:58:45 +01:00
checkLocale
2019-02-13 15:43:17 +01:00
# Set Base URL - functionLocation('generic/supportFunctions.md')
setBaseURL
2022-03-03 11:51:14 +01:00
# Install PHP 7.4 (only php8.1 is available on latest Kali) - functionLocation('supportFunctions.md')
installDepsKaliPhp74
2021-02-03 06:29:12 +01:00
# Install PHP 7.4 Dependencies - functionLocation('INSTALL.ubuntu2004.md')
installDepsPhp74
2019-02-13 15:43:17 +01:00
2019-02-08 16:47:31 +01:00
# Set custom Kali only variables and tweaks
2019-02-08 10:23:43 +01:00
space
2019-02-09 16:23:48 +01:00
# The following disables sleep on kali/gnome
2019-02-13 14:58:45 +01:00
### FIXME: Disabling for now, maybe source of some issues.
2020-05-16 09:41:32 +02:00
##disableSleep
2019-02-13 14:58:45 +01:00
##debug "Sleeping 3 seconds to make sure the disable sleep does not confuse the execution of the script."
##sleep 3
2019-02-08 10:23:43 +01:00
2019-02-14 02:43:31 +01:00
# Kali specific dependencies - functionLocation('generic/supportFunctions.md')
2019-02-08 10:23:43 +01:00
debug "Installing dependencies"
2019-02-14 02:43:31 +01:00
installDeps
2019-02-08 10:23:43 +01:00
2019-02-14 02:43:31 +01:00
# Install Core Dependencies - functionLocation('INSTALL.ubuntu1804.md')
installCoreDeps
2019-02-13 15:09:19 +01:00
2019-02-08 10:23:43 +01:00
debug "Enabling redis and gnupg modules"
2021-02-03 06:29:12 +01:00
sudo phpenmod -v 7.4 redis
sudo phpenmod -v 7.4 gnupg
2019-02-08 10:23:43 +01:00
2020-05-16 15:38:10 +02:00
debug "Apache2 ops: dismod: status - dissite: 000-default enmod: ssl rewrite headers php7.3 ensite: default-ssl"
2020-05-16 09:41:32 +02:00
sudo a2dismod status
2021-02-03 06:29:12 +01:00
sudo a2enmod ssl rewrite headers php7.4
2020-05-16 09:41:32 +02:00
sudo a2dissite 000-default
sudo a2ensite default-ssl
2019-02-08 10:23:43 +01:00
debug "Restarting mysql.service"
2020-05-16 09:41:32 +02:00
sudo systemctl restart mysql.service
2019-02-08 10:23:43 +01:00
debug "git clone, submodule update everything"
2020-05-22 09:18:07 +02:00
sudo mkdir ${ PATH_TO_MISP }
sudo chown ${ WWW_USER } :${ WWW_USER } ${ PATH_TO_MISP }
cd ${ PATH_TO_MISP }
false; while [ [ $? -ne 0 ] ] ; do ${ SUDO_WWW } git clone https://github.com/MISP/MISP.git ${ PATH_TO_MISP } ; done
2019-02-08 10:23:43 +01:00
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } git config core.filemode false
2019-02-08 10:23:43 +01:00
2020-05-22 09:18:07 +02:00
cd ${ PATH_TO_MISP }
false; while [ [ $? -ne 0 ] ] ; do ${ SUDO_WWW } git submodule update --progress --init --recursive; done
2019-02-08 10:23:43 +01:00
# Make git ignore filesystem permission differences for submodules
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } git submodule foreach --recursive git config core.filemode false
2019-02-08 10:23:43 +01:00
2020-05-16 09:33:13 +02:00
sudo mkdir /var/www/.cache/
2019-02-08 10:23:43 +01:00
2022-03-03 11:51:14 +01:00
MISP_USER_HOME = $( sudo -Hiu ${ MISP_USER } env | grep HOME | cut -f 2 -d= )
sudo mkdir ${ MISP_USER_HOME } /.cache
sudo chown ${ MISP_USER } :${ MISP_USER } ${ MISP_USER_HOME } /.cache
2020-05-22 09:18:07 +02:00
sudo chown ${ WWW_USER } :${ WWW_USER } /var/www/.cache
2019-02-08 10:23:43 +01:00
2020-05-16 17:23:34 +02:00
## Not really needed...
## debug "Generating rc.local"
## genRCLOCAL
2019-02-09 16:23:48 +01:00
2019-02-08 16:47:31 +01:00
debug "Setting up main MISP virtualenv"
2019-02-09 16:23:48 +01:00
# Needs virtualenv
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } virtualenv -p python3 ${ PATH_TO_MISP } /venv
2019-02-08 15:41:42 +01:00
2020-02-20 04:33:11 +01:00
## FIXME: The current stat of misp-dashboard is broken, disabling any use.
##debug "Installing MISP dashboard"
##mispDashboard
2019-02-13 05:48:39 +01:00
2019-02-08 16:47:31 +01:00
debug "Installing python-cybox"
2020-05-22 09:18:07 +02:00
cd ${ PATH_TO_MISP } /app/files/scripts/python-cybox
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install .
2019-02-11 08:15:59 +01:00
2019-02-08 10:23:43 +01:00
debug "Installing python-stix"
2020-05-22 09:18:07 +02:00
cd ${ PATH_TO_MISP } /app/files/scripts/python-stix
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install .
2019-02-11 08:15:59 +01:00
2022-03-07 14:38:49 +01:00
debug "Installing maec"
2020-05-22 09:18:07 +02:00
cd ${ PATH_TO_MISP } /app/files/scripts/python-maec
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install .
2019-02-11 08:15:59 +01:00
2022-03-07 10:07:55 +01:00
# Install misp-stix
debug "Installing misp-stix"
cd ${ PATH_TO_MISP } /app/files/scripts/misp-stix
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install .
2019-02-11 08:15:59 +01:00
2019-02-08 10:23:43 +01:00
debug "Installing mixbox"
2020-05-22 09:18:07 +02:00
cd ${ PATH_TO_MISP } /app/files/scripts/mixbox
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install .
2019-02-11 08:15:59 +01:00
2019-02-08 10:23:43 +01:00
# install PyMISP
debug "Installing PyMISP"
2020-05-22 09:18:07 +02:00
cd ${ PATH_TO_MISP } /PyMISP
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install .
2019-02-08 10:23:43 +01:00
2019-02-11 08:15:59 +01:00
# install pydeep
2020-05-22 09:18:07 +02:00
false; while [ [ $? -ne 0 ] ] ; do ${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install git+https://github.com/kbandla/pydeep.git; done
2019-02-11 08:15:59 +01:00
# install lief
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install lief
2019-02-11 08:15:59 +01:00
# install python-magic
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install python-magic
2019-02-11 08:15:59 +01:00
2019-06-20 04:57:38 +02:00
# install plyara
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install plyara
2019-06-20 04:57:38 +02:00
2019-06-12 08:44:17 +02:00
# install zmq needed by mispzmq
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } ${ PATH_TO_MISP } /venv/bin/pip install zmq
2019-06-12 08:44:17 +02:00
2020-05-16 17:23:34 +02:00
debug "Installing cake"
2022-03-07 14:38:49 +01:00
composer74
2019-02-08 10:23:43 +01:00
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } cp -fa ${ PATH_TO_MISP } /INSTALL/setup/config.php ${ PATH_TO_MISP } /app/Plugin/CakeResque/Config/config.php
2019-02-08 10:23:43 +01:00
2020-05-22 09:18:07 +02:00
sudo chown -R ${ WWW_USER } :${ WWW_USER } ${ PATH_TO_MISP }
sudo chmod -R 750 ${ PATH_TO_MISP }
sudo chmod -R g+ws ${ PATH_TO_MISP } /app/tmp
sudo chmod -R g+ws ${ PATH_TO_MISP } /app/files
sudo chmod -R g+ws ${ PATH_TO_MISP } /app/files/scripts/tmp
2019-02-08 10:23:43 +01:00
debug "Setting up database"
2019-02-28 09:06:52 +01:00
if [ [ ! -e /var/lib/mysql/misp/users.ibd ] ] ; then
2021-02-03 06:29:12 +01:00
# Kill the anonymous users
2022-03-03 11:51:14 +01:00
sudo mysql -h ${ DBHOST } -e "DROP USER IF EXISTS ''@'localhost'"
2021-02-03 06:29:12 +01:00
# Because our hostname varies we'll use some Bash magic here.
2022-03-03 11:51:14 +01:00
sudo mysql -h ${ DBHOST } -e " DROP USER IF EXISTS ''@' $( hostname) ' "
2021-02-03 06:29:12 +01:00
# Kill off the demo database
2022-03-03 11:51:14 +01:00
sudo mysql -h ${ DBHOST } -e "DROP DATABASE IF EXISTS test"
2021-02-03 06:29:12 +01:00
# No root remote logins
2022-03-03 11:51:14 +01:00
sudo mysql -h ${ DBHOST } -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1')"
2021-02-03 06:29:12 +01:00
# Make sure that NOBODY can access the server without a password
2022-03-03 11:51:14 +01:00
sudo mysqladmin -h ${ DBHOST } -u " ${ DBUSER_ADMIN } " password " ${ DBPASSWORD_ADMIN } "
2021-02-03 06:29:12 +01:00
# Make our changes take effect
2022-03-03 11:51:14 +01:00
sudo mysql -h ${ DBHOST } -e "FLUSH PRIVILEGES"
2019-02-08 10:23:43 +01:00
2022-03-03 11:51:14 +01:00
sudo mysql -u ${ DBUSER_ADMIN } -p${ DBPASSWORD_ADMIN } -e " CREATE DATABASE ${ DBNAME } ; "
sudo mysql -u ${ DBUSER_ADMIN } -p${ DBPASSWORD_ADMIN } -e " GRANT USAGE ON *.* TO ${ DBUSER_MISP } @localhost IDENTIFIED BY ' ${ DBPASSWORD_MISP } '; "
sudo mysql -u ${ DBUSER_ADMIN } -p${ DBPASSWORD_ADMIN } -e " GRANT ALL PRIVILEGES ON ${ DBNAME } .* TO ' ${ DBUSER_MISP } '@'localhost'; "
sudo mysql -u ${ DBUSER_ADMIN } -p${ DBPASSWORD_ADMIN } -e "FLUSH PRIVILEGES;"
2019-02-08 10:23:43 +01:00
enableServices
2020-05-16 18:16:49 +02:00
debug "Populating database"
2022-03-03 11:51:14 +01:00
${ SUDO_WWW } cat ${ PATH_TO_MISP } /INSTALL/MYSQL.sql | mysql -u ${ DBUSER_MISP } -p${ DBPASSWORD_MISP } ${ DBNAME }
2019-02-08 10:23:43 +01:00
echo " <?php
class DATABASE_CONFIG {
public \$ default = array(
'datasource' = > 'Database/Mysql' ,
//'datasource' = > 'Database/Postgres' ,
'persistent' = > false,
'host' = > '$DBHOST' ,
'login' = > '$DBUSER_MISP' ,
'port' = > 3306, // MySQL & MariaDB
//'port' = > 5432, // PostgreSQL
'password' = > '$DBPASSWORD_MISP' ,
'database' = > '$DBNAME' ,
'prefix' = > '' ,
'encoding' = > 'utf8' ,
) ;
2020-05-22 09:18:07 +02:00
} " | ${ SUDO_WWW } tee ${ PATH_TO_MISP } /app/Config/database.php
2019-02-08 10:23:43 +01:00
else
echo "There might be a database already existing here: /var/lib/mysql/misp/users.ibd"
echo "Skipping any creations…"
sleep 3
fi
debug "Generating Certificate"
2020-05-16 09:33:13 +02:00
sudo openssl req -newkey rsa:4096 -days 365 -nodes -x509 \
2019-02-08 10:23:43 +01:00
-subj " /C= ${ OPENSSL_C } /ST= ${ OPENSSL_ST } /L= ${ OPENSSL_L } /O= ${ OPENSSL_O } /OU= ${ OPENSSL_OU } /CN= ${ OPENSSL_CN } /emailAddress= ${ OPENSSL_EMAILADDRESS } " \
-keyout /etc/ssl/private/misp.local.key -out /etc/ssl/private/misp.local.crt
debug "Generating Apache Conf"
genApacheConf
2020-05-16 09:33:13 +02:00
echo "127.0.0.1 misp.local" | sudo tee -a /etc/hosts
2019-02-08 10:23:43 +01:00
debug "Disabling site default-ssl, enabling misp-ssl"
2020-05-16 09:33:13 +02:00
sudo a2dissite default-ssl
sudo a2ensite misp-ssl
2019-02-08 10:23:43 +01:00
for key in upload_max_filesize post_max_size max_execution_time max_input_time memory_limit
do
2022-03-03 11:51:14 +01:00
sudo sed -i " s/^\( $key \).*/\1 = $( eval echo \$ { $key } ) / " ${ PHP_INI }
2019-02-08 10:23:43 +01:00
done
debug "Restarting Apache2"
2020-05-16 09:33:13 +02:00
sudo systemctl restart apache2
2019-02-08 10:23:43 +01:00
debug "Setting up logrotate"
2020-05-22 09:18:07 +02:00
sudo cp ${ PATH_TO_MISP } /INSTALL/misp.logrotate /etc/logrotate.d/misp
2020-05-16 09:33:13 +02:00
sudo chmod 0640 /etc/logrotate.d/misp
2019-02-08 10:23:43 +01:00
2020-05-22 09:18:07 +02:00
${ SUDO_WWW } cp -a ${ PATH_TO_MISP } /app/Config/bootstrap.default.php ${ PATH_TO_MISP } /app/Config/bootstrap.php
${ SUDO_WWW } cp -a ${ PATH_TO_MISP } /app/Config/core.default.php ${ PATH_TO_MISP } /app/Config/core.php
${ SUDO_WWW } cp -a ${ PATH_TO_MISP } /app/Config/config.default.php ${ PATH_TO_MISP } /app/Config/config.php
2019-02-08 10:23:43 +01:00
2020-05-22 09:18:07 +02:00
sudo chown -R ${ WWW_USER } :${ WWW_USER } ${ PATH_TO_MISP } /app/Config
sudo chmod -R 750 ${ PATH_TO_MISP } /app/Config
2019-02-08 10:23:43 +01:00
debug "Setting up GnuPG"
2020-05-16 09:41:32 +02:00
setupGnuPG
2019-02-08 10:23:43 +01:00
2019-02-27 05:47:40 +01:00
debug "Adding workers to systemd"
2020-05-16 17:53:50 +02:00
backgroundWorkers
2019-02-08 10:23:43 +01:00
debug "Running Core Cake commands"
2020-05-16 09:41:32 +02:00
coreCAKE
2020-05-16 17:23:34 +02:00
2020-02-20 07:53:49 +01:00
## FIXME: The current state of misp-dashboard is broken, disabling any use.
2020-05-16 09:41:32 +02:00
##dashboardCAKE
2019-02-08 10:23:43 +01:00
debug "Update: Galaxies, Template Objects, Warning Lists, Notice Lists, Taxonomies"
2020-05-16 09:41:32 +02:00
updateGOWNT
2019-02-08 10:23:43 +01:00
2020-05-16 17:23:34 +02:00
# This is not needed atm...
##gitPullAllRCLOCAL
2019-02-08 10:23:43 +01:00
2019-02-10 12:29:23 +01:00
checkUsrLocalSrc
2019-02-08 10:23:43 +01:00
debug "Installing misp-modules"
mispmodules
2021-04-02 11:59:07 +02:00
modulesCAKE
2019-02-08 10:23:43 +01:00
2020-02-20 07:53:49 +01:00
## FIXME: The current state of Viper is broken, disabling any use.
2020-02-03 05:16:16 +01:00
##debug "Installing Viper"
##viper
2019-02-08 10:23:43 +01:00
2019-02-12 13:15:38 +01:00
debug "Installing ssdeep"
ssdeep
2020-05-16 09:33:13 +02:00
sudo phpenmod -v 7.3 ssdeep
2019-02-12 13:15:38 +01:00
2019-02-08 10:23:43 +01:00
debug "Setting permissions"
permissions
debug "Running Then End!"
theEnd
}
2019-02-12 13:15:38 +01:00
# End installMISPonKali ()
2019-02-08 10:23:43 +01:00
2020-03-18 16:16:16 +01:00
# Main Install on RHEL function
installMISPRHEL ( ) {
if [ [ -n $SSDEEP ] ] || [ [ -n $MAIL2 ] ] ; then
echo "RHEL installation currently only supports Core and Modules"
echo "Ignoring other options..."
fi
if [ [ -n $CORE ] ] || [ [ -n $ALL ] ] ; then
space
2020-05-16 10:47:14 +02:00
echo " Proceeding with MISP core installation on RHEL ${ dist_version } "
2020-03-18 16:16:16 +01:00
space
2021-04-05 12:17:55 +02:00
2020-05-16 10:47:14 +02:00
id -u " ${ MISP_USER } " > /dev/null
if [ [ $? -eq 1 ] ] ; then
2020-03-18 16:16:16 +01:00
debug "Creating MISP user"
2021-04-06 08:00:12 +02:00
sudo useradd -G wheel -m " ${ MISP_USER } "
2020-03-18 16:16:16 +01:00
fi
2021-04-05 12:17:55 +02:00
# Register system if RHEL
if [ [ " ${ DISTRI } " = ~ ^[ rhel] .* ] ] ; then
registerRHEL
fi
2020-03-18 16:16:16 +01:00
debug "Enabling Extras Repos (SCL)"
2021-03-31 10:07:45 +02:00
if [ [ " ${ DISTRI } " = = "rhel7" ] ] ; then
2021-04-05 12:17:55 +02:00
enableReposRHEL7
2020-03-18 16:16:16 +01:00
enableEPEL
2021-04-05 12:17:55 +02:00
debug "Installing System Dependencies"
2021-04-06 08:00:12 +02:00
yumInstallCoreDeps7
installEntropyRHEL
2021-04-05 12:17:55 +02:00
debug "Installing MISP code"
installCoreRHEL7
debug "Install Cake PHP"
installCake_RHEL
2021-04-07 07:08:14 +02:00
debug "Setting File permissions"
permissions_RHEL7
2021-04-05 12:17:55 +02:00
debug "Preparing Database"
prepareDB_RHEL
2021-04-06 08:00:12 +02:00
apacheConfig_RHEL7
2020-03-18 16:16:16 +01:00
fi
2021-07-02 05:52:03 +02:00
if [ [ " ${ DISTRI %?? } " = = "fedora" ] ] ; then
enableREMI_fedora
2021-04-06 08:00:12 +02:00
yumInstallCoreDeps8
installEntropyRHEL
2021-04-05 12:17:55 +02:00
installCoreRHEL8
2021-04-07 03:39:12 +02:00
installCake_RHEL
2021-04-05 12:17:55 +02:00
permissions_RHEL8
2021-04-07 03:39:12 +02:00
prepareDB_RHEL
2021-04-05 12:17:55 +02:00
debug "Configuring Apache"
2021-04-06 08:36:14 +02:00
apacheConfig_RHEL8
2021-04-05 12:17:55 +02:00
fi
if [ [ " ${ DIST_VER } " = ~ ^[ 8] .* ] ] ; then
enableEPEL_REMI_8
2021-04-07 07:08:14 +02:00
enableOptionalRHEL8
2021-04-07 03:39:12 +02:00
yumInstallCoreDeps8
2021-04-05 12:17:55 +02:00
installCoreRHEL8
2021-04-07 03:39:12 +02:00
installCake_RHEL
2021-04-05 12:17:55 +02:00
permissions_RHEL8
2021-04-07 03:39:12 +02:00
prepareDB_RHEL
2021-04-05 12:17:55 +02:00
apacheConfig_RHEL8
fi
if [ [ " ${ DISTRI } " = = "centos7" ] ] ; then
centosEPEL
debug "Installing MISP code"
debug "Installing System Dependencies"
2021-04-06 08:00:12 +02:00
yumInstallCoreDeps7
installEntropyRHEL
2021-04-05 12:17:55 +02:00
installCoreRHEL7
debug "Install Cake PHP"
installCake_RHEL
2021-04-07 07:08:14 +02:00
debug "Setting File permissions"
permissions_RHEL7
2021-04-05 12:17:55 +02:00
debug "Preparing Database"
prepareDB_RHEL
debug "Configuring Apache"
2021-04-06 08:36:14 +02:00
apacheConfig_RHEL7
2021-04-05 12:17:55 +02:00
fi
2020-03-18 16:16:16 +01:00
debug "Enabling Haveged for additional entropy"
sudo yum install haveged -y
sudo systemctl enable --now haveged.service
debug "Setting up firewall"
firewall_RHEL
debug "Enabling log rotation"
logRotation_RHEL
debug "Configuring MISP"
configMISP_RHEL
debug "Setting up background workers"
configWorkersRHEL
debug "Optimizing Cake Installation"
coreCAKE
debug "Updating tables"
updateGOWNT
echo "Core Intallation finished, check on port 443 to see the Web UI"
fi
if [ [ -n $MODULES ] ] || [ [ -n $ALL ] ] ; then
space
echo "Installing MISP Modules"
space
mispmodulesRHEL
2021-04-05 12:17:55 +02:00
# Another sleep to avoid RC
sleep 3
2021-04-02 11:59:07 +02:00
modulesCAKE
2020-03-18 16:16:16 +01:00
echo "MISP modules installation finished."
fi
}
# End installMISPRHEL ()
2019-02-11 17:04:16 +01:00
## End Function Section ##
colors
2019-02-08 10:23:43 +01:00
debug "Checking if we are run as the installer template"
2019-04-18 02:49:22 +02:00
if [ [ " $0 " = = "./INSTALL.tpl.sh" || " $( echo $0 | grep -o -e 'INSTALL.tpl.sh' ) " = = "INSTALL.tpl.sh" ] ] ; then
2019-02-08 10:23:43 +01:00
generateInstaller
fi
2020-03-18 16:16:16 +01:00
debug "Checking Linux distribution and flavour..."
checkFlavour
2019-05-15 04:43:17 +02:00
debug "Checking if we are uptodate and checksums match"
checkInstaller
2019-02-11 06:35:11 +01:00
space
debug "Setting MISP variables"
MISPvars
debug "Checking for parameters or Unattended Kali Install"
2020-05-16 10:47:14 +02:00
if [ [ $# -eq 0 && " $0 " != "/tmp/misp-kali.sh" ] ] ; then
2019-02-08 10:23:43 +01:00
usage
exit
else
debug "Setting install options with given parameters."
2019-02-10 12:29:23 +01:00
# The setOpt/checkOpt function lives in generic/supportFunctions.md
2019-02-08 10:23:43 +01:00
setOpt $@
2019-02-10 12:29:23 +01:00
checkOpt core && echo " ${ LBLUE } MISP ${ NC } ${ GREEN } core ${ NC } selected "
checkOpt viper && echo " ${ GREEN } Viper ${ NC } selected "
checkOpt modules && echo " ${ LBLUE } MISP ${ NC } ${ GREEN } modules ${ NC } selected "
checkOpt dashboard && echo " ${ LBLUE } MISP ${ NC } ${ GREEN } dashboard ${ NC } selected "
checkOpt mail2 && echo " ${ GREEN } Mail 2 ${ NC } ${ LBLUE } MISP ${ NC } selected "
checkOpt all && echo " ${ GREEN } All options ${ NC } selected "
checkOpt pre && echo " ${ GREEN } Pre-flight checks ${ NC } selected "
checkOpt unattended && echo " ${ GREEN } unattended ${ NC } install selected "
2019-02-11 17:04:16 +01:00
checkOpt upgrade && echo " ${ GREEN } upgrade ${ NC } install selected "
checkOpt force && echo " ${ GREEN } force ${ NC } install selected "
# Check if at least core is selected if no other options that do not require core are set
if [ [ " $CORE " != "1" && " $ALL " != "1" && " $UPGRADE " != "1" && " $PRE " != "1" && " $0 " != "/tmp/misp-kali.sh" ] ] ; then
space
usage
echo "You need to at least select core, or -A to install everything."
echo " $0 -c # Is the minima for install options "
exit 1
fi
2019-02-08 10:23:43 +01:00
fi
2019-02-11 17:04:16 +01:00
# Add upgrade option to do upgrade pre flight
2019-02-11 07:49:30 +01:00
[ [ -n $PRE ] ] && preInstall
2019-02-11 17:04:16 +01:00
[ [ -n $UPGRADE ] ] && upgrade
2019-03-01 05:58:32 +01:00
[ [ -n $NUKE ] ] && nuke && exit
2019-02-28 09:06:52 +01:00
2019-07-01 08:46:14 +02:00
# TODO: Move support map to top
SUPPORT_MAP = "
2020-03-18 16:16:16 +01:00
x86_64-centos-7
2019-07-01 08:46:14 +02:00
x86_64-rhel-7
2021-03-31 10:07:45 +02:00
x86_64-centos-8
x86_64-rhel-8
x86_64-fedora-33
2021-12-25 04:39:06 +01:00
x86_64-fedora-34
x86_64-fedora-35
2019-07-01 08:46:14 +02:00
x86_64-debian-stretch
x86_64-debian-buster
x86_64-ubuntu-bionic
2020-04-30 06:40:13 +02:00
x86_64-ubuntu-focal
2021-02-15 03:59:34 +01:00
x86_64-ubuntu-hirsute
2022-05-23 12:11:13 +02:00
x86_64-ubuntu-jammy
2021-03-31 10:07:45 +02:00
x86_64-kali-2021.4
2022-03-02 15:01:12 +01:00
x86_64-kali-2022.1
x86_64-kali-2022.2
x86_64-kali-2022.3
x86_64-kali-2022.4
2019-07-01 08:46:14 +02:00
armv6l-raspbian-stretch
armv7l-raspbian-stretch
2021-04-27 19:41:06 +02:00
armv7l-raspbian-buster
2019-07-01 08:46:14 +02:00
armv7l-debian-jessie
armv7l-debian-stretch
armv7l-debian-buster
armv7l-ubuntu-bionic
2020-04-30 06:40:13 +02:00
armv7l-ubuntu-focal
2021-04-27 19:41:06 +02:00
aarch64-ubuntu-focal
aarch64-ubuntu-hirsute
2019-07-01 08:46:14 +02:00
"
# Check if we actually support this configuration
2019-07-02 05:28:35 +02:00
if ! echo " $SUPPORT_MAP " | grep " $( uname -m) - $FLAVOUR - $dist_version " >/dev/null; then
2019-07-01 08:46:14 +02:00
cat >& 2 <<-'EOF'
Either your platform is not easily detectable or is not supported by this
installer script.
Please visit the following URL for more detailed installation instructions:
https://misp.github.io/MISP/
EOF
exit 1
fi
2019-02-11 06:35:11 +01:00
# If Ubuntu is detected, figure out which release it is and run the according scripts
2020-05-16 10:47:14 +02:00
if [ [ " ${ FLAVOUR } " = = "ubuntu" ] ] ; then
2019-06-14 15:53:10 +02:00
RELEASE = $( lsb_release -s -r| tr '[:upper:]' '[:lower:]' )
2020-05-16 10:47:14 +02:00
if [ [ " ${ RELEASE } " = = "18.04" ] ] ; then
2019-02-08 10:23:43 +01:00
echo "Install on Ubuntu 18.04 LTS fully supported."
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
2021-04-05 10:46:36 +02:00
upgradeToPHP74
installSupported PHP = "7.4" && exit || exit
2019-02-08 10:23:43 +01:00
fi
2020-05-16 10:47:14 +02:00
if [ [ " ${ RELEASE } " = = "20.04" ] ] ; then
2020-04-30 06:40:13 +02:00
echo "Install on Ubuntu 20.04 LTS fully supported."
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
installSupported PHP = "7.4" && exit || exit
fi
2021-02-15 03:59:34 +01:00
if [ [ " ${ RELEASE } " = = "21.04" ] ] ; then
echo "Install on Ubuntu 21.04 LTS fully supported."
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
installSupported PHP = "7.4" && exit || exit
fi
2022-05-23 12:16:48 +02:00
if [ [ " ${ RELEASE } " = = "22.04" ] ] ; then
echo "Install on Ubuntu 22.04 LTS fully supported."
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
2022-05-23 12:38:06 +02:00
upgradeToPHP74
2022-05-23 12:16:48 +02:00
installSupported PHP = "7.4" && exit || exit
fi
2020-05-16 10:47:14 +02:00
if [ [ " ${ RELEASE } " = = "18.10" ] ] ; then
2019-02-11 06:35:11 +01:00
echo "Install on Ubuntu 18.10 partially supported, bye."
2020-04-30 06:40:13 +02:00
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
2019-02-28 04:03:52 +01:00
installSupported && exit || exit
2019-02-08 10:23:43 +01:00
fi
2020-05-16 10:47:14 +02:00
if [ [ " ${ RELEASE } " = = "19.04" ] ] ; then
2020-04-30 06:40:13 +02:00
echo "Install on Ubuntu 19.04 partially supported bye."
2019-04-20 05:00:39 +02:00
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
installSupported && exit || exit
2019-02-08 10:23:43 +01:00
exit 1
fi
2020-05-16 10:47:14 +02:00
if [ [ " ${ RELEASE } " = = "19.10" ] ] ; then
2019-02-08 10:23:43 +01:00
echo "Install on Ubuntu 19.10 not supported, bye"
exit 1
fi
echo "Installation done!"
2019-02-13 07:00:31 +01:00
exit
2019-02-08 10:23:43 +01:00
fi
2021-04-27 19:41:06 +02:00
# If Debian/Raspbian is detected, figure out which release it is and run the according scripts
if [ [ " ${ FLAVOUR } " = = "debian" ] ] || [ [ " ${ FLAVOUR } " = = "raspbian" ] ] ; then
2019-06-14 15:53:10 +02:00
CODE = $( lsb_release -s -c| tr '[:upper:]' '[:lower:]' )
2020-05-16 10:47:14 +02:00
if [ [ " ${ CODE } " = = "buster" ] ] ; then
2019-02-08 10:23:43 +01:00
echo "Install on Debian testing fully supported."
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
2019-02-28 04:03:52 +01:00
installSupported PHP = 7.3 && exit || exit
2019-02-08 10:23:43 +01:00
fi
2020-05-16 10:47:14 +02:00
if [ [ " ${ CODE } " = = "sid" ] ] ; then
2019-02-08 10:23:43 +01:00
echo "Install on Debian unstable not fully supported."
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
2019-02-28 04:03:52 +01:00
installSupported PHP = 7.3 && exit || exit
2019-02-08 10:23:43 +01:00
fi
2020-05-16 10:47:14 +02:00
if [ [ " ${ CODE } " = = "stretch" ] ] ; then
2019-02-08 10:23:43 +01:00
echo "Install on Debian stable fully supported."
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
2019-02-28 04:03:52 +01:00
installSupported PHP = 7.0 && exit || exit
2019-02-08 10:23:43 +01:00
fi
echo "Installation done!"
exit 0
fi
2019-02-11 06:35:11 +01:00
# If Tsurugi is detected, figure out which release it is and run the according scripts
2020-05-16 10:47:14 +02:00
if [ [ " ${ FLAVOUR } " = = "tsurugi" ] ] ; then
2019-06-14 15:53:10 +02:00
CODE = $( lsb_release -s -c| tr '[:upper:]' '[:lower:]' )
2020-05-16 10:47:14 +02:00
if [ [ " ${ CODE } " = = "bamboo" ] ] ; then
2019-02-11 06:35:11 +01:00
echo "Install on Tsurugi Lab partially supported."
2019-02-08 10:23:43 +01:00
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
fi
2020-05-16 10:47:14 +02:00
if [ [ " ${ CODE } " = = "soy sauce" ] ] ; then
2019-02-11 06:35:11 +01:00
echo "Install on Tsurugi Acquire partially supported."
2019-02-08 10:23:43 +01:00
echo "Please report bugs/issues here: https://github.com/MISP/MISP/issues"
fi
echo "Installation done!"
exit 0
fi
2019-02-11 06:35:11 +01:00
# If Kali Linux is detected, run the acccording scripts
2020-05-16 10:47:14 +02:00
if [ [ " ${ FLAVOUR } " = = "kali" ] ] ; then
2019-02-10 12:29:23 +01:00
KALI = 1
2020-05-13 06:40:14 +02:00
kaliOnTheR0ckz
2019-02-08 10:23:43 +01:00
installMISPonKali
echo "Installation done!"
2019-02-11 06:35:11 +01:00
exit
2019-02-08 10:23:43 +01:00
fi
2020-03-18 16:16:16 +01:00
# If RHEL/CentOS is detected, run appropriate script
2021-03-31 10:07:45 +02:00
if [ [ " ${ FLAVOUR } " = = "rhel" ] ] || [ [ " ${ FLAVOUR } " = = "centos" ] ] || [ [ " ${ FLAVOUR } " = = "fedora" ] ] ; then
2020-03-18 16:16:16 +01:00
installMISPRHEL
echo "Installation done !"
exit
fi