New init script for open-iscsi

git-svn-id: svn+ssh://svnintern.kmrc.de/projects/gentoo/iwm-overlay@6588 cbe59ace-07ea-0310-918e-868702b5370d
This commit is contained in:
Torsten Kurbad 2008-05-28 09:24:38 +00:00
parent dd99e09e5a
commit 6d06013173

View File

@ -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() {