Compare commits

...

8 Commits

6 changed files with 109 additions and 59 deletions

3
.gitignore vendored
View File

@ -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

19
checkDeps.sh Normal file
View File

@ -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

52
config.sh Normal file
View File

@ -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

View File

@ -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

View File

@ -155,11 +155,11 @@
"hostname": "misp",
"http_proxy": "{{env `http_proxy`}}",
"https_proxy": "{{env `https_proxy`}}",
"iso_checksum": "8fb81c7a72c0775c17bbc3490e8ff5997fa1ae4eab7446a9c078b81b0103af4eff758ec41b250c36fddc3f1bcd29175440ea8b68944f29b7bcae02be34e8f40f",
"iso_checksum": "302c990c6d69575ff24c96566e5c7e26bf36908abb0cd546e22687c46fb07bf8dba595bf77a9d4fd9ab63e75c0437c133f35462fd41ea77f6f616140cd0e5e6a",
"iso_checksum_type": "sha512",
"iso_name": "ubuntu-20.04-live-server-amd64.iso",
"iso_name": "ubuntu-20.04.1-live-server-amd64.iso",
"iso_path": "iso",
"iso_url": "https://releases.ubuntu.com/20.04/ubuntu-20.04-live-server-amd64.iso",
"iso_url": "https://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64.iso",
"memory": "3072",
"no_proxy": "{{env `no_proxy`}}",
"ovftool_path": "ovftool",

View File

@ -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