[Pkg-iscsi-maintainers] open-iscsi init script

Harmel Patrick Patrick.Harmel at afpa.FR
Thu Nov 25 14:33:14 UTC 2010


I'm trying to use iscsi on a debian/squeeze.
I have configured an iscsi target on a machine, an an iscsi initiator on another one.
Every things is working great.

But when I reboot the initiator, the iscsi attachement is not restored, even with every thing configured in "automatic" mode.

Working on it, i find out what the problem was.
Even if networking is S13 in rcS, and open-iscsi is S18 (in rcS too), the network is not configured as iscsi tries to connect to targets.

As a workaround, I had re-write the "starttargets" function in the open-iscsi init script.

Here it is, if it can help.

Thanks for all your work.

starttargets() {
        log_daemon_msg "Setting up iSCSI targets"
        while [ "$NETPB" = "yes" ] && [ "$RETRY" != "3" ]
        do NETPB="no"
# building the configured iscsi targets list
           $ADM --mode node>/tmp/iscsi-list.txt
           while read DASHREPLY
# is it already connected ?
           do if ! [ -e /dev/disk/by-path/ip-${DASHREPLY%%,*}-iscsi-${DASHREPLY#* }* ]
# should it be connected at boot time ?
              then if [ "$(grep "^node\.startup" "/etc/iscsi/nodes/${DASHREPLY#* }/`echo ${DASHREPLY% *}|sed 's/:/,/'`/default"|sed 's/.*= *//')" = automatic ]
# is it reachable; ie is the network properly configured ?
                   then if ip route get to ${DASHREPLY%%:*}>/dev/null 2>/dev/null
# then go now
                        then $ADM --mode node --login $DASHREPLY
# not reachable
                        else NETPB="yes"
           if [ "$NETPB" = "yes" ]
           then sleep 3
                RETRY=$(( RETRY + 1 ))
#       $ADM -m node --loginall=automatic
        log_end_msg 0

Patrick HARMEL
Formateur TSRIT
73, rue Saint-Jean
31130 BALMA

More information about the Pkg-iscsi-maintainers mailing list