1#!/bin/bash 2 3################################################ 4# 5# Spin up the given SCSI disk(s). 6# 7# SCSI disks (or disks that understand SCSI commands) 8# are assumed. By default, the immediate bit is set so the 9# command should return immediately. The disk however will 10# take 10 seconds or more to spin up. The '-w' option 11# causes each start to wait until the disk reports that it 12# has started. 13# 14# This script assumes the sg3_utils package is installed. 15# 16############################################### 17 18verbose="" 19immediate="-i" 20 21usage() 22{ 23 echo "Usage: scsi_start [-h] [-v] [-w] <device>+" 24 echo " where:" 25 echo " -h, --help print usage message" 26 echo " -v, --verbose more verbose output" 27 echo " -w, --wait wait for each start to complete" 28 echo "" 29 echo "Send SCSI START STOP UNIT command to start each <device>" 30} 31 32opt="$1" 33while test ! -z "$opt" -a -z "${opt##-*}"; do 34 opt=${opt#-} 35 case "$opt" in 36 h|-help) usage ; exit 0 ;; 37 v|-verbose) verbose="-v" ;; 38 w|-wait) immediate="" ;; 39 *) echo "Unknown option: -$opt " ; exit 1 ;; 40 esac 41 shift 42 opt="$1" 43done 44 45if [ $# -lt 1 ] 46 then 47 usage 48 exit 1 49fi 50 51for i 52do 53 echo "sg_start $immediate 1 $verbose $i" 54 sg_start $immediate 1 $verbose $i 55done 56