#!/bin/tcsh
#
#	ini-lun-up
#
#	vi: set autoindent tabstop=4 shiftwidth=4 :
#
#	in existing session in initiator
#	bring up additional lun (default is 1 if no number given as parameter)
#	on target at given ip address or DNS name
#
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 bring up the lun on
set cid = 0
#
#	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 up ip=$ip host=$hostno lun=$lun cid=$cid target=$localtargetno
	break
end
