Skip to content

Commit 280dd29

Browse files
authored
[show techsupport] fix bash errors in generate_dump script (sonic-net#1844)
What I did Fix: sonic-net#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]>
1 parent 709dc85 commit 280dd29

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

scripts/generate_dump

+24-19
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,9 @@ save_cmd() {
195195
if $NOOP; then
196196
echo "${timeout_cmd} $cmd $redirect '$filepath'"
197197
else
198-
eval "${timeout_cmd} $cmd" "$redirect" "$filepath"
199-
if [ $? -ne 0 ]; then
198+
RC=0
199+
eval "${timeout_cmd} $cmd" "$redirect" "$filepath" || RC=$?
200+
if [ $RC -ne 0 ]; then
200201
echo "Command: $cmd timedout after ${TIMEOUT_MIN} minutes."
201202
fi
202203
fi
@@ -988,26 +989,30 @@ save_warmboot_files() {
988989
save_crash_files() {
989990
# archive core dump files
990991
trap 'handle_error $? $LINENO' ERR
991-
for file in $(find_files "/var/core/"); do
992-
# don't gzip already-gzipped log files :)
993-
if [ -z "${file##*.gz}" ]; then
994-
save_file $file core false
995-
else
996-
save_file $file core true
997-
fi
998-
done
992+
if [ -d /var/core/ ]; then
993+
for file in $(find_files "/var/core/"); do
994+
# don't gzip already-gzipped log files :)
995+
if [ -z "${file##*.gz}" ]; then
996+
save_file $file core false
997+
else
998+
save_file $file core true
999+
fi
1000+
done
1001+
fi
9991002

10001003
# archive kernel dump files
1001-
[ -d /var/crash/ ] && for file in $(find_files "/var/crash/"); do
1002-
# don't gzip already-gzipped dmesg files :)
1003-
if [ ! ${file} = "/var/crash/kexec_cmd" -a ! ${file} = "/var/crash/export" ]; then
1004-
if [[ ${file} == *"kdump."* ]]; then
1005-
save_file $file kdump false
1006-
else
1007-
save_file $file kdump true
1004+
if [ -d /var/crash/ ]; then
1005+
for file in $(find_files "/var/crash/"); do
1006+
# don't gzip already-gzipped dmesg files :)
1007+
if [ ! ${file} = "/var/crash/kexec_cmd" -a ! ${file} = "/var/crash/export" ]; then
1008+
if [[ ${file} == *"kdump."* ]]; then
1009+
save_file $file kdump false
1010+
else
1011+
save_file $file kdump true
1012+
fi
10081013
fi
1009-
fi
1010-
done
1014+
done
1015+
fi
10111016
}
10121017

10131018
###############################################################################

0 commit comments

Comments
 (0)