124226c4fSGopichand Paturi#!/bin/bash 224226c4fSGopichand Paturi 3*ac291d44SGopichand Paturi#CONSTANTS 4*ac291d44SGopichand Paturideclare -rx HEADER_EXTENSION="$DREPORT_INCLUDE/gendumpheader" 5*ac291d44SGopichand Paturi 624226c4fSGopichand Paturi# @brief Packaging the dump, applying the header 724226c4fSGopichand Paturi# and transferring to dump location. 824226c4fSGopichand Paturifunction custom_package() 924226c4fSGopichand Paturi{ 10*ac291d44SGopichand Paturi FILE="/tmp/dumpheader_${dump_id}_${EPOCHTIME}" 11*ac291d44SGopichand Paturi echo "performing dump compression $name_dir" 12*ac291d44SGopichand Paturi if [ "$dump_type" = "$TYPE_FAULTDATA" ]; then 13*ac291d44SGopichand Paturi rm -rf $name_dir/dreport.log 14*ac291d44SGopichand Paturi rm -rf $name_dir/summary.log 15*ac291d44SGopichand Paturi tar -cf "$name_dir.bin" -C "$(dirname "$name_dir")" "$(basename "$name_dir")" 16*ac291d44SGopichand Paturi else 17*ac291d44SGopichand Paturi tar cf - -C "$(dirname "$name_dir")" "$(basename "$name_dir")" | zstd > "$name_dir.bin" 18*ac291d44SGopichand Paturi fi 1924226c4fSGopichand Paturi # shellcheck disable=SC2181 # need output from `tar` in above if cond. 2024226c4fSGopichand Paturi if [ $? -ne 0 ]; then 2124226c4fSGopichand Paturi echo "$($TIME_STAMP)" "Could not create the compressed tar file" 2224226c4fSGopichand Paturi rm -r "$name_dir.bin" 2324226c4fSGopichand Paturi return "$INTERNAL_FAILURE" 2424226c4fSGopichand Paturi fi 2524226c4fSGopichand Paturi 2624226c4fSGopichand Paturi echo "Adding Dump Header :"$HEADER_EXTENSION 2724226c4fSGopichand Paturi ("$HEADER_EXTENSION") 2824226c4fSGopichand Paturi 29*ac291d44SGopichand Paturi cat "$name_dir.bin" | tee -a "$FILE" > /dev/null 3024226c4fSGopichand Paturi #remove the temporary name specific directory 31*ac291d44SGopichand Paturi rm -rf "$name_dir" "$name_dir.bin" 32*ac291d44SGopichand Paturi mv $FILE "$name_dir" 3324226c4fSGopichand Paturi 3424226c4fSGopichand Paturi echo "$($TIME_STAMP)" "Report is available in $dump_dir" 3524226c4fSGopichand Paturi if [ "$TMP_DIR" == "$dump_dir" ] || [ "$TMP_DIR/" == "$dump_dir" ]; then 3624226c4fSGopichand Paturi return "$SUCCESS" 3724226c4fSGopichand Paturi fi 3824226c4fSGopichand Paturi 3924226c4fSGopichand Paturi #copy the compressed tar file into the destination 4024226c4fSGopichand Paturi cp "$name_dir" "$dump_dir" 4124226c4fSGopichand Paturi if [ $? -ne 0 ]; then 4224226c4fSGopichand Paturi echo "Failed to copy the $name_dir to $dump_dir" 43*ac291d44SGopichand Paturi rm "$name_dir" 4424226c4fSGopichand Paturi return "$INTERNAL_FAILURE" 4524226c4fSGopichand Paturi fi 4624226c4fSGopichand Paturi 4724226c4fSGopichand Paturi #Remove the temporary copy of the file 48*ac291d44SGopichand Paturi rm -rf "$name_dir" 4924226c4fSGopichand Paturi} 5024226c4fSGopichand Paturi 5124226c4fSGopichand Paturi# Executing function 5224226c4fSGopichand Paturicustom_package 53