From 2fea1a198e66c3566dcd5d2d9e0ca9198a5e4173 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 1 Sep 2014 21:05:15 -0700 Subject: [PATCH 01/16] Release new version 0.10.0 --- debian/changelog | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/debian/changelog b/debian/changelog index e1050c8..cdd1aaf 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +grml-hwinfo (0.10.0) unstable; urgency=medium + + * [43246c9] Support mcelog + * [9b0e96b] Support edac-utils + * [8216405] Support i2c-tools's decode-dimms + * [20db99b] Bump Standards-Version to 3.9.5 + + -- Michael Prokop Mon, 01 Sep 2014 21:04:58 -0700 + grml-hwinfo (0.9.2) unstable; urgency=medium * [048f6e4] Support iproute2 as alternative to iproute in Recommends -- 2.1.4 From 8eca38cb953a756c9662cb93a7c2cb933657261d Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 21 Oct 2015 22:42:10 +0200 Subject: [PATCH 02/16] ip: also store table specific route information --- grml-hwinfo | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/grml-hwinfo b/grml-hwinfo index ed48463..37f007c 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -223,6 +223,11 @@ cd "${OUTDIR}" || exit 1 exectest ip && ip netns list > ip_netns exectest ip && ip ntable show > ip_ntable exectest ip && ip route show > ip_route + exectest ip && if [ -r /etc/iproute2/rt_tables ] ; then + grep -v '^#' /etc/iproute2/rt_tables | while read table name ; do + ip route show table "${table}" > "ip_route_table_${table}" + done + fi exectest ip && ip rule show > ip_rule exectest ip && ip tunnel show > ip_tunnel exectest ip && ip tuntap show > ip_tuntap -- 2.1.4 From 55629e08ab582fe9c8fb787f931ee44536d9cf50 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 21 Oct 2015 23:03:08 +0200 Subject: [PATCH 03/16] Improve shell quoting (thanks to shellcheck) --- grml-hwinfo | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/grml-hwinfo b/grml-hwinfo index 37f007c..48ae804 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -12,7 +12,7 @@ # variables UNAME="$(uname -r)" -PN="$(basename $0)" +PN="$(basename "$0")" [ -n "$WORKING_DIR" -a -d "$WORKING_DIR" ] || WORKING_DIR=$(pwd) VERSION='***UNRELEASED***' @@ -101,11 +101,11 @@ done # Generate output/temporary directory name & path, and output file path [ -n "$OUTDIRNAME" ] || OUTDIRNAME="grml-hwinfo-${DATE}" OUTDIR="${WORKING_DIR}/${OUTDIRNAME}" -mkdir "${OUTDIR}" || { echo 'Directory "'${OUTDIR}'" already exists, aborting.'>&2 ; exit 1; } +mkdir "${OUTDIR}" || { echo "Directory '${OUTDIR}' already exists, aborting." >&2 ; exit 1; } if [ -n "$GENERATE_FILE" ] ; then [ -n "$OUTFILE" ] && OUTFILE_="$OUTFILE" || OUTFILE_="${OUTDIR}.tar.bz2" - [ -e "${OUTFILE_}" ] && { echo 'File "'${OUTFILE_}'" already exists, aborting.'>&2 ; rm -r "${OUTDIR}"; exit 1; } + [ -e "${OUTFILE_}" ] && { echo "File '${OUTFILE_}' already exists, aborting." >&2 ; rm -r "${OUTDIR}"; exit 1; } OUTFILE=${OUTFILE_} touch "${OUTFILE}" fi @@ -121,7 +121,7 @@ exectest() { echo 'Usage: exectest '>&2 return 1 else - if test -e "$(which $1)" ; then + if test -e "$(which "$1")" ; then return 0 else grep -q "^$1"'$' missing_tools 2>/dev/null || echo "$1" >> missing_tools @@ -137,7 +137,7 @@ diskandsize() { while read major minor blocks device suffix; do isdisk=1 # skip ide cdrom - [ -f /proc/ide/$device/media ] && grep -q cdrom /proc/ide/$device/media && isdisk=0 + [ -f "/proc/ide/${device}/media" ] && grep -q cdrom "/proc/ide/${device}/media" && isdisk=0 [ "$isdisk" -eq 1 ] && echo "$device $blocks" done } @@ -145,9 +145,9 @@ diskandsize() { list_disks() { # print only every second entry; used by disk_info i=0 - for ent in $@; do + for ent in "$@" ; do if [ "$i" -eq 0 ]; then - echo $ent + echo "$ent" i=1 else i=0 @@ -157,9 +157,9 @@ list_disks() { disk_info() { # the variable holds a space separated list of devices and their block size - device_size=`grep -E ' cciss/c.d.$| ida/c.d.$| rd/c.d.$| hd.$| sd.$|/disc$' /proc/partitions | diskandsize` + device_size=$(grep -E ' cciss/c.d.$| ida/c.d.$| rd/c.d.$| hd.$| sd.$|/disc$' /proc/partitions | diskandsize) # a list of all local disks, without size - disklist=`list_disks $device_size` + disklist=$(list_disks "$device_size") } @@ -255,12 +255,12 @@ cd "${OUTDIR}" || exit 1 if [ -r /proc/config.gz ] ; then zcat /proc/config.gz > kernelconfig else - [ -r /boot/config-$UNAME ] && cat /boot/config-$UNAME > kernelconfig + [ -r "/boot/config-${UNAME}" ] && cat "/boot/config-${UNAME}" > kernelconfig fi - exectest dpkg && COLUMNS=1000 dpkg -l linux-image-$UNAME 2>running_kernel.error \ - | grep linux-image-$UNAME | tr -s ' ' > running_kernel 2>>running_kernel.error - dpkg -S /boot/vmlinuz-$(uname -r) >> running_kernel 2>>running_kernel.error + exectest dpkg && COLUMNS=1000 dpkg -l "linux-image-${UNAME}" 2>running_kernel.error \ + | grep "linux-image-${UNAME}" | tr -s ' ' > running_kernel 2>>running_kernel.error + dpkg -S "/boot/vmlinuz-$(uname -r)" >> running_kernel 2>>running_kernel.error # X stuff if [ -n "${DISPLAY}" ] ; then @@ -344,48 +344,48 @@ cd "${OUTDIR}" || exit 1 for disk in $disklist; do if exectest smartctl ; then echo -e "smartctl -a /dev/${disk}:\n" >> smartctl - smartctl -a /dev/$disk >> smartctl + smartctl -a "/dev/$disk" >> smartctl echo -e "\n\n" >> smartctl fi if exectest hdparm ; then echo -e "hdparm -iv /dev/${disk}:\n" >> hdparm - hdparm -iv /dev/$disk >> hdparm + hdparm -iv "/dev/$disk" >> hdparm echo -e "\n\n" >> hdparm fi if exectest fdisk ; then echo -e "fdisk -lu /dev/${disk}:\n" >> fdisk - fdisk -lu /dev/$disk >>fdisk 2>>fdisk.error + fdisk -lu "/dev/$disk" >>fdisk 2>>fdisk.error echo -e "\n\n" >> fdisk fi if exectest parted ; then echo -e "parted -s /dev/${disk}:\n" >> parted - parted -s /dev/$disk print >> parted + parted -s "/dev/$disk" print >> parted echo -e "\n\n" >> parted fi if exectest sdparm ; then echo -e "sdparm --all --long /dev/${disk}:\n" >> sdparm - sdparm --all --long /dev/$disk >> sdparm + sdparm --all --long "/dev/$disk" >> sdparm echo -e "\n\n" >> sdparm fi if exectest sg_inq ; then echo -e "sg_inq /dev/${disk}:\n" >> sg_inq - sg_inq /dev/$disk >> sg_inq + sg_inq "/dev/$disk" >> sg_inq echo -e "\n\n" >> sg_inq fi - file -s /dev/$disk?* | grep -v ": empty" >> file_disk + file -s "/dev/${disk}"?* | grep -v ": empty" >> file_disk done fi ) # get rid of empty files for file in *.error ; do - test -s $file || rm $file + test -s "$file" || rm -- "$file" done echo @@ -395,7 +395,7 @@ cd "${WORKING_DIR}" # create tarball if [ -n "$GENERATE_FILE" ] ; then tar acf "${OUTFILE}" "${OUTDIRNAME}" - [ -r "$OUTFILE" ] && echo "$OUTFILE ("$(ls -ahl "$OUTFILE" | awk '{print $5}')") has been generated." + [ -r "$OUTFILE" ] && echo "$OUTFILE ($(ls -ahl -- "$OUTFILE" | awk '{print $5}')) has been generated." fi # remove (temporary) output directory if needed, else keep it, as it doubles -- 2.1.4 From 87551b7fca974481edae635433b554a629dc3671 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 21 Oct 2015 23:14:42 +0200 Subject: [PATCH 04/16] Fix shell scripting issues discovered by shellcheck --- grml-hwinfo | 91 +++++++++++++++++++++++++++++++------------------------------ 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/grml-hwinfo b/grml-hwinfo index 48ae804..f0bd2a9 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -134,7 +134,7 @@ exectest() { # taken from http://cvs.debian.org/fai/lib/disk-info diskandsize() { local isdisk major minor blocks device suffix - while read major minor blocks device suffix; do + while read _ _ blocks device _ ; do isdisk=1 # skip ide cdrom [ -f "/proc/ide/${device}/media" ] && grep -q cdrom "/proc/ide/${device}/media" && isdisk=0 @@ -171,46 +171,46 @@ cd "${OUTDIR}" || exit 1 echo "This might take a few seconds/minutes. Please be patient..." # some sysinfo - date > date + date > ./date if [ -r /etc/grml_version ] ; then cat /etc/grml_version > grml_version fi if [ -r /etc/debian_version ] ; then cat /etc/debian_version > debian_version fi - uname -a > uname + uname -a > ./uname # disks / devices [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi > scsi - exectest lspci && lspci -nn > lspci + exectest lspci && lspci -nn > ./lspci cat /proc/partitions > partitions find /proc/ide/ -name geometry -exec grep . {} \; > proc_ide 2>/dev/null - df -h > df 2>/dev/null + df -h > ./df 2>/dev/null for i in free lsmod mount lsdev lspnp lsusb ; do - exectest $i && $i > $i + exectest $i && $i > ./$i done - swapon -s > swapon 2>swapon.error + swapon -s > ./swapon 2>./swapon.error # proc stuff for i in cpuinfo interrupts cmdline devices dma fb iomem ioports \ mdstat meminfo modules mtrr pci version ; do [ -r /proc/$i ] && cat /proc/$i > proc_$i done - exectest sysdump && sysdump > sysdump 2>sysdump.error + exectest sysdump && sysdump > ./sysdump 2>./sysdump.error # log dmesg > dmesg.cur # hwinfo - exectest discover && discover -v --type-summary --enable-bus all > discover 2> discover.2 + exectest discover && discover -v --type-summary --enable-bus all > ./discover 2>./discover.2 exectest hwinfo && hwinfo log=hwinfo - exectest numactl && numactl --hardware > numactl - exectest x86info && x86info > x86info 2>x86info.2 - exectest lscpu && lscpu > lscpu + exectest numactl && numactl --hardware > ./numactl + exectest x86info && x86info > ./x86info 2>./x86info.2 + exectest lscpu && lscpu > ./lscpu # net stuff, net-tools: - exectest ifconfig && ifconfig -v -a > ifconfig - exectest route && route -n > route + exectest ifconfig && ifconfig -v -a > ./ifconfig + exectest route && route -n > ./route # net stuff, iproute: exectest ip && ip addrlabel list > ip_addrlabel @@ -224,7 +224,7 @@ cd "${OUTDIR}" || exit 1 exectest ip && ip ntable show > ip_ntable exectest ip && ip route show > ip_route exectest ip && if [ -r /etc/iproute2/rt_tables ] ; then - grep -v '^#' /etc/iproute2/rt_tables | while read table name ; do + grep -v '^#' /etc/iproute2/rt_tables | while read table _ ; do ip route show table "${table}" > "ip_route_table_${table}" done fi @@ -244,11 +244,11 @@ cd "${OUTDIR}" || exit 1 cat /proc/acpi/info > acpi_info fi - exectest acpi && acpi > acpi 2> acpi.error && acpi -v > acpi.version - [ -r /proc/apm/ ] && apm > apm + exectest acpi && acpi > ./acpi 2>acpi.error && acpi -v > ./acpi.version + [ -r /proc/apm/ ] && apm > ./apm if exectest mcelog ; then - mcelog > mcelog 2>mcelog.error + mcelog > ./mcelog 2>./mcelog.error fi # kernel stuff @@ -264,10 +264,10 @@ cd "${OUTDIR}" || exit 1 # X stuff if [ -n "${DISPLAY}" ] ; then - exectest xviddetect && xviddetect > xviddetect - exectest xvidtune && xvidtune -show > xdivtune - exectest xrandr && xrandr > xrandr - exectest xdpyinfo && xdpyinfo > xdpyinfo + exectest xviddetect && xviddetect > ./xviddetect + exectest xvidtune && xvidtune -show > ./xdivtune + exectest xrandr && xrandr > ./xrandr + exectest xdpyinfo && xdpyinfo > ./xdpyinfo X -version > x_version 2>&1 fi @@ -285,8 +285,8 @@ cd "${OUTDIR}" || exit 1 else echo "running as root" > root disk_info - exectest sfdisk && sfdisk -d > sfdisk 2>sfdisk.error - exectest dmidecode && dmidecode > dmidecode + exectest sfdisk && sfdisk -d > ./sfdisk 2>./sfdisk.error + exectest dmidecode && dmidecode > ./dmidecode exectest dconf && dconf -o dconf @@ -295,36 +295,36 @@ cd "${OUTDIR}" || exit 1 fi if exectest edac-util ; then - edac-util > edac-util 2>edac-util.error + edac-util > ./edac-util 2>./edac-util.error edac-util --report=full > edac-util_report 2>edac-util_report.error fi if exectest decode-dimms ; then - decode-dimms > decode-dimms 2>decode-dimms.error + decode-dimms > ./decode-dimms 2>./decode-dimms.error elif [ -x /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl ] ; then /usr/share/doc/lm-sensors/examples/eeprom/decode-dimms.pl > decode-dimms 2>decode-dimms.error fi # proxmox - exectest qm && qm list > qm 2>qm.error + exectest qm && qm list > ./qm 2>./qm.error # libvirt - exectest virsh && virsh list >virsh 2>virsh.error + exectest virsh && virsh list >./virsh 2>./virsh.error # openvz - exectest vzlist && vzlist >vzlist 2>vzlist.error + exectest vzlist && vzlist >./vzlist 2>./vzlist.error # vserver - exectest vserver-stat && vserver-stat >vserver-stat 2>vserver-stat.error + exectest vserver-stat && vserver-stat >./vserver-stat 2>./vserver-stat.error - exectest mdadm && mdadm --detail /dev/md[0-9]* >> mdadm 2>mdadm.error + exectest mdadm && mdadm --detail /dev/md[0-9]* >> ./mdadm 2>./mdadm.error # LVM - exectest pvs && pvs > pvs 2>pvs.error - exectest vgs && vgs > vgs 2>vgs.error - exectest lvs && lvs > lvs 2>lvs.error - exectest lvdisplay && lvdisplay > lvdisplay 2>lvdisplay.error + exectest pvs && pvs > ./pvs 2>./pvs.error + exectest vgs && vgs > ./vgs 2>./vgs.error + exectest lvs && lvs > ./lvs 2>./lvs.error + exectest lvdisplay && lvdisplay > ./lvdisplay 2>./lvdisplay.error exectest dmsetup && dmsetup ls > dmsetup_ls 2>dmsetup_ls.error exectest dmsetup && dmsetup ls --tree > dmsetup_ls_tree 2>dmsetup_ls_tree.error - exectest lsblk && lsblk > lsblk 2>lsblk.error + exectest lsblk && lsblk > ./lsblk 2>./lsblk.error # iSCSI if exectest iscsiadm ; then @@ -337,44 +337,44 @@ cd "${OUTDIR}" || exit 1 fi if exectest lsscsi ; then - lsscsi > lsscsi 2>lsscsi.error - lsscsi -t > lsscsi_transport 2>lsscsi_transport.error + lsscsi > ./lsscsi 2>./lsscsi.error + lsscsi -t > ./lsscsi_transport 2>./lsscsi_transport.error fi for disk in $disklist; do if exectest smartctl ; then echo -e "smartctl -a /dev/${disk}:\n" >> smartctl - smartctl -a "/dev/$disk" >> smartctl - echo -e "\n\n" >> smartctl + smartctl -a "/dev/$disk" >> ./smartctl + echo -e "\n\n" >> ./smartctl fi if exectest hdparm ; then echo -e "hdparm -iv /dev/${disk}:\n" >> hdparm - hdparm -iv "/dev/$disk" >> hdparm + hdparm -iv "/dev/$disk" >> ./hdparm echo -e "\n\n" >> hdparm fi if exectest fdisk ; then echo -e "fdisk -lu /dev/${disk}:\n" >> fdisk - fdisk -lu "/dev/$disk" >>fdisk 2>>fdisk.error + fdisk -lu "/dev/$disk" >> ./fdisk 2>> ./fdisk.error echo -e "\n\n" >> fdisk fi if exectest parted ; then echo -e "parted -s /dev/${disk}:\n" >> parted - parted -s "/dev/$disk" print >> parted + parted -s "/dev/$disk" print >> ./parted echo -e "\n\n" >> parted fi if exectest sdparm ; then echo -e "sdparm --all --long /dev/${disk}:\n" >> sdparm - sdparm --all --long "/dev/$disk" >> sdparm + sdparm --all --long "/dev/$disk" >> ./sdparm echo -e "\n\n" >> sdparm fi if exectest sg_inq ; then echo -e "sg_inq /dev/${disk}:\n" >> sg_inq - sg_inq "/dev/$disk" >> sg_inq + sg_inq "/dev/$disk" >> ./sg_inq echo -e "\n\n" >> sg_inq fi @@ -395,6 +395,7 @@ cd "${WORKING_DIR}" # create tarball if [ -n "$GENERATE_FILE" ] ; then tar acf "${OUTFILE}" "${OUTDIRNAME}" + # shellcheck disable=SC2012 [ -r "$OUTFILE" ] && echo "$OUTFILE ($(ls -ahl -- "$OUTFILE" | awk '{print $5}')) has been generated." fi -- 2.1.4 From 1b107c81288f9debebe73004455ed9c0cb4b12eb Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 21 Oct 2015 23:16:15 +0200 Subject: [PATCH 05/16] Save stderr of x86info and discover in *.error instead of *.2 Make those two commands behave as all the other ones to get consistent behaviour. --- grml-hwinfo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grml-hwinfo b/grml-hwinfo index f0bd2a9..67cfac5 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -202,10 +202,10 @@ cd "${OUTDIR}" || exit 1 dmesg > dmesg.cur # hwinfo - exectest discover && discover -v --type-summary --enable-bus all > ./discover 2>./discover.2 + exectest discover && discover -v --type-summary --enable-bus all > ./discover 2>./discover.error exectest hwinfo && hwinfo log=hwinfo exectest numactl && numactl --hardware > ./numactl - exectest x86info && x86info > ./x86info 2>./x86info.2 + exectest x86info && x86info > ./x86info 2>./x86info.error exectest lscpu && lscpu > ./lscpu # net stuff, net-tools: -- 2.1.4 From 9010e65d818434843f4dc1279ae845729f6539be Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 21 Oct 2015 23:17:13 +0200 Subject: [PATCH 06/16] Bump Standards-Version to 3.9.6 --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index f5fe317..92c3b9b 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: admin Priority: optional Maintainer: Michael Prokop Build-Depends: debhelper (>= 5.0.0) -Standards-Version: 3.9.5 +Standards-Version: 3.9.6 Homepage: http://git.grml.org/?p=grml-hwinfo.git Vcs-git: git://git.grml.org/grml-hwinfo.git Vcs-Browser: http://git.grml.org/?p=grml-hwinfo.git -- 2.1.4 From 3a92e15822e3e5929a64b22a58cf872df7a705ea Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Wed, 21 Oct 2015 23:19:50 +0200 Subject: [PATCH 07/16] Release new version 0.11.0 --- debian/changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index cdd1aaf..48db1a5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +grml-hwinfo (0.11.0) unstable; urgency=medium + + * [8eca38c] ip: also store table specific route information + * [55629e0] Improve shell quoting (thanks to shellcheck) + * [87551b7] Fix shell scripting issues discovered by shellcheck + * [1b107c8] Save stderr of x86info and discover in *.error instead of *.2 + * [9010e65] Bump Standards-Version to 3.9.6 + + -- Michael Prokop Wed, 21 Oct 2015 23:19:35 +0200 + grml-hwinfo (0.10.0) unstable; urgency=medium * [43246c9] Support mcelog -- 2.1.4 From fb0e3560121d35f1b430a3cf3fd93a2f7b920d6a Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 19 Nov 2015 15:17:19 +0100 Subject: [PATCH 08/16] Support options --force + --quiet for usage with cron --- grml-hwinfo | 60 +++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/grml-hwinfo b/grml-hwinfo index 67cfac5..406f9b7 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -23,13 +23,13 @@ export LC_ALL=C TIMESTAMP='+%F--%H-%M-%S-%Z' DATE="$(date $TIMESTAMP)" -echo "$PN ${VERSION} - collect hardware information" - # defaults GENERATE_FILE='1' GENERATE_DIRECTORY='' _opt_output_directory=false _opt_output_file=false +_opt_quiet=false +_opt_force=false usage() { echo " @@ -45,13 +45,15 @@ usage() { -d, --directory Create grml-hwinfo-TIMESTAMP as a directory (no file) -f, --file Create grml-hwinfo-TIMESTAMP.tar.bz2 [default action] -h, --help Display this help message + -q, --quiet Don't display informational text (useful for cron usage) + --force Don't abort but overwrite possibly existing output file --output-directory Store output files in specified directory - --output-file Store output in specified filename (tar.bz2 format) + --output-file Store output in specified filename (tar.XX format) " } -CMDLINE_OPTS=output-directory:,output-file:,both,directory,file,help -_opt_temp=$(getopt --name grml-hwinfo -o +bdfh --long $CMDLINE_OPTS -- "$@") +CMDLINE_OPTS=output-directory:,output-file:,both,directory,file,help,quiet,force +_opt_temp=$(getopt --name grml-hwinfo -o +bdfhq --long $CMDLINE_OPTS -- "$@") if [ $? -ne 0 ]; then echo "Try 'grml-hwinfo --help' for more information." >&2 exit 1 @@ -87,6 +89,12 @@ while :; do GENERATE_DIRECTORY='1' GENERATE_FILE='1' ;; + -q|--quiet) + _opt_quiet=true + ;; + --force) + _opt_force=true + ;; --) shift; break ;; @@ -98,21 +106,31 @@ while :; do shift done +if ! $_opt_quiet ; then + echo "$PN ${VERSION} - collect hardware information" +fi + # Generate output/temporary directory name & path, and output file path [ -n "$OUTDIRNAME" ] || OUTDIRNAME="grml-hwinfo-${DATE}" OUTDIR="${WORKING_DIR}/${OUTDIRNAME}" -mkdir "${OUTDIR}" || { echo "Directory '${OUTDIR}' already exists, aborting." >&2 ; exit 1; } +if $_opt_force ; then + mkdir -p "${OUTDIR}" +else + mkdir "${OUTDIR}" || { echo "Directory '${OUTDIR}' already exists, aborting." >&2 ; exit 1; } +fi if [ -n "$GENERATE_FILE" ] ; then [ -n "$OUTFILE" ] && OUTFILE_="$OUTFILE" || OUTFILE_="${OUTDIR}.tar.bz2" - [ -e "${OUTFILE_}" ] && { echo "File '${OUTFILE_}' already exists, aborting." >&2 ; rm -r "${OUTDIR}"; exit 1; } + if ! $_opt_force ; then + [ -e "${OUTFILE_}" ] && { echo "File '${OUTFILE_}' already exists, aborting." >&2 ; rm -r "${OUTDIR}"; exit 1; } + fi OUTFILE=${OUTFILE_} touch "${OUTFILE}" fi if [ "$(id -u)" != "0" ] ; then NOTROOT=1 - echo "W: Running without root permissions. Not all data will be collected." + $_opt_quiet || echo "W: Running without root permissions. Not all data will be collected." fi # check whether a binary is available and executable @@ -124,7 +142,9 @@ exectest() { if test -e "$(which "$1")" ; then return 0 else - grep -q "^$1"'$' missing_tools 2>/dev/null || echo "$1" >> missing_tools + if ! grep -q "^$1"'$' missing_tools 2>/dev/null ; then + $_opt_quiet || echo "$1" >> missing_tools + fi return 1 fi fi @@ -165,10 +185,12 @@ disk_info() { cd "${OUTDIR}" || exit 1 ( - [ -n "$GENERATE_FILE" ] && echo "Output file: $OUTFILE" - [ -n "$GENERATE_DIRECTORY" ] && echo "Output directory: $OUTDIR" - echo - echo "This might take a few seconds/minutes. Please be patient..." + if ! $_opt_quiet ; then + [ -n "$GENERATE_FILE" ] && echo "Output file: $OUTFILE" + [ -n "$GENERATE_DIRECTORY" ] && echo "Output directory: $OUTDIR" + echo + echo "This might take a few seconds/minutes. Please be patient..." + fi # some sysinfo date > ./date @@ -388,15 +410,17 @@ for file in *.error ; do test -s "$file" || rm -- "$file" done -echo +$_opt_quiet || echo cd "${WORKING_DIR}" # create tarball if [ -n "$GENERATE_FILE" ] ; then tar acf "${OUTFILE}" "${OUTDIRNAME}" - # shellcheck disable=SC2012 - [ -r "$OUTFILE" ] && echo "$OUTFILE ($(ls -ahl -- "$OUTFILE" | awk '{print $5}')) has been generated." + if ! $_opt_quiet ; then + # shellcheck disable=SC2012 + [ -r "$OUTFILE" ] && echo "$OUTFILE ($(ls -ahl -- "$OUTFILE" | awk '{print $5}')) has been generated." + fi fi # remove (temporary) output directory if needed, else keep it, as it doubles @@ -404,7 +428,9 @@ fi if [ -z "$GENERATE_DIRECTORY" ] ; then rm -r "${OUTDIR}" else - [ -r "${OUTDIR}" ] && echo "${OUTDIR} has been generated." + if ! $_opt_quiet ; then + [ -r "${OUTDIR}" ] && echo "${OUTDIR} has been generated." + fi fi exit 0 -- 2.1.4 From fc34c5d064aab1a288ef7fc0166a77b898343619 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 19 Nov 2015 15:17:37 +0100 Subject: [PATCH 09/16] Improve local disk detection for recent kernel changes Based on https://github.com/faiproject/fai/blob/master/lib/fai-disk-info --- grml-hwinfo | 34 +++++++++------------------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/grml-hwinfo b/grml-hwinfo index 406f9b7..1b572f4 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -150,36 +150,20 @@ exectest() { fi } -# echo a list of all disks and their size -# taken from http://cvs.debian.org/fai/lib/disk-info -diskandsize() { - local isdisk major minor blocks device suffix - while read _ _ blocks device _ ; do +# based on https://github.com/faiproject/fai/blob/master/lib/fai-disk-info +checkdisk() { + local isdisk device + while read _ _ _ device _ ; do isdisk=1 - # skip ide cdrom - [ -f "/proc/ide/${device}/media" ] && grep -q cdrom "/proc/ide/${device}/media" && isdisk=0 - [ "$isdisk" -eq 1 ] && echo "$device $blocks" - done -} - -list_disks() { - # print only every second entry; used by disk_info - i=0 - for ent in "$@" ; do - if [ "$i" -eq 0 ]; then - echo "$ent" - i=1 - else - i=0 - fi + # skip CDROMs + [ "$(stat -c %G /dev/$device)" = "disk" ] || isdisk=0 + [ "$isdisk" -eq 1 ] && echo "$device" done } disk_info() { - # the variable holds a space separated list of devices and their block size - device_size=$(grep -E ' cciss/c.d.$| ida/c.d.$| rd/c.d.$| hd.$| sd.$|/disc$' /proc/partitions | diskandsize) - # a list of all local disks, without size - disklist=$(list_disks "$device_size") + # the variable holds a newline separated list of devices + disklist=$(egrep ' etherd/e[[:digit:]]+\.[[:digit:]]+\b| i2o/hd.+\b| cciss/c.+d.+\b| ida/c.+d.+\b| rd/c.+d.+\b| fio.\b| hd.\b| sd[a-z]{1,2}\b|/disc\b| vd.\b| xvd.\b' /proc/partitions | checkdisk) } -- 2.1.4 From c5989b9ae42a5cf640f17e354be37f40088f267c Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 19 Nov 2015 15:20:25 +0100 Subject: [PATCH 10/16] Fix shellcheck issue with quoting --- grml-hwinfo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grml-hwinfo b/grml-hwinfo index 1b572f4..48b9676 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -156,7 +156,7 @@ checkdisk() { while read _ _ _ device _ ; do isdisk=1 # skip CDROMs - [ "$(stat -c %G /dev/$device)" = "disk" ] || isdisk=0 + [ "$(stat -c %G /dev/"${device}")" = "disk" ] || isdisk=0 [ "$isdisk" -eq 1 ] && echo "$device" done } -- 2.1.4 From 5afa0d80a53a44fdb30a3e2ba43fb4df02ab7632 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 19 Nov 2015 15:47:07 +0100 Subject: [PATCH 11/16] Don't use working directory when --output-directory option is used Otherwise when running something like: /root/system-info/grml-hwinfo --output-directory=/root/system-info/grml-hwinfo-data via cron this store data to /root/root/system-info/grml-hwinfo-data (instead of the requested /root/system-info/grml-hwinfo-data) since /root is the working directory for cron. --- grml-hwinfo | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/grml-hwinfo b/grml-hwinfo index 48b9676..75567b2 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -112,7 +112,12 @@ fi # Generate output/temporary directory name & path, and output file path [ -n "$OUTDIRNAME" ] || OUTDIRNAME="grml-hwinfo-${DATE}" -OUTDIR="${WORKING_DIR}/${OUTDIRNAME}" +if $_opt_output_directory ; then + OUTDIR="${OUTDIRNAME}" +else + OUTDIR="${WORKING_DIR}/${OUTDIRNAME}" +fi + if $_opt_force ; then mkdir -p "${OUTDIR}" else -- 2.1.4 From 3e8d59e50ce8d91a04a0d1fc2014cf4b6d1d88d2 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 19 Nov 2015 15:49:00 +0100 Subject: [PATCH 12/16] Release new version 0.12.0 --- debian/changelog | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index 48db1a5..0516d78 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +grml-hwinfo (0.12.0) unstable; urgency=medium + + * [fb0e356] Support options --force + --quiet for usage with cron + * [fc34c5d] Improve local disk detection for recent kernel changes + * [c5989b9] Fix shellcheck issue with quoting + * [5afa0d8] Don't use working directory when --output-directory option + is used + + -- Michael Prokop Thu, 19 Nov 2015 15:48:55 +0100 + grml-hwinfo (0.11.0) unstable; urgency=medium * [8eca38c] ip: also store table specific route information -- 2.1.4 From 588c3c881bfb3f806f8a49bf1d3ec9bc86204d65 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Mon, 14 Dec 2015 13:25:23 +0100 Subject: [PATCH 13/16] Redirect hdparm + sg_inq errors to according .error files sg_inq might raise: Both SCSI INQUIRY and fetching ATA information failed on /dev/vda and hdparm might raise: HDIO_DRIVE_CMD(identify) failed: Inappropriate ioctl for device HDIO_GET_IDENTITY failed: Inappropriate ioctl for device This is annoying when running grml-hwinfo under cron, so let's redirect this output to their according .error files. --- grml-hwinfo | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/grml-hwinfo b/grml-hwinfo index 75567b2..eeabf61 100755 --- a/grml-hwinfo +++ b/grml-hwinfo @@ -361,7 +361,7 @@ cd "${OUTDIR}" || exit 1 if exectest hdparm ; then echo -e "hdparm -iv /dev/${disk}:\n" >> hdparm - hdparm -iv "/dev/$disk" >> ./hdparm + hdparm -iv "/dev/$disk" >> ./hdparm 2>> ./hdparm.error echo -e "\n\n" >> hdparm fi @@ -385,7 +385,7 @@ cd "${OUTDIR}" || exit 1 if exectest sg_inq ; then echo -e "sg_inq /dev/${disk}:\n" >> sg_inq - sg_inq "/dev/$disk" >> ./sg_inq + sg_inq "/dev/$disk" >> ./sg_inq 2>> ./sg_inq.error echo -e "\n\n" >> sg_inq fi -- 2.1.4 From 49cba9651f79c4452b696f6f742871c62bdb7722 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 27 Jan 2017 16:11:34 +0100 Subject: [PATCH 14/16] Bump Standards-Version to 3.9.8 --- debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/control b/debian/control index 92c3b9b..e59cfb3 100644 --- a/debian/control +++ b/debian/control @@ -3,7 +3,7 @@ Section: admin Priority: optional Maintainer: Michael Prokop Build-Depends: debhelper (>= 5.0.0) -Standards-Version: 3.9.6 +Standards-Version: 3.9.8 Homepage: http://git.grml.org/?p=grml-hwinfo.git Vcs-git: git://git.grml.org/grml-hwinfo.git Vcs-Browser: http://git.grml.org/?p=grml-hwinfo.git -- 2.1.4 From 8c8df09c31b016ada45f0e67c3a8ae35025a2690 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 27 Jan 2017 16:11:54 +0100 Subject: [PATCH 15/16] Use SSL for Homepage + Vcs-Browser URLs --- debian/control | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/control b/debian/control index e59cfb3..be77e27 100644 --- a/debian/control +++ b/debian/control @@ -4,9 +4,9 @@ Priority: optional Maintainer: Michael Prokop Build-Depends: debhelper (>= 5.0.0) Standards-Version: 3.9.8 -Homepage: http://git.grml.org/?p=grml-hwinfo.git +Homepage: https://git.grml.org/?p=grml-hwinfo.git Vcs-git: git://git.grml.org/grml-hwinfo.git -Vcs-Browser: http://git.grml.org/?p=grml-hwinfo.git +Vcs-Browser: https://git.grml.org/?p=grml-hwinfo.git Origin: Grml Bugs: mailto:bugs@grml.org -- 2.1.4 From 8618504c7260d0983e1011fabdf99c0a2d3f4dbd Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Fri, 27 Jan 2017 16:13:11 +0100 Subject: [PATCH 16/16] Bump debian/compat to 9 --- debian/compat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/compat b/debian/compat index 7ed6ff8..ec63514 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -5 +9 -- 2.1.4