mirror of https://github.com/MISP/misp-packer
new: [dbg] Added debug mode
parent
906f0ee80e
commit
7fdf431809
20
config.sh
20
config.sh
|
@ -1,5 +1,13 @@
|
|||
#!/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"
|
||||
|
@ -30,3 +38,15 @@ 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
|
||||
|
||||
|
|
22
deploy.sh
22
deploy.sh
|
@ -169,6 +169,7 @@ 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
|
||||
|
||||
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) &
|
||||
|
@ -177,10 +178,29 @@ if [[ "${LATEST_COMMIT}" != "$(cat /tmp/${PACKER_NAME}-latest.sha)" ]]; then
|
|||
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
|
||||
while [[ ! -f /tmp/${PACKER_NAME}-vbox.done ]]; do :; done
|
||||
#exit -1
|
||||
|
||||
# Prevent uploading only half a build
|
||||
if [[ "$(cat /tmp/${PACKER_NAME}-vbox.done)" == "0" ]] && [[ "$(cat /tmp/${PACKER_NAME}-vmware.done)" == "0" ]]; then
|
||||
# ZIPup all the vmware stuff
|
||||
|
|
Loading…
Reference in New Issue