mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
dbginfo.sh: ensure type commands compatible with dash
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 <mario.held@de.ibm.com> Signed-off-by: Joern Siglen <siglen@de.ibm.com> Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
This commit is contained in:
committed by
Jan Höppner
parent
bc3134ba5a
commit
92b8409207
@@ -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=$?
|
||||
|
||||
Reference in New Issue
Block a user