Created
October 4, 2017 09:52
-
-
Save Decstasy/2a03474797bc11f21c3357eef9af210d to your computer and use it in GitHub Desktop.
simple lsscsi for .bashrc if there is no repository available or the server is too old
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Dennis Ullrich | |
# [email protected] | |
# 2017-10-03 | |
# Insert the following to your .bashrc and execute "source ~/.bashrc" | |
# It is for servers with no connection to a repository as a short workaround | |
if ! type lsscsi >/dev/null 2>&1; then | |
lsscsi() { | |
echo -e "WARNING: lsscsi is a .bashrc function!\n" | |
for DEVICE in /sys/class/scsi_device/*; do | |
BLOCK=$(ls ${DEVICE}/device/block 2>/dev/null) | |
if [ $? -ne 0 ]; then | |
BLOCK=$(readlink ${DEVICE}/device/block*) | |
BLOCK=${BLOCK##*/} | |
fi | |
_types=(\ | |
"disk " "tape " "printer" "process" "worm " "cd/dvd " \ | |
"scanner" "optical" "mediumx" "comms " "(0xa) " "(0xb) " \ | |
"storage" "enclosu" "sim dsk" "opti rd" "bridge " "osd " \ | |
"adi " "sec man" "zbc " "(0x15) " "(0x16) " "(0x17) " \ | |
"(0x18) " "(0x19) " "(0x1a) " "(0x1b) " "(0x1c) " "(0x1e) " \ | |
"wlun " "no dev " \ | |
) | |
DEVTYPE=$(cat ${DEVICE}/device/type) | |
DEVTYPE=${_types[DEVTYPE]} | |
VENDOR=$(cat ${DEVICE}/device/vendor) | |
MODEL=$(cat ${DEVICE}/device/model) | |
REV=$(cat ${DEVICE}/device/rev) | |
printf "%-12s %-7s %-8s %-16s %-5s %s\n" "[${DEVICE##*/}]" "${DEVTYPE}" "${VENDOR}" "${MODEL}" "${REV}" "/dev/${BLOCK}" | |
done | |
} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment