diff --git a/.gitignore b/.gitignore index f46ec98..2b45eed 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ packer_cache/ output-virtualbox-iso/ +output-vmware-iso/ scripts/INSTALL.sh* *.checksum misp-deploy.json +packerlog-vbox.txt +packerlog-vmware.txt diff --git a/checkDeps.sh b/checkDeps.sh new file mode 100644 index 0000000..4c9447a --- /dev/null +++ b/checkDeps.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +GOT_PACKER=$(which packer > /dev/null 2>&1; echo $?) +if [[ "${GOT_PACKER}" == 0 ]]; then + echo "Packer detected, version: $(packer -v)" + PACKER_RUN=$(which packer) +else + echo "No packer binary detected, please make sure you installed it from: https://www.packer.io/downloads.html" + exit 1 +fi + +GOT_RHASH=$(which rhash > /dev/null 2>&1; echo $?) +if [[ "${GOT_RHASH}" == 0 ]]; then + echo "rhash detected, version: $(rhash --version)" + RHASH_RUN=$(which rhash) +else + echo "No rhash binary detected, please make sure you installed it." + exit 1 +fi diff --git a/config.sh b/config.sh new file mode 100644 index 0000000..7512f56 --- /dev/null +++ b/config.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Leave empty for NO debug messages, if run with set -x or bash -x it will enable DEBUG by default +DEBUG= + +case "$-" in + *x*) NO_PROGRESS=1; DEBUG=1 ;; + *) NO_PROGRESS=0 ;; +esac + +# Name of the packer +PACKER_NAME="misp" +PACKER_VM="MISP" +NAME="${PACKER_NAME}-packer" + +# Configure your user and remote server +REMOTE=1 +REL_USER="${PACKER_NAME}-release" +REL_SERVER="cpab" + +# GPG Sign +GPG_ENABLED=1 +GPG_KEY="0x34F20B13" + +# Enable debug for packer, omit -debug to disable +##PACKER_DEBUG="-debug" + +# Enable logging and debug for packer +export PACKER_LOG=1 + +REPO="MISP/MISP" +BRANCH="2.4" + +# SHAsums to be computed, note the -- notatiation is for ease of use with rhash +SHA_SUMS="--sha1 --sha256 --sha384 --sha512" + +NAME_OF_INSTALLER="INSTALL.sh" +PATH_TO_INSTALLER="scripts/${NAME_OF_INSTALLER}" +URL_TO_INSTALLER="https://raw.githubusercontent.com/${REPO}/${BRANCH}/INSTALL/${NAME_OF_INSTALLER}" +URL_TO_LICENSE="https://raw.githubusercontent.com/${REPO}/${BRANCH}/LICENSE" + +if [[ ! -z $DEBUG ]]; then + echo "Debug mode enabled." + echo "-------------------" + echo "" + echo "Some config info:" + echo "Using: $NAME" + [[ ! -z $GPG_ENABLED ]] && echo "GnuPG enabled with key $GPG_KEY" + [[ ! -z $PACKER_LOG ]] && echo "Packer Log enabled." + [[ ! -z $REMOTE ]] && echo "Remote deploy enabled with connection string: $REL_USER@$REL_SERVER" +fi + diff --git a/deploy.sh b/deploy.sh index 6b4fa42..d62e9f4 100755 --- a/deploy.sh +++ b/deploy.sh @@ -9,57 +9,12 @@ # Timing creation TIME_START=$(date +%s) -# Name of the packer -PACKER_NAME="misp" -PACKER_VM="MISP" -NAME="${PACKER_NAME}-packer" +# Please adjust config.sh accordingly +source config.sh -# Configure your user and remote server -REMOTE=1 -REL_USER="${PACKER_NAME}-release" -REL_SERVER="cpab" +### ---- NO TOUCHY BEYOND THIS POINT, PLEASE --- ### -# GPG Sign -GPG_ENABLED=1 -GPG_KEY="0x34F20B13" - -# Enable debug for packer, omit -debug to disable -##PACKER_DEBUG="-debug" - -# Enable logging and debug for packer -export PACKER_LOG=0 - -REPO="MISP/MISP" -BRANCH="2.4" - -# SHAsums to be computed, note the -- notatiation is for ease of use with rhash -SHA_SUMS="--sha1 --sha256 --sha384 --sha512" - -NAME_OF_INSTALLER="INSTALL.sh" -PATH_TO_INSTALLER="scripts/${NAME_OF_INSTALLER}" -URL_TO_INSTALLER="https://raw.githubusercontent.com/${REPO}/${BRANCH}/INSTALL/${NAME_OF_INSTALLER}" -URL_TO_LICENSE="https://raw.githubusercontent.com/${REPO}/${BRANCH}/LICENSE" - -### ---- NOT TOUCHY BEOYND THIS POINT, PLEASE --- ### - -# TODO: Move into seprate file -GOT_PACKER=$(which packer > /dev/null 2>&1; echo $?) -if [[ "${GOT_PACKER}" == 0 ]]; then - echo "Packer detected, version: $(packer -v)" - PACKER_RUN=$(which packer) -else - echo "No packer binary detected, please make sure you installed it from: https://www.packer.io/downloads.html" - exit 1 -fi - -GOT_RHASH=$(which rhash > /dev/null 2>&1; echo $?) -if [[ "${GOT_RHASH}" == 0 ]]; then - echo "rhash detected, version: $(rhash --version)" - RHASH_RUN=$(which rhash) -else - echo "No rhash binary detected, please make sure you installed it." - exit 1 -fi +source checkDeps.sh # Latest version of misp VER=$(curl -s https://api.github.com/repos/${REPO}/tags |jq -r '.[0] | .name') @@ -166,7 +121,8 @@ checkInstaller () { if [[ ${chsum} == ${INSTsum} ]] && [[ ${rhash_chk} == 0 ]]; then echo "sha${sum} matches" else - echo "sha${sum}: ${chsum} does not match the installer sum of: ${INSTsum}" + echo "Either: sha${sum}: ${chsum} does not match the installer sum of: ${INSTsum}" + echo "Or: rhash failed on non Zero: ${rhash_chk}" echo "Deleting installer, please run again." rm ${PATH_TO_INSTALLER} exit 1 @@ -213,13 +169,33 @@ if [[ "${LATEST_COMMIT}" != "$(cat /tmp/${PACKER_NAME}-latest.sha)" ]]; then # Search and replace for vm_name and make sure we can easily identify the generated VMs cat ${PACKER_NAME}.json| sed "s|\"vm_name\": \"${PACKER_VM}_demo\",|\"vm_name\": \"${PACKER_VM}_${VER}@${LATEST_COMMIT_SHORT}\",|" > ${PACKER_NAME}-deploy.json - # Build virtualbox VM set - PACKER_LOG_PATH="${PWD}/packerlog-vbox.txt" - ($PACKER_RUN build --on-error=cleanup -only=virtualbox-iso ${PACKER_NAME}-deploy.json > /dev/null 2>&1 ; echo $? > /tmp/${PACKER_NAME}-vbox.done) & + if [[ -z $DEBUG ]]; then + # Build virtualbox VM set + export PACKER_LOG_PATH="${PWD}/packerlog-vbox.txt" + ($PACKER_RUN build --on-error=cleanup -only=virtualbox-iso ${PACKER_NAME}-deploy.json ; echo $? > /tmp/${PACKER_NAME}-vbox.done) & # Build vmware VM set - PACKER_LOG_PATH="${PWD}/packerlog-vmware.txt" - ($PACKER_RUN build --on-error=cleanup -only=vmware-iso ${PACKER_NAME}-deploy.json ; echo $? > /tmp/${PACKER_NAME}-vmware.done) & + export PACKER_LOG_PATH="${PWD}/packerlog-vmware.txt" + ($PACKER_RUN build --on-error=cleanup -only=vmware-iso ${PACKER_NAME}-deploy.json ; echo $? > /tmp/${PACKER_NAME}-vmware.done) & + + else + echo "Disabling // builds" + # Build virtualbox VM set + export PACKER_LOG_PATH="${PWD}/packerlog-vbox.txt" + ($PACKER_RUN build --on-error=cleanup -only=virtualbox-iso ${PACKER_NAME}-deploy.json ; echo $? > /tmp/${PACKER_NAME}-vbox.done) + + # Build vmware VM set + export PACKER_LOG_PATH="${PWD}/packerlog-vmware.txt" + ($PACKER_RUN build --on-error=cleanup -only=vmware-iso ${PACKER_NAME}-deploy.json ; echo $? > /tmp/${PACKER_NAME}-vmware.done) + TIME_END=$(date +%s) + TIME_DELTA=$(expr ${TIME_END} - ${TIME_START}) + TIME=$(convertSecs ${TIME_DELTA}) + echo "So far the generation took ${TIME}" + echo "" + echo "Waiting for return key..." + read + #exit -1 + fi # The below waits for the above 2 parallel packer builds to finish while [[ ! -f /tmp/${PACKER_NAME}-vmware.done ]]; do :; done diff --git a/scripts/clean.sh b/scripts/clean.sh index 58219df..c381107 100644 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -22,7 +22,7 @@ cd /var/www/MISP/PyMISP if [ "$?" != "0" ]; then echo "Damage, terrible terrible damage!!!!" >> /tmp/tests-output.txt # TODO: Move the smtp server and e-mail address to a config file - set smtp=smtp://149.13.33.5 ; cat /tmp/tests-output.txt |mail -s "tests/testlive_comprehensive.py failed on autogen-VM" steve.clement@circl.lu + ##set smtp=smtp://149.13.33.5 ; cat /tmp/tests-output.txt |mail -s "tests/testlive_comprehensive.py failed on autogen-VM" steve.clement@circl.lu fi rm -rf tests/viper-test-files