From 6d06013173ef7e5f9090e5ec00559beb34c234b6 Mon Sep 17 00:00:00 2001 From: Torsten Kurbad Date: Wed, 28 May 2008 09:24:38 +0000 Subject: [PATCH] New init script for open-iscsi git-svn-id: svn+ssh://svnintern.kmrc.de/projects/gentoo/iwm-overlay@6588 cbe59ace-07ea-0310-918e-868702b5370d --- sys-block/open-iscsi/files/iscsid-init.d | 50 ++++++++++++------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/sys-block/open-iscsi/files/iscsid-init.d b/sys-block/open-iscsi/files/iscsid-init.d index 98a88e2..fefb9c5 100644 --- a/sys-block/open-iscsi/files/iscsid-init.d +++ b/sys-block/open-iscsi/files/iscsid-init.d @@ -69,39 +69,41 @@ start() { sleep 5 - ebegin "Mounting all disks with entries in /etc/fstab" - PARTITIONS="" - ISCSI_SESSION="`iscsiadm -m session -i 2>/dev/null | grep '^Attached scsi disk ' | grep 'State: running$'`" + einfo "Mounting all disks with entries in /etc/fstab" + + NUM_PARTS=0 + ISCSI_SESSION="`iscsiadm -m session -P 3 2>/dev/null | grep 'Attached scsi disk ' | grep 'State: running$'`" if [ "x${?}" == "x0" ] ; then DISKS="`echo ${ISCSI_SESSION} | awk '{ print }' | sed -e 's@Attached scsi disk @@g' -e 's@State: running@@g'`" for DISK in ${DISKS} ; do - PARTITIONS="`find /dev -name \"${DISK}[0-9]*\" | grep -v '\.udev/'` ${PARTITIONS}" - - for PARTITION in ${PARTITIONS} ; do - - IN_FSTAB="" - - PART_LABEL_RAW="`${UDEVINFO} -q env -n ${PARTITION} 2>/dev/null | grep '^ID_FS_LABEL='`" - if [ "${PART_LABEL_RAW}x" != "x" ] ; then - PART_LABEL="`echo ${PART_LABEL_RAW} | awk -F '=' '{ print $2; }'`" - IN_FSTAB="`grep ${PART_LABEL} /etc/fstab`" - fi - - if [ "x${IN_FSTAB}" != "x" ] ; then - mount -s /dev/disk/by-label/${PART_LABEL} - fi - done + (( NUM_PARTS += 1 )) + PARTITIONS[NUM_PARTS]="`find /dev -name \"${DISK}[0-9]*\" | grep -v '\.udev/'` ${PARTITIONS}" done - ret=$? + fi - else - echo "No automatic nodes or attached disks found!" + for PARTITION in ${PARTITIONS[@]} ; do + IN_FSTAB="" + + PART_LABEL_RAW="`${UDEVINFO} -q env -n ${PARTITION} 2>/dev/null | grep '^ID_FS_LABEL='`" + if [ "${PART_LABEL_RAW}x" != "x" ] ; then + PART_LABEL="`echo ${PART_LABEL_RAW} | awk -F '=' '{ print $2; }'`" + IN_FSTAB="`grep ${PART_LABEL} /etc/fstab`" + fi + + if [ "x${IN_FSTAB}" != "x" ] ; then + ebegin "Mounting disk ${PART_LABEL}" + mount -s /dev/disk/by-label/${PART_LABEL} + eend $? + fi + done + + if [ "${#PATITIONS[*]}" == "0" ] ; then + einfo "No automatic nodes or attached disks found!" ret=0 fi - eend $ret - return $ret + return $? } stop() {