Skip to content

fix: increase stability in resources/support-zip.sh #683

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions resources/support-zip.sh
Original file line number Diff line number Diff line change
@@ -1,38 +1,45 @@
#!/bin/bash
# This script creates a zip file so that it can be copied out of the pod for research purposes
set -o pipefail

readonly HAPI_DIR=/opt/hgcapp/services-hedera/HapiApp2.0
readonly DATA_DIR=data
readonly RESEARCH_ZIP=${HOSTNAME}.zip
readonly ZIP_FULLPATH=${HAPI_DIR}/${RESEARCH_ZIP}
readonly OUTPUT_DIR=output
readonly ZIP_FULLPATH=${HAPI_DIR}/${DATA_DIR}/${RESEARCH_ZIP}
readonly FILE_LIST=${HAPI_DIR}/support-zip-file-list.txt
readonly CONFIG_TXT=config.txt
readonly SETTINGS_TXT=settings.txt
readonly SETTINGS_USED_TXT=settingsUsed.txt
readonly OUTPUT_DIR=output
readonly DATA_DIR=data
readonly ADDRESS_BOOK_DIR=${DATA_DIR}/saved/address_book
readonly CONFIG_DIR=${DATA_DIR}/config
readonly KEYS_DIR=${DATA_DIR}/keys
readonly UPGRADE_DIR=${DATA_DIR}/upgrade
readonly JOURNAL_CTL_LOG=${OUTPUT_DIR}/journalctl.log
readonly JOURNAL_CTL_LOG=${HAPI_DIR}/${OUTPUT_DIR}/journalctl.log
readonly LOG_FILE=${HAPI_DIR}/${OUTPUT_DIR}/support-zip.log
rm ${LOG_FILE} 2>/dev/null || true
rm ${FILE_LIST} 2>/dev/null || true

AddToFileList()
{
if [[ -d "${1}" ]];then
find "${1}" -name "*" -printf '\047%p\047\n' >>${FILE_LIST}
find ${1} -name "*" -printf '\047%p\047\n' | tee -a ${LOG_FILE} >>${FILE_LIST}

Check warning on line 26 in resources/support-zip.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

resources/support-zip.sh#L26

Double quote to prevent globbing and word splitting.
return
fi

if [[ -f "${1}" ]];then
find . -maxdepth 1 -type f -name "${1}" -print >>${FILE_LIST}
find . -maxdepth 1 -type f -name ${1} -print | tee -a ${LOG_FILE} >>${FILE_LIST}

Check warning on line 31 in resources/support-zip.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

resources/support-zip.sh#L31

Double quote to prevent globbing and word splitting.
else
echo "skipping: ${1}, file or directory not found"
echo "skipping: ${1}, file or directory not found" | tee -a ${LOG_FILE}
fi
}

echo "support-zip.sh begin..." | tee -a ${LOG_FILE}
echo "cd ${HAPI_DIR}" | tee -a ${LOG_FILE}
cd ${HAPI_DIR}
pwd | tee -a ${LOG_FILE}
echo -n > ${FILE_LIST}
journalctl > ${JOURNAL_CTL_LOG}
(journalctl > ${JOURNAL_CTL_LOG} 2>/dev/null) || true
AddToFileList ${CONFIG_TXT}
AddToFileList ${SETTINGS_TXT}
AddToFileList ${SETTINGS_USED_TXT}
Expand All @@ -41,4 +48,8 @@
AddToFileList ${CONFIG_DIR}
AddToFileList ${KEYS_DIR}
AddToFileList ${UPGRADE_DIR}
echo "creating zip file" | tee -a ${LOG_FILE}
jar cvfM "${ZIP_FULLPATH}" "@${FILE_LIST}"
echo "...end support-zip.sh" | tee -a ${LOG_FILE}
jar -u -v --file=${ZIP_FULLPATH} ${OUTPUT_DIR}/support-zip.log

Check warning on line 54 in resources/support-zip.sh

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

resources/support-zip.sh#L54

Double quote to prevent globbing and word splitting.
exit 0
Loading