Skip to content

Commit

Permalink
[show techsupport] fix bash errors in generate_dump script (sonic-net…
Browse files Browse the repository at this point in the history
…#1844)

What I did
Fix: sonic-net/sonic-buildimage#8850

Issue was introduced by sonic-net#1723, sonic-net#1833, and sonic-net#1843 (pending merge)

The error_handler is a great idea but the bash script needs to be error free first.

How I did it
Fix bash script errors.

How to verify it
run show techsupport test..

Signed-off-by: Ying Xie <[email protected]>
  • Loading branch information
yxieca authored and Sangita Maity committed Nov 3, 2021
1 parent daf18c9 commit c9f5be3
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions scripts/generate_dump
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,9 @@ save_cmd() {
if $NOOP; then
echo "${timeout_cmd} $cmd $redirect '$filepath'"
else
eval "${timeout_cmd} $cmd" "$redirect" "$filepath"
if [ $? -ne 0 ]; then
RC=0
eval "${timeout_cmd} $cmd" "$redirect" "$filepath" || RC=$?
if [ $RC -ne 0 ]; then
echo "Command: $cmd timedout after ${TIMEOUT_MIN} minutes."
fi
fi
Expand Down Expand Up @@ -983,26 +984,30 @@ save_warmboot_files() {
save_crash_files() {
# archive core dump files
trap 'handle_error $? $LINENO' ERR
for file in $(find_files "/var/core/"); do
# don't gzip already-gzipped log files :)
if [ -z "${file##*.gz}" ]; then
save_file $file core false
else
save_file $file core true
fi
done
if [ -d /var/core/ ]; then
for file in $(find_files "/var/core/"); do
# don't gzip already-gzipped log files :)
if [ -z "${file##*.gz}" ]; then
save_file $file core false
else
save_file $file core true
fi
done
fi

# archive kernel dump files
[ -d /var/crash/ ] && for file in $(find_files "/var/crash/"); do
# don't gzip already-gzipped dmesg files :)
if [ ! ${file} = "/var/crash/kexec_cmd" -a ! ${file} = "/var/crash/export" ]; then
if [[ ${file} == *"kdump."* ]]; then
save_file $file kdump false
else
save_file $file kdump true
if [ -d /var/crash/ ]; then
for file in $(find_files "/var/crash/"); do
# don't gzip already-gzipped dmesg files :)
if [ ! ${file} = "/var/crash/kexec_cmd" -a ! ${file} = "/var/crash/export" ]; then
if [[ ${file} == *"kdump."* ]]; then
save_file $file kdump false
else
save_file $file kdump true
fi
fi
fi
done
done
fi
}

###############################################################################
Expand Down

0 comments on commit c9f5be3

Please sign in to comment.