Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: correct errors and suppress stderr for common cases #5959

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions scripts/log-capture
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
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,26 @@
_to_log dmidecode
_to_log lspci -vvnn

for DEV_NAME in $(list-harddrives | cut -d " " -f 1)
elkoniu marked this conversation as resolved.
Show resolved Hide resolved
for DEV_NAME in /sys/block/*; do

Check failure

Code scanning / shellcheck

SC1073 Error

Couldn't parse this for loop. Fix to allow more checks.
do
DEV_NAME=$(basename "$DEV_NAME")
_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 +65,21 @@
_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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we need to change to root? Wasn't it working before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the change to root and addition of ./, tar no longer emits:

tar: Removing leading `/' from member names


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