ALT Linux repositórios
Group :: Sistema/Kernel e hardware
RPM: open-iscsi
Main Changelog Spec Patches Sources Download Gear Bugs e FR Repocop
Patch: open-iscsi-2.0.871-alt6.1.patch
Download
Download
Makefile | 9 ++-
etc/initd/initd.alt | 183 +++++++++++++++++++++++++++++++++++++++++++++++++
utils/iscsi_discovery | 10 ++-
3 files changed, 195 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 9b22b7c..21ffe6e 100644
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,8 @@ install_programs: $(PROGRAMS)
install_initd:
if [ -f /etc/debian_version ]; then \
$(MAKE) install_initd_debian ; \
+ elif [ -f /etc/altlinux-release ]; then \
+ $(MAKE) install_initd_alt ; \
elif [ -f /etc/redhat-release ]; then \
$(MAKE) install_initd_redhat ; \
elif [ -f /etc/SuSE-release ]; then \
@@ -94,6 +96,11 @@ install_initd_suse:
$(INSTALL) -m 755 etc/initd/boot.suse \
$(DESTDIR)$(initddir)/boot.open-iscsi
+install_initd_alt:
+ $(INSTALL) -d $(DESTDIR)$(initddir)
+ $(INSTALL) -m 755 etc/initd/initd.alt \
+ $(DESTDIR)$(initddir)/open-iscsi
+
install_initd_redhat:
$(INSTALL) -d $(DESTDIR)$(initddir)
$(INSTALL) -m 755 etc/initd/initd.redhat \
@@ -109,7 +116,7 @@ install_iface: $(IFACEFILES)
$(INSTALL) -m 644 $^ $(DESTDIR)$(etcdir)/iscsi/ifaces
install_etc: $(ETCFILES)
- if [ ! -f /etc/iscsi/iscsid.conf ]; then \
+ if [ ! -f $(DESTDIR)$(etcdir)/iscsi/iscsid.conf ]; then \
$(INSTALL) -d $(DESTDIR)$(etcdir)/iscsi ; \
$(INSTALL) -m 644 $^ $(DESTDIR)$(etcdir)/iscsi ; \
fi
diff --git a/etc/initd/initd.alt b/etc/initd/initd.alt
new file mode 100755
index 0000000..ed7707c
--- /dev/null
+++ b/etc/initd/initd.alt
@@ -0,0 +1,183 @@
+#!/bin/sh
+#
+# chkconfig: - 13 87
+# description: Starts and stops the iSCSI initiator
+#
+# pidfile: /var/run/iscsid.pid
+# config: /etc/iscsid.conf
+# processname: iscsid
+
+### BEGIN INIT INFO
+# Provides: open-iscsi
+# Required-Start: $network $local_fs
+# Required-Stop: $network
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: iSCSI initiator
+# Description: Starts and stops the iSCSI initiator
+### END INIT INFO
+
+# Do not load RH compatibility interface.
+WITHOUT_RC_COMPAT=1
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+ISCSID=iscsid
+ISCSIADM=iscsiadm
+
+PIDFILE=/var/run/iscsid.pid
+LOCKFILE=/var/lock/subsys/open-iscsi
+RETVAL=0
+
+attach_nodes()
+{
+ echo -n "Attaching nodes: "
+ $ISCSIADM -m node --loginall=automatic 2> /dev/null
+ RETVAL=$?
+ if [ $RETVAL == "0" ]; then
+ echo_success
+ elif [ $RETVAL -eq "19" ]; then
+ echo -n "No records found!"
+ echo_passed
+ RETVAL=0
+ else
+ echo_failure
+ fi
+ echo
+ sleep 5
+ action 'Mounting netdev filesystems:' mount -a -O _netdev
+ return 0
+}
+
+detach_nodes()
+{
+ echo -n "Detaching nodes: "
+ sync
+ $ISCSIADM -m node --logoutall=all
+ RETVAL=$?
+ if [ $RETVAL == "0" ]; then
+ echo_success
+ else
+ echo_failure
+ fi
+ echo
+ return 0
+}
+
+umount_all_luns()
+{
+ local d m dev p s
+
+ cat /proc/mounts | sed -ne '/^\/dev\/.*/p' | while read d m t o x; do
+ if [ "$m" = "/" ] ; then
+ continue;
+ fi
+ if [ -L "$d" ] ; then
+ d=$(readlink -f $d)
+ fi
+ dev=${d##/dev}
+
+ if [ "${dev##/sd}" = "$dev" ] ; then
+ continue;
+ fi
+ p="/sys/block${dev%%[0-9]*}"
+
+ if [ ! -d ${p} ] && [ ! -d ${p}/device ] ; then
+ continue;
+ fi
+
+ s=$(cd -P ${p}/device && echo $PWD)
+
+ case "$s" in
+ */session[0-9]*/*)
+ # This is an iSCSI device
+ echo -n "Unmount $m: "
+ umount "$m"
+ RETVAL=$?
+ if [ $RETVAL == "0" ]; then
+ echo_success
+ else
+ echo_failure
+ fi
+ echo
+ #return 0
+ ;;
+ esac
+ done
+}
+
+start()
+{
+ modprobe -q iscsi_tcp
+ modprobe -q ib_iser
+ start_daemon --displayname "iSCSI initiator" --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $ISCSID
+ RETVAL=$?
+ if [ $RETVAL == "0" ]; then
+ attach_nodes
+ fi
+ return $RETVAL
+}
+
+stop()
+{
+ t=$($ISCSIADM -m session 2> /dev/null)
+ if [ "$t" ]; then
+ umount_all_luns
+ detach_nodes
+ fi
+ stop_daemon --displayname "iSCSI initiator" --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- $ISCSID
+ RETVAL=$?
+ modprobe -r iscsi_tcp 2>/dev/null
+ modprobe -r ib_iser 2>/dev/null
+ return $RETVAL
+}
+
+restart()
+{
+ stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ reload)
+ restart
+ ;;
+ restart)
+ restart
+ ;;
+ condstop)
+ if [ -e "$LOCKFILE" ]; then
+ stop
+ fi
+ ;;
+ condrestart)
+ if [ -e "$LOCKFILE" ]; then
+ restart
+ fi
+ ;;
+ condreload)
+ if [ -e "$LOCKFILE" ]; then
+ restart
+ fi
+ ;;
+ status)
+ status `basename $ISCSID`
+ RETVAL=$?
+ if [ "$RETVAL" -eq "0" ]; then
+ echo "Active sessions:"
+ $ISCSIADM -m session
+ fi
+ ;;
+ *)
+ msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
+ RETVAL=1
+esac
+
+exit $RETVAL
diff --git a/utils/iscsi_discovery b/utils/iscsi_discovery
index 1bddc25..d07ecc2 100755
--- a/utils/iscsi_discovery
+++ b/utils/iscsi_discovery
@@ -104,24 +104,22 @@ discover()
connected=0
discovered=0
- df=/tmp/discovered.$$
dbg "starting discovery to $ip"
- iscsiadm -m discovery --type sendtargets --portal ${ip}:${port} > ${df}
- while read portal target
+ disc="$(iscsiadm -m discovery --type sendtargets --portal ${ip}:${port})"
+ echo "${disc}" | while read portal target
do
portal=${portal%,*}
select_transport
- done < ${df}
+ done
- discovered=$(cat ${df} | wc -l)
+ discovered=$(echo "${disc}" | wc -l)
if [ ${discovered} = 0 ]; then
echo "failed to discover targets at ${ip}"
exit 2
else
echo "discovered ${discovered} targets at ${ip}"
fi
- /bin/rm -f ${df}
}
try_login()