mirror of https://github.com/MISP/misp-packer
Merge branch '18.04' into 20.04
commit
2fbde74eb9
|
@ -1,5 +1,8 @@
|
||||||
packer_cache/
|
packer_cache/
|
||||||
output-virtualbox-iso/
|
output-virtualbox-iso/
|
||||||
|
output-vmware-iso/
|
||||||
scripts/INSTALL.sh*
|
scripts/INSTALL.sh*
|
||||||
*.checksum
|
*.checksum
|
||||||
misp-deploy.json
|
misp-deploy.json
|
||||||
|
packerlog-vbox.txt
|
||||||
|
packerlog-vmware.txt
|
||||||
|
|
|
@ -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
|
|
@ -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
|
||||||
|
|
82
deploy.sh
82
deploy.sh
|
@ -9,57 +9,12 @@
|
||||||
# Timing creation
|
# Timing creation
|
||||||
TIME_START=$(date +%s)
|
TIME_START=$(date +%s)
|
||||||
|
|
||||||
# Name of the packer
|
# Please adjust config.sh accordingly
|
||||||
PACKER_NAME="misp"
|
source config.sh
|
||||||
PACKER_VM="MISP"
|
|
||||||
NAME="${PACKER_NAME}-packer"
|
|
||||||
|
|
||||||
# Configure your user and remote server
|
### ---- NO TOUCHY BEYOND THIS POINT, PLEASE --- ###
|
||||||
REMOTE=1
|
|
||||||
REL_USER="${PACKER_NAME}-release"
|
|
||||||
REL_SERVER="cpab"
|
|
||||||
|
|
||||||
# GPG Sign
|
source checkDeps.sh
|
||||||
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
|
|
||||||
|
|
||||||
# Latest version of misp
|
# Latest version of misp
|
||||||
VER=$(curl -s https://api.github.com/repos/${REPO}/tags |jq -r '.[0] | .name')
|
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
|
if [[ ${chsum} == ${INSTsum} ]] && [[ ${rhash_chk} == 0 ]]; then
|
||||||
echo "sha${sum} matches"
|
echo "sha${sum} matches"
|
||||||
else
|
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."
|
echo "Deleting installer, please run again."
|
||||||
rm ${PATH_TO_INSTALLER}
|
rm ${PATH_TO_INSTALLER}
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -213,14 +169,34 @@ 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
|
# 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
|
cat ${PACKER_NAME}.json| sed "s|\"vm_name\": \"${PACKER_VM}_demo\",|\"vm_name\": \"${PACKER_VM}_${VER}@${LATEST_COMMIT_SHORT}\",|" > ${PACKER_NAME}-deploy.json
|
||||||
|
|
||||||
|
if [[ -z $DEBUG ]]; then
|
||||||
# Build virtualbox VM set
|
# Build virtualbox VM set
|
||||||
PACKER_LOG_PATH="${PWD}/packerlog-vbox.txt"
|
export 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) &
|
($PACKER_RUN build --on-error=cleanup -only=virtualbox-iso ${PACKER_NAME}-deploy.json ; echo $? > /tmp/${PACKER_NAME}-vbox.done) &
|
||||||
|
|
||||||
# Build vmware VM set
|
# Build vmware VM set
|
||||||
PACKER_LOG_PATH="${PWD}/packerlog-vmware.txt"
|
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) &
|
($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
|
# The below waits for the above 2 parallel packer builds to finish
|
||||||
while [[ ! -f /tmp/${PACKER_NAME}-vmware.done ]]; do :; done
|
while [[ ! -f /tmp/${PACKER_NAME}-vmware.done ]]; do :; done
|
||||||
while [[ ! -f /tmp/${PACKER_NAME}-vbox.done ]]; do :; done
|
while [[ ! -f /tmp/${PACKER_NAME}-vbox.done ]]; do :; done
|
||||||
|
|
|
@ -22,7 +22,7 @@ cd /var/www/MISP/PyMISP
|
||||||
if [ "$?" != "0" ]; then
|
if [ "$?" != "0" ]; then
|
||||||
echo "Damage, terrible terrible damage!!!!" >> /tmp/tests-output.txt
|
echo "Damage, terrible terrible damage!!!!" >> /tmp/tests-output.txt
|
||||||
# TODO: Move the smtp server and e-mail address to a config file
|
# 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
|
fi
|
||||||
|
|
||||||
rm -rf tests/viper-test-files
|
rm -rf tests/viper-test-files
|
||||||
|
|
Loading…
Reference in New Issue