23
23
# Source LSB init functions
26
. /etc/sysconfig/open-iscsi
28
26
# Reset status of this service
33
$ISCSIADM -m discovery --type=$ISCSI_DISCOVERY --portal=$ISCSI_PORTAL > /dev/null
36
29
iscsi_login_all_nodes()
38
TARGETS=$($ISCSIADM -m node | sed 's@\[\(.*\)\] .*@\1@g')
39
for rec in $TARGETS; do
40
STARTUP=`$ISCSIADM -m node -r $rec | grep "node.conn\[0\].startup" | cut -d' ' -f3`
41
NODE=`$ISCSIADM -m node -r $rec | grep "node.name" | cut -d' ' -f3`
42
if [ $STARTUP = "automatic" ] ; then
43
echo -n "Logging into $NODE: "
44
$ISCSIADM -m node -r $rec -l
31
echo -n "Setting up iSCSI targets: "
32
$ISCSIADM -m node --loginall=automatic
50
36
iscsi_logout_all_nodes()
52
TARGETS=$($ISCSIADM -m session | sed 's@\[[^:]*:\(.*\)\] .*@\1@g')
53
for rec in $TARGETS; do
54
NODE=`$ISCSIADM -m node -r $rec | grep "node.name" | cut -d' ' -f3`
55
echo -n "Logging out from $NODE: "
56
if $ISCSIADM -m node --record $rec --logout ; then
38
# Logout from all active sessions
39
if $ISCSIADM -m node --logoutall=all ; then
46
# Not sure whether this is still needed
66
51
iscsi_list_all_nodes()
68
TARGETS=$($ISCSIADM -m session | sed 's@\[[^:]*:\(.*\)\] .*@\1@g')
69
if [ "$TARGETS" != "no active sessions" ] ; then
70
echo "Active connections:"
71
for rec in $TARGETS; do
72
NODE=$($ISCSIADM -m node -r $rec | grep "node.name" | cut -d' ' -f3)
53
# Check for active sessions
54
if $ISCSIADM -m session > /dev/null; then
57
echo "Active connections:"
58
$ISCSIADM -m session | while read proto num PORTAL TARGET ; do
60
echo -e "\t$TARGET at $PORTAL"
80
66
[ ! -d /var/lib/iscsi ] && mkdir -p /var/lib/iscsi
81
echo -n "Starting iSCSI initiator service: "
82
modprobe scsi_transport_iscsi
84
startproc $DAEMON $ARGS
67
if checkproc $DAEMON ; then
70
echo -n "Starting iSCSI initiator service: "
73
startproc $DAEMON $ARGS
87
77
if [ "$RETVAL" == "0" ]; then
88
78
iscsi_login_all_nodes
92
82
if iscsi_logout_all_nodes ; then
94
83
killproc -KILL $DAEMON