Skip to content

Commit

Permalink
util: correct errors and suppress stderr for common cases
Browse files Browse the repository at this point in the history
  • Loading branch information
jcpunk authored and KKoukiou committed Nov 22, 2024
1 parent 1176b22 commit 0b2442f
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions scripts/log-capture
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ date=$(date +%F_%H%M%S)
OUTDIR=/tmp/log-capture-${date}
ARCHIVE=${1-/tmp/log-capture.tar.bz2}

echo -e "Generating ${ARCHIVE}, please wait.\n"

# shellcheck disable=SC2068
_to_log() { local OutputFile=$(tr ' /' '_' <<<"$@"); $@ >${OUTDIR}/${OutputFile}; }

Expand All @@ -29,24 +31,25 @@ _to_log dmesg
_to_log dmidecode
_to_log lspci -vvnn

for DEV_NAME in $(list-harddrives | cut -d " " -f 1)
for DEV_NAME in $(ls /sys/block);

Check failure

Code scanning / shellcheck

SC2045 Error

Iterating over ls output is fragile. Use globs.
do
_to_log blkid --probe /dev/${DEV_NAME}
done
for PART in $(blkid -d':' -f1)
for PART in $(blkid | cut -d':' -f1)
do
_to_log blkid --probe ${PART}
done

_to_log ls -lR /dev
_to_log parted -l
_to_log lsblk --all --topology
_to_log blkid --output-all
_to_log ls -l /sys/firmware/efi/efivars
_to_log lsblk --output-all --json
_to_log blkid --output full
_to_log dmsetup ls --tree
_to_log lvm pvs
_to_log lvm vgs
_to_log lvm lvs
_to_log cat /proc/devices
_to_log cat /proc/mdstat
_to_log cat /proc/partitions
_to_log mount
Expand All @@ -61,13 +64,21 @@ _to_log ip r
_to_log journalctl

cp /etc/resolv.conf ${OUTDIR}
cp /tmp/*.log ${OUTDIR}
cp /root/lorax-packages.log ${OUTDIR}

if [[ -e /sys/firmware/efi ]]; then
_to_log ls -l /sys/firmware/efi/efivars
fi

find /tmp -type f -name '*.log' -exec cp '{}' ${OUTDIR} ';'

if [[ -e /root/lorax-packages.log ]];then
cp /root/lorax-packages.log ${OUTDIR}
fi

if [[ -e /tmp/pre-anaconda-logs/ ]];then
cp -r /tmp/pre-anaconda-logs ${OUTDIR}
fi

tar cfa ${ARCHIVE} ${OUTDIR}
tar cfa ${ARCHIVE} -C / ./${OUTDIR}

echo -e "\nFinished gathering data\nUpload ${ARCHIVE} to another system\n"

0 comments on commit 0b2442f

Please sign in to comment.