Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 200355

Summary: sys-block/open-iscsi userfriendly init.d
Product: Gentoo Linux Reporter: Stefan de Konink <stefan>
Component: Current packagesAssignee: Mike Doty (RETIRED) <kingtaco>
Status: RESOLVED FIXED    
Severity: enhancement CC: robbat2
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Unified diff...

Description Stefan de Konink 2007-11-26 01:53:24 UTC
Currently if no InitiatorName is set the init.d stops.

checkconfig() {
        if [ ! -f $CONFIG_FILE ]; then
                eerror "Config file $CONFIG_FILE does not exist!"
                return 1
        fi
        if [ ! -f $INITIATORNAME -o -z "$(egrep '^InitiatorName=' "${INITIATORNAME}")" ]; then
                eerror "$INITIATORNAME should contain a string with your initiatior name, eg:"
                eerror "InitiatorName=iqn.2005-09.tld.domainname.hostname:initiator-name"
                eerror "Initiator name file does not exist!"
                return 1
        fi
}


Wouldn't it be nicer to do such thing:

checkconfig() {
        if [ ! -f $CONFIG_FILE ]; then
                eerror "Config file $CONFIG_FILE does not exist!"
                return 1
        fi
        if [ ! -f $INITIATORNAME -o -z "$(egrep '^InitiatorName=' "${INITIATORNAME}")" ]; then
                mkdir -p /etc/iscsi/ifaces /etc/iscsi/nodes /etc/iscsi/send_targets
                eerror "InitiatorName was not set, creating one:"
                IQN=`date +%Y-%m`.local.`ip addr show dev eth0 | egrep '^ *inet ' | sed 's/ *inet \(.*\)\/.*/\1/g'`
                UNIQUE=`echo $IQN | md5sum | sed "s/\(.*\) -/\1/g"`
                INITNAME="iqn.$IQN:openiscsi-$UNIQUE"
                echo "InitiatorName=$INITNAME" >> $INITIATORNAME
                eerror "$INITNAME"
        fi
}


My implementation leaves the tiny bug as was in the original version, if the file does not exists you cannot egrep it, and leaves an error. Anyway the idea is to create a InitiatorName based in the ip address of the machine, or maybe ever better a hostname. In my scenario I cannot trust on the hostname, so I choose this solution.

Reproducible: Always

Steps to Reproduce:
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2007-11-26 06:51:46 UTC
Please, attach a unified diff. Don't paste stuff inline, it kills formatting completely.
Comment 2 Stefan de Konink 2007-11-26 08:14:29 UTC
Created attachment 137028 [details, diff]
Unified diff...
Comment 3 Robin Johnson archtester Gentoo Infrastructure gentoo-dev Security 2008-01-14 01:29:37 UTC
kingtaco: yours now.
Comment 4 Stefan Behte (RETIRED) gentoo-dev Security 2008-03-09 22:47:47 UTC
Fixed here: http://bugs.gentoo.org/show_bug.cgi?id=196096
Please close the bug.
Comment 5 Stefan de Konink 2008-03-14 15:23:37 UTC
Thanks for using Craig!