124226c4fSGopichand Paturi#!/bin/bash 224226c4fSGopichand Paturi 3ac291d44SGopichand Paturi#CONSTANTS 4ac291d44SGopichand Paturideclare -rx HEADER_EXTENSION="$DREPORT_INCLUDE/gendumpheader" 5ac291d44SGopichand Paturi 60e29d5caSGopichand Paturi#Source opfunctions 70e29d5caSGopichand Paturi. $DREPORT_INCLUDE/opfunctions 80e29d5caSGopichand Paturi 924226c4fSGopichand Paturi# @brief Packaging the dump, applying the header 1024226c4fSGopichand Paturi# and transferring to dump location. 1124226c4fSGopichand Paturifunction custom_package() 1224226c4fSGopichand Paturi{ 130e29d5caSGopichand Paturi #fetch customized dump name and rename 140e29d5caSGopichand Paturi get_bmc_dump_filename 150e29d5caSGopichand Paturi mv "$name_dir" "$TMP_DIR/$name" 160e29d5caSGopichand Paturi name_dir="$TMP_DIR/$name" 170e29d5caSGopichand Paturi 18ac291d44SGopichand Paturi FILE="/tmp/dumpheader_${dump_id}_${EPOCHTIME}" 19ac291d44SGopichand Paturi echo "performing dump compression $name_dir" 20ac291d44SGopichand Paturi if [ "$dump_type" = "$TYPE_FAULTDATA" ]; then 21ac291d44SGopichand Paturi rm -rf $name_dir/dreport.log 22ac291d44SGopichand Paturi rm -rf $name_dir/summary.log 23ac291d44SGopichand Paturi tar -cf "$name_dir.bin" -C "$(dirname "$name_dir")" "$(basename "$name_dir")" 24ac291d44SGopichand Paturi else 25ac291d44SGopichand Paturi tar cf - -C "$(dirname "$name_dir")" "$(basename "$name_dir")" | zstd > "$name_dir.bin" 26ac291d44SGopichand Paturi fi 2724226c4fSGopichand Paturi # shellcheck disable=SC2181 # need output from `tar` in above if cond. 2824226c4fSGopichand Paturi if [ $? -ne 0 ]; then 2924226c4fSGopichand Paturi echo "$($TIME_STAMP)" "Could not create the compressed tar file" 3024226c4fSGopichand Paturi rm -r "$name_dir.bin" 3124226c4fSGopichand Paturi return "$INTERNAL_FAILURE" 3224226c4fSGopichand Paturi fi 3324226c4fSGopichand Paturi 34*1bee03b8SSwarnendu-R-C get_originator_details "bmc" 35*1bee03b8SSwarnendu-R-C 3624226c4fSGopichand Paturi echo "Adding Dump Header :"$HEADER_EXTENSION 3724226c4fSGopichand Paturi ("$HEADER_EXTENSION") 3824226c4fSGopichand Paturi 39ac291d44SGopichand Paturi cat "$name_dir.bin" | tee -a "$FILE" > /dev/null 4024226c4fSGopichand Paturi #remove the temporary name specific directory 41ac291d44SGopichand Paturi rm -rf "$name_dir" "$name_dir.bin" 42ac291d44SGopichand Paturi mv $FILE "$name_dir" 4324226c4fSGopichand Paturi 4424226c4fSGopichand Paturi echo "$($TIME_STAMP)" "Report is available in $dump_dir" 4524226c4fSGopichand Paturi if [ "$TMP_DIR" == "$dump_dir" ] || [ "$TMP_DIR/" == "$dump_dir" ]; then 4624226c4fSGopichand Paturi return "$SUCCESS" 4724226c4fSGopichand Paturi fi 4824226c4fSGopichand Paturi 4924226c4fSGopichand Paturi #copy the compressed tar file into the destination 5024226c4fSGopichand Paturi cp "$name_dir" "$dump_dir" 5124226c4fSGopichand Paturi if [ $? -ne 0 ]; then 5224226c4fSGopichand Paturi echo "Failed to copy the $name_dir to $dump_dir" 53ac291d44SGopichand Paturi rm "$name_dir" 5424226c4fSGopichand Paturi return "$INTERNAL_FAILURE" 5524226c4fSGopichand Paturi fi 5624226c4fSGopichand Paturi 5724226c4fSGopichand Paturi #Remove the temporary copy of the file 58ac291d44SGopichand Paturi rm -rf "$name_dir" 5924226c4fSGopichand Paturi} 6024226c4fSGopichand Paturi 6124226c4fSGopichand Paturi# Executing function 6224226c4fSGopichand Paturicustom_package 63