feat: add tapes index view

This commit is contained in:
Samuel N Cui
2023-10-03 16:12:44 +08:00
parent 15079aaa50
commit 999b9bf9b2
27 changed files with 1357 additions and 358 deletions
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
set -e;
DEVICE=`readlink -f ${DEVICE}`
REGEXP='/dev/n?st([0-9]+)[alm]?'
if [[ ! $DEVICE =~ $REGEXP ]]; then
echo "'$DEVICE' doesn't match" >&2
exit 1
fi
NUM="${BASH_REMATCH[1]}"
TRIES=("/dev/nst${NUM}" "/dev/st${NUM}")
for TRY in ${TRIES[@]}; do
SG_DEVICE=`sg_map | grep ${TRY} || echo ''`;
if [[ $SG_DEVICE != "" ]]; then
echo $SG_DEVICE | awk '{print $1}'
exit 0;
fi
done
echo "'$DEVICE' not found" >&2
exit 1