Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 3 | #CONSTANTS |
| 4 | declare -rx HEADER_EXTENSION="$DREPORT_INCLUDE/gendumpheader" |
| 5 | |
Gopichand Paturi | 0e29d5c | 2024-06-11 05:51:38 -0500 | [diff] [blame^] | 6 | #Source opfunctions |
| 7 | . $DREPORT_INCLUDE/opfunctions |
| 8 | |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 9 | # @brief Packaging the dump, applying the header |
| 10 | # and transferring to dump location. |
| 11 | function custom_package() |
| 12 | { |
Gopichand Paturi | 0e29d5c | 2024-06-11 05:51:38 -0500 | [diff] [blame^] | 13 | #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 Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 18 | 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 Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 27 | # 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 | |
| 34 | echo "Adding Dump Header :"$HEADER_EXTENSION |
| 35 | ("$HEADER_EXTENSION") |
| 36 | |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 37 | cat "$name_dir.bin" | tee -a "$FILE" > /dev/null |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 38 | #remove the temporary name specific directory |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 39 | rm -rf "$name_dir" "$name_dir.bin" |
| 40 | mv $FILE "$name_dir" |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 41 | |
| 42 | echo "$($TIME_STAMP)" "Report is available in $dump_dir" |
| 43 | if [ "$TMP_DIR" == "$dump_dir" ] || [ "$TMP_DIR/" == "$dump_dir" ]; then |
| 44 | return "$SUCCESS" |
| 45 | fi |
| 46 | |
| 47 | #copy the compressed tar file into the destination |
| 48 | cp "$name_dir" "$dump_dir" |
| 49 | if [ $? -ne 0 ]; then |
| 50 | echo "Failed to copy the $name_dir to $dump_dir" |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 51 | rm "$name_dir" |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 52 | return "$INTERNAL_FAILURE" |
| 53 | fi |
| 54 | |
| 55 | #Remove the temporary copy of the file |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 56 | rm -rf "$name_dir" |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | # Executing function |
| 60 | custom_package |