blob: 00dcb81fdac015f76314f2bed1f7ecd6b2d7ace0 [file] [log] [blame]
Gopichand Paturi24226c42024-05-16 14:51:22 -05001#!/bin/bash
2
Gopichand Paturiac291d42025-03-25 14:11:00 -05003#CONSTANTS
4declare -rx HEADER_EXTENSION="$DREPORT_INCLUDE/gendumpheader"
5
Gopichand Paturi0e29d5c2024-06-11 05:51:38 -05006#Source opfunctions
7. $DREPORT_INCLUDE/opfunctions
8
Gopichand Paturi24226c42024-05-16 14:51:22 -05009# @brief Packaging the dump, applying the header
10# and transferring to dump location.
11function custom_package()
12{
Gopichand Paturi0e29d5c2024-06-11 05:51:38 -050013 #fetch customized dump name and rename
14 get_bmc_dump_filename
15 mv "$name_dir" "$TMP_DIR/$name"
16 name_dir="$TMP_DIR/$name"
17
Gopichand Paturiac291d42025-03-25 14:11:00 -050018 FILE="/tmp/dumpheader_${dump_id}_${EPOCHTIME}"
19 echo "performing dump compression $name_dir"
20 if [ "$dump_type" = "$TYPE_FAULTDATA" ]; then
21 rm -rf $name_dir/dreport.log
22 rm -rf $name_dir/summary.log
23 tar -cf "$name_dir.bin" -C "$(dirname "$name_dir")" "$(basename "$name_dir")"
24 else
25 tar cf - -C "$(dirname "$name_dir")" "$(basename "$name_dir")" | zstd > "$name_dir.bin"
26 fi
Gopichand Paturi24226c42024-05-16 14:51:22 -050027 # shellcheck disable=SC2181 # need output from `tar` in above if cond.
28 if [ $? -ne 0 ]; then
29 echo "$($TIME_STAMP)" "Could not create the compressed tar file"
30 rm -r "$name_dir.bin"
31 return "$INTERNAL_FAILURE"
32 fi
33
Swarnendu-R-C1bee03b2024-06-13 09:21:56 -050034 get_originator_details "bmc"
35
Gopichand Paturi24226c42024-05-16 14:51:22 -050036 echo "Adding Dump Header :"$HEADER_EXTENSION
37 ("$HEADER_EXTENSION")
38
Gopichand Paturiac291d42025-03-25 14:11:00 -050039 cat "$name_dir.bin" | tee -a "$FILE" > /dev/null
Gopichand Paturi24226c42024-05-16 14:51:22 -050040 #remove the temporary name specific directory
Gopichand Paturiac291d42025-03-25 14:11:00 -050041 rm -rf "$name_dir" "$name_dir.bin"
42 mv $FILE "$name_dir"
Gopichand Paturi24226c42024-05-16 14:51:22 -050043
44 echo "$($TIME_STAMP)" "Report is available in $dump_dir"
45 if [ "$TMP_DIR" == "$dump_dir" ] || [ "$TMP_DIR/" == "$dump_dir" ]; then
46 return "$SUCCESS"
47 fi
48
49 #copy the compressed tar file into the destination
50 cp "$name_dir" "$dump_dir"
51 if [ $? -ne 0 ]; then
52 echo "Failed to copy the $name_dir to $dump_dir"
Gopichand Paturiac291d42025-03-25 14:11:00 -050053 rm "$name_dir"
Gopichand Paturi24226c42024-05-16 14:51:22 -050054 return "$INTERNAL_FAILURE"
55 fi
56
57 #Remove the temporary copy of the file
Gopichand Paturiac291d42025-03-25 14:11:00 -050058 rm -rf "$name_dir"
Gopichand Paturi24226c42024-05-16 14:51:22 -050059}
60
61# Executing function
62custom_package