#!/bin/tcsh
#
#	ini-lun-down
#
#	vi: set autoindent tabstop=4 shiftwidth=4 :
#
#	bring down just one lun, not the connection or session
#	to do this, give a cid that will not match that
#	of any existing connection
#
set lun = 1
if ( $# > 0 ) set lun = $1
echo lun $lun
#
#	set the target's ip address or DNS name to connect to
set ip = 127.0.0.1
#
#	set the connection id to NOT match an existing connection
set cid = 255
#
#	set this to determine initiator's local target slot to use
set localtargetno = 0
#
#
if ( ! -e /proc/scsi/iscsi_initiator ) then
	echo "/proc/scsi/iscsi_initiator does not exist"
	echo "load the initiator module with ini-install"
	exit 1
endif
#
foreach hostno (/proc/scsi/iscsi_initiator/*)
	if ( ! -f $hostno ) continue
	set hostno = $hostno:t
	iscsi_config down ip=$ip host=$hostno lun=$lun cid=$cid target=$localtargetno
	break
end
