new: [dbg] Added debug mode

pull/23/head
Steve Clement 2021-02-05 04:31:13 +00:00
parent 906f0ee80e
commit 7fdf431809
2 changed files with 46 additions and 6 deletions

View File

@ -1,5 +1,13 @@
#!/bin/bash #!/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 # Name of the packer
PACKER_NAME="misp" PACKER_NAME="misp"
PACKER_VM="MISP" PACKER_VM="MISP"
@ -30,3 +38,15 @@ NAME_OF_INSTALLER="INSTALL.sh"
PATH_TO_INSTALLER="scripts/${NAME_OF_INSTALLER}" PATH_TO_INSTALLER="scripts/${NAME_OF_INSTALLER}"
URL_TO_INSTALLER="https://raw.githubusercontent.com/${REPO}/${BRANCH}/INSTALL/${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" 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

@ -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 # 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
export 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 ; 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) &
@ -177,10 +178,29 @@ if [[ "${LATEST_COMMIT}" != "$(cat /tmp/${PACKER_NAME}-latest.sha)" ]]; then
export 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
#exit -1
# Prevent uploading only half a build # Prevent uploading only half a build
if [[ "$(cat /tmp/${PACKER_NAME}-vbox.done)" == "0" ]] && [[ "$(cat /tmp/${PACKER_NAME}-vmware.done)" == "0" ]]; then if [[ "$(cat /tmp/${PACKER_NAME}-vbox.done)" == "0" ]] && [[ "$(cat /tmp/${PACKER_NAME}-vmware.done)" == "0" ]]; then
# ZIPup all the vmware stuff # ZIPup all the vmware stuff