blob: df87315928a6aee4c1f92da6b07f3d7c16d9afd7 [file] [log] [blame]
Gopichand Paturi24226c42024-05-16 14:51:22 -05001#!/bin/bash
2
3# @brief Packaging the dump, applying the header
4# and transferring to dump location.
5function custom_package()
6{
7 tar -Jcf "$name_dir.bin" -C \
8 "$(dirname "$name_dir")" "$(basename "$name_dir")"
9 # shellcheck disable=SC2181 # need output from `tar` in above if cond.
10 if [ $? -ne 0 ]; then
11 echo "$($TIME_STAMP)" "Could not create the compressed tar file"
12 rm -r "$name_dir.bin"
13 return "$INTERNAL_FAILURE"
14 fi
15
16 echo "Adding Dump Header :"$HEADER_EXTENSION
17 ("$HEADER_EXTENSION")
18
19 cat "$name_dir.bin" | tee -a "/tmp/dumpheader_$EPOCHTIME" > /dev/null
20 #remove the temporary name specific directory
21 rm -rf "$name_dir"
22 mv "/tmp/dumpheader_$EPOCHTIME" "$name_dir"
23
24 echo "$($TIME_STAMP)" "Report is available in $dump_dir"
25 if [ "$TMP_DIR" == "$dump_dir" ] || [ "$TMP_DIR/" == "$dump_dir" ]; then
26 return "$SUCCESS"
27 fi
28
29 #copy the compressed tar file into the destination
30 cp "$name_dir" "$dump_dir"
31 if [ $? -ne 0 ]; then
32 echo "Failed to copy the $name_dir to $dump_dir"
33 rm "$name_dir.bin"
34 return "$INTERNAL_FAILURE"
35 fi
36
37 #Remove the temporary copy of the file
38 rm -rf "$name_dir.bin" "$name_dir"
39}
40
41# Executing function
42custom_package