From 92b84092077f5238f8067f24e9fc330ddefb4525 Mon Sep 17 00:00:00 2001 From: Joern Siglen Date: Fri, 26 Aug 2022 11:51:33 +0200 Subject: [PATCH] dbginfo.sh: ensure type commands compatible with dash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All debian distors use the dash shell as default, where type is not supprting "-t" parameter Remove of "-t" where not important and change type check not using -t Reviewed-by: Mario Held Signed-off-by: Joern Siglen Signed-off-by: Jan Höppner --- scripts/dbginfo.sh | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/scripts/dbginfo.sh b/scripts/dbginfo.sh index 9cbe98ba..da3a3227 100755 --- a/scripts/dbginfo.sh +++ b/scripts/dbginfo.sh @@ -17,7 +17,7 @@ export LC_ALL readonly SCRIPTNAME="${0##*/}" # general name of this script # readonly DATETIME="$(date +%Y-%m-%d-%H-%M-%S 2>/dev/null)" -readonly DOCKER=$(if type -t docker >/dev/null; then echo "YES"; else echo "NO"; fi) +readonly DOCKER=$(if type docker >/dev/null; then echo "YES"; else echo "NO"; fi) readonly HW="$(uname -i 2>/dev/null)" # retrieve and split kernel version readonly KERNEL_BASE="$(uname -r 2>/dev/null)" @@ -25,7 +25,7 @@ readonly KERNEL_VERSION=$(echo ${KERNEL_BASE} | cut -d'.' -f1 ) readonly KERNEL_MAJOR_REVISION=$(echo ${KERNEL_BASE} | cut -d'.' -f2 ) readonly KERNEL_MINOR_REVISION=$(echo ${KERNEL_BASE} | cut -d'.' -f3 | sed 's/[^0-9].*//g') readonly KERNEL_INFO=${KERNEL_VERSION}.${KERNEL_MAJOR_REVISION}.${KERNEL_MINOR_REVISION} -readonly KVM=$(if type -t virsh >/dev/null; then echo "YES"; else echo "NO"; fi) +readonly KVM=$(if type virsh >/dev/null; then echo "YES"; else echo "NO"; fi) # The file to indicate that another instance of the script is already running readonly LOCKFILE="/tmp/${SCRIPTNAME}.lock" # check limits for logfiles like /var/log/messages @@ -690,12 +690,12 @@ collect_vmcmdsout() { if echo "${RUNTIME_ENVIRONMENT}" | grep -qi "z/VM" >/dev/null 2>&1; then pr_collect_output "z/VM" - if type -t vmcp >/dev/null; then + if type vmcp >/dev/null; then cp_command="vmcp" if ! lsmod 2>/dev/null | grep -q vmcp && modinfo vmcp >/dev/null 2>&1; then modprobe vmcp && module_loaded=0 && sleep 2 fi - elif type -t hcp >/dev/null; then + elif type hcp >/dev/null; then cp_command="hcp" if ! lsmod 2>/dev/null | grep -q cpint; then modprobe cpint && module_loaded=0 && sleep 2 @@ -789,7 +789,7 @@ collect_sysfs() { # files known to block on read (-x). Stop reading a file that takes # more than 5 seconds (-T 5) such as an active ftrace buffer. # error messages are not written to the log - if type -t dump2tar >/dev/null; then + if type dump2tar >/dev/null; then dump2tar /sys -z -o "${OUTPUT_FILE_SYSFS}.tgz" \ -x '*/tracing/trace_pipe*' \ -x '*/page_idle/bitmap*' \ @@ -867,7 +867,7 @@ collect_osaoat() { network_devices=$(lsqeth 2>/dev/null | grep "Device name" \ | sed 's/D.*:[[:space:]]*\([^[:space:]]*\)[[:space:]]\+/\1/g') - if type -t qethqoat >/dev/null; then + if type qethqoat >/dev/null; then if test -n "${network_devices}"; then pr_collect_output "osa oat" for network_device in ${network_devices}; do @@ -890,7 +890,7 @@ collect_ethtool() { local network_device network_devices=$(ls /sys/class/net 2>/dev/null) - if type -t ethtool >/dev/null; then + if type ethtool >/dev/null; then if test -n "${network_devices}"; then pr_collect_output "ethtool" for network_device in ${network_devices}; do @@ -931,7 +931,7 @@ collect_tc() { local network_device network_devices=$(ls /sys/class/net 2>/dev/null) - if type -t tc >/dev/null; then + if type tc >/dev/null; then if test -n "${network_devices}"; then pr_collect_output "Trafic Control" for network_device in ${network_devices}; do @@ -952,7 +952,7 @@ collect_bridge() { local network_device network_devices=$(ls /sys/class/net 2>/dev/null) - if type -t bridge >/dev/null; then + if type bridge >/dev/null; then if test -n "${network_devices}"; then pr_collect_output "bridge" for network_device in ${network_devices}; do @@ -984,7 +984,7 @@ collect_ovs() { :ovs-vsctl -t 5 show\ :ovsdb-client dump\ " - if type -t ovs-vsctl >/dev/null; then + if type ovs-vsctl >/dev/null; then pr_collect_output "OpenVSwitch" IFS=: for ovscmd in ${ovscmds}; do @@ -1047,7 +1047,7 @@ collect_docker() { collect_nvme() { local device - if type -t nvme >/dev/null; then + if type nvme >/dev/null; then pr_collect_output "NVME storage" call_run_command "nvme list" "${OUTPUT_FILE_NVME}" for device in /dev/nvme[0-9]*; do @@ -1149,19 +1149,19 @@ call_run_command() { local logfile="${2}" # extract the raw_command and set cmd_type local raw_cmd=$(echo "${cmd}" | sed -ne 's/^\([^[:space:]]*\).*$/\1/p') - local cmd_type=$(type -t ${raw_cmd}) + local cmd_type=$(type ${raw_cmd} | cut -d' ' -sf4,5) # timeout_ok - like a boolean - is not empty if command exists - local timeout_ok=$(type -t timeout) + local timeout_ok=$(type timeout) echo "#######################################################" >> "${logfile}" echo "${USER}@${SYSTEMHOSTNAME:-localhost}> ${cmd}" >> "${logfile}" # check calling command type - if [ "X${cmd_type}" = "Xbuiltin" ]; then + if [ "X${cmd_type}" = "Xshell builtin" ]; then # command is a builtin (no use of timeout possible) eval "${cmd}" >> ${logfile} 2>&1 rc=$? - elif [ "X${cmd_type}" != "X" ]; then + elif [ "X${cmd_type}" != "Xnot found" ]; then if [ "X${timeout_ok}" = "Xfile" ]; then eval timeout -k ${TOS} ${TOS} "${cmd}" >> ${logfile} 2>&1 rc=$?