parent
2a0b63e8a1
commit
724048f272
@ -1,11 +1,29 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
MKSED=false
|
# GET THE INITITAL OUTPUT OF `ls /sys/block`
|
||||||
OUTPUT="$(ls -l --color=never /sys/block | grep -v virtual | grep devices | cut -d\ -f9- | sed 's/\.\.\/devices\/pci//g;s/[0-9]\{4\}:[0-9]\{2\}[0-9:.a-f]*//g;s/\/\/\/*//g;s/->/=/g' | cut -d/ -f1)"
|
OUTPUT="$(ls -l --color=never /sys/block | grep -v virtual | grep devices | cut -d\ -f9-)"
|
||||||
|
|
||||||
case "${1}" in
|
# STRIP OFF THE PCI BUS LOCATION INFORMATION
|
||||||
--sed) sed "$(echo ""${OUTPUT}"" | sed 's/ = / (/g;s/\(sd.\)/s\/\1 \\{7\\}\/\1/g;s/ s\//)\/g;s\//g'))/g" /dev/stdin ;;
|
OUTPUT="$(echo "${OUTPUT}" | sed 's|\.\.\/devices/pci[0-9a-f:]\{7\}\(/[0-9a-f:.]\{12\}\)\+/||g')"
|
||||||
*) echo "${OUTPUT}" ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
#STRIP OFF THE SUPERFLUOUS USB HOST INFORMATION
|
||||||
|
OUTPUT="$(echo "${OUTPUT}" | sed 's|\(usb[0-9]\+\)/.*/host|\1/host|g')"
|
||||||
|
|
||||||
|
# CONDENSE THE TARGET INFORMATION
|
||||||
|
OUTPUT="$(echo "${OUTPUT}" | sed 's|target[0-9:]\+/[0-9:]\+:\([0-9]\+\)|target\1|g')"
|
||||||
|
|
||||||
|
# STRIP OFF BLOCKS
|
||||||
|
OUTPUT="$(echo "${OUTPUT}" | sed 's|/block/.*||g')"
|
||||||
|
|
||||||
|
# CONVERT -> TO A TAB
|
||||||
|
OUTPUT="${OUTPUT// -> / }"
|
||||||
|
|
||||||
|
# SWAP COLUMNS
|
||||||
|
OUTPUT="$(echo "${OUTPUT}" | awk '{t=$1; $1=$2; $2=t; print;}')"
|
||||||
|
|
||||||
|
# NOW GET DEVICE IDs
|
||||||
|
|
||||||
|
while read -r LOCATION BLOCKDEV; do
|
||||||
|
DEVICE_ID="$(ls -l --color=never /dev/disk/by-id | sed 's/ \+/ /g' | grep -v 'nvme-eui\|wwn-' | grep "${BLOCKDEV}$" | cut -d\ -f9)"
|
||||||
|
echo "${LOCATION} ${BLOCKDEV} ${DEVICE_ID}"
|
||||||
|
done <<< "${OUTPUT}"
|
||||||
|
Loading…
Reference in new issue