From c8e87e5b08b6cb59a9585cc3dd54f1de3b403a71 Mon Sep 17 00:00:00 2001 From: BrainwreckedTech <3752022+BrainwreckedTech@users.noreply.github.com> Date: Tue, 11 Jan 2022 05:34:46 -0500 Subject: [PATCH] Added delete and rescan verbs --- scsictl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scsictl b/scsictl index f4e7dfd..9c8f4f0 100755 --- a/scsictl +++ b/scsictl @@ -39,7 +39,22 @@ case "${1}" in done sort -n -o /tmp/scsictl /tmp/scsictl column -N H:C:I:L,PORT,DEV,SIZE,NAME -t -R1,4 -o" " /tmp/scsictl - rm /tmp/scsictl - ;; + rm /tmp/scsictl;; + delete|rescan) + case "${2}" in + sd*) + if [ -e "/sys/class/block/${2}" ]; then + echo 1 | sudo tee "/sys/class/block/${2}/device/${1}" > /dev/null + else + echo "Device '${2}' not found."; exit 1 + fi;; + [0-9]:*|[0-9][0-9]:*|[0-9][0-9][0-9]:*) + if [ -e "/sys/class/scsi_device/${2}" ]; then + echo 1 | sudo tee "/sys/class/scsi_device/${2}/device/${1}" > /dev/null + else + echo "Device '${2}' not found."; exit 1 + fi;; + *) echo "Uknown device '${2}' -- expected sd[x] or n:n:n:n";; + esac;; *) echo "Unknown verb '${1}' -- expected delete, list, or rescan"; exit 1;; esac