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 | |
Swarnendu-R-C | 1bee03b | 2024-06-13 09:21:56 -0500 | [diff] [blame^] | 34 | get_originator_details "bmc" |
| 35 | |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 36 | echo "Adding Dump Header :"$HEADER_EXTENSION |
| 37 | ("$HEADER_EXTENSION") |
| 38 | |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 39 | cat "$name_dir.bin" | tee -a "$FILE" > /dev/null |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 40 | #remove the temporary name specific directory |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 41 | rm -rf "$name_dir" "$name_dir.bin" |
| 42 | mv $FILE "$name_dir" |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 43 | |
| 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 Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 53 | rm "$name_dir" |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 54 | return "$INTERNAL_FAILURE" |
| 55 | fi |
| 56 | |
| 57 | #Remove the temporary copy of the file |
Gopichand Paturi | ac291d4 | 2025-03-25 14:11:00 -0500 | [diff] [blame] | 58 | rm -rf "$name_dir" |
Gopichand Paturi | 24226c4 | 2024-05-16 14:51:22 -0500 | [diff] [blame] | 59 | } |
| 60 | |
| 61 | # Executing function |
| 62 | custom_package |