packages: open-iscsi/open-iscsi.init, open-iscsi/open-iscsi.spec, open-iscs...
arekm
arekm at pld-linux.org
Fri Dec 3 10:16:09 CET 2010
Author: arekm Date: Fri Dec 3 09:16:09 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- rel 3; split iscsi.init into iscsi and iscsi-devices; S: multipath-tools
---- Files affected:
packages/open-iscsi:
open-iscsi.init (1.10 -> 1.11) , open-iscsi.spec (1.23 -> 1.24) , open-iscsi-devices.init (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/open-iscsi/open-iscsi.init
diff -u packages/open-iscsi/open-iscsi.init:1.10 packages/open-iscsi/open-iscsi.init:1.11
--- packages/open-iscsi/open-iscsi.init:1.10 Wed Dec 1 08:54:35 2010
+++ packages/open-iscsi/open-iscsi.init Fri Dec 3 10:16:03 2010
@@ -5,7 +5,6 @@
# chkconfig: 2345 7 89
# description: Start iSCSI to allow access to remote SCSI devices
#
-
# Source function library.
. /etc/rc.d/init.d/functions
@@ -27,17 +26,53 @@
exit 0
fi
+# FIXME this has a false positive for root on nfs
+root_is_iscsi() {
+ rootopts=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $4; }}' /etc/mtab)
+ echo $rootopts | grep -q _netdev && return 0 || return 1
+}
+
+force_start() {
+ msg_starting "iSCSI Initiator"
+ modprobe -s iscsi_tcp
+ modprobe -s ib_iser
+ modprobe -s cxgb3i
+ modprobe -s bnx2i
+ modprobe -s be2iscsi
+ daemon /sbin/iscsid -u iscsi -g iscsi
+ RETVAL=$?
+ if [ $RETVAL -eq 0 ]; then
+ touch /var/lock/subsys/iscsid
+ fi
+ return $RETVAL
+}
+
+use_discoveryd() {
+ grep -qrs "discovery.sendtargets.use_discoveryd = Yes" /etc/iscsi/send_targets
+ if [ $? -eq 0 ] ; then
+ return 0
+ fi
+
+ grep -qrs "discovery.isns.use_discoveryd = Yes" /etc/iscsi/isns
+ if [ $? -eq 0 ] ; then
+ return 0
+ fi
+
+ return 1
+}
+
start() {
# Start daemons.
if [ ! -f /var/lock/subsys/iscsid ]; then
- msg_starting "iSCSI Initiator"
- modprobe -s scsi_transport_iscsi
- modprobe -s iscsi_tcp
- daemon /sbin/iscsid -u iscsi -g iscsi
- RETVAL=$?
- if [ $RETVAL -eq 0 ]; then
- touch /var/lock/subsys/iscsid
- run_cmd "Logging into iSCSI targets" iscsiadm -m node -L automatic
+
+ # only start if nodes are setup to startup automatically, root is iscsi,
+ # or if iscsid is managing the sessions.
+ grep -qrs "node.startup = automatic" /etc/iscsi/nodes
+ if [ $? -eq 0 ] || root_is_iscsi || use_discoveryd ; then
+ force_start
+ RETVAL=$?
+ else
+ RETVAL=0
fi
else
msg_already_running "iSCSI Initiator"
@@ -47,9 +82,30 @@
stop() {
# Stop daemons.
if [ -f /var/lock/subsys/iscsid ]; then
- run_cmd "Logging out from iSCSI targets" iscsiadm -m node -U all
+ if use_discoveryd ; then
+ iscsiadm -k 0 2>/dev/null
+ fi
+
msg_stopping "iSCSI Initiator"
- killproc iscsid
+ if [ -n "$(iscsiadm -m session 2>/dev/null | egrep "tcp|iser|bnx2i|cxgb3i|be2iscsi")" ]; then
+ deltext; fail
+ nls "Not stopping iSCSI Initiator: iscsi sessions still active"
+ return 0
+ fi
+
+ iscsiadm -k 0 2>/dev/null
+
+ # only remove the iscsi drivers when offload is used
+ rmmod bnx2i 2>/dev/null
+ rmmod cnic 2>/dev/null
+
+ rmmod cxgb3i 2>/dev/null
+
+ modprobe -r be2iscsi 2>/dev/null
+
+ modprobe -r ib_iser 2>/dev/null
+ modprobe -r iscsi_tcp 2>/dev/null
+
rm -f /var/lock/subsys/iscsid >/dev/null 2>&1
else
msg_not_running "iSCSI Initiator"
================================================================
Index: packages/open-iscsi/open-iscsi.spec
diff -u packages/open-iscsi/open-iscsi.spec:1.23 packages/open-iscsi/open-iscsi.spec:1.24
--- packages/open-iscsi/open-iscsi.spec:1.23 Sat Nov 27 19:51:00 2010
+++ packages/open-iscsi/open-iscsi.spec Fri Dec 3 10:16:03 2010
@@ -3,7 +3,7 @@
# - /sbin/iscsistart is linked static, should it be linked uclibc/klibc-static for initrd?
#
%define subver 872
-%define rel 2
+%define rel 3
Summary: iSCSI - SCSI over IP
Summary(pl.UTF-8): iSCSI - SCSI po IP
Name: open-iscsi
@@ -15,6 +15,7 @@
# Source0-md5: b4df94f08c241352bb964043b3e44779
Source1: %{name}.init
Source2: %{name}.sysconfig
+Source3: %{name}-devices.init
Patch0: %{name}-build.patch
URL: http://www.open-iscsi.org/
BuildRequires: db-devel
@@ -24,6 +25,7 @@
BuildRequires: rpmbuild(macros) >= 1.379
Requires(post,preun): /sbin/chkconfig
Requires: rc-scripts
+Suggests: multipath-tools
Provides: group(iscsi)
Provides: user(iscsi)
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -70,6 +72,7 @@
install %{SOURCE1} $RPM_BUILD_ROOT/etc/rc.d/init.d/iscsi
install %{SOURCE2} $RPM_BUILD_ROOT/etc/sysconfig/iscsi
+install %{SOURCE3} $RPM_BUILD_ROOT/etc/rc.d/init.d/iscsi-devices
install etc/iscsid.conf $RPM_BUILD_ROOT%{_sysconfdir}/iscsi
:> $RPM_BUILD_ROOT%{_sysconfdir}/iscsi/initiatorname.iscsi
@@ -91,10 +94,13 @@
echo "InitiatorName=$(iscsi-iname)" >> %{_sysconfdir}/iscsi/initiatorname.iscsi
fi
/sbin/chkconfig --add iscsi
+/sbin/chkconfig --add iscsi-devices
%preun
if [ "$1" = "0" ]; then
+ %service iscsi-devices stop
%service iscsi stop
+ /sbin/chkconfig --del iscsi-devices
/sbin/chkconfig --del iscsi
fi
@@ -128,6 +134,9 @@
All persons listed below can be reached at <cvs_login>@pld-linux.org
$Log$
+Revision 1.24 2010/12/03 09:16:03 arekm
+- rel 3; split iscsi.init into iscsi and iscsi-devices; S: multipath-tools
+
Revision 1.23 2010/11/27 18:51:00 arekm
- rel 2
================================================================
Index: packages/open-iscsi/open-iscsi-devices.init
diff -u /dev/null packages/open-iscsi/open-iscsi-devices.init:1.1
--- /dev/null Fri Dec 3 10:16:09 2010
+++ packages/open-iscsi/open-iscsi-devices.init Fri Dec 3 10:16:03 2010
@@ -0,0 +1,109 @@
+#!/bin/bash
+#
+# iscsi-devices This shell script takes care of starting and stopping iscsi.
+#
+# chkconfig: 2345 13 89
+# description: Start iSCSI devices
+#
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# Source networking configuration.
+. /etc/sysconfig/network
+
+# Source oident configureation.
+if [ -f /etc/sysconfig/iscsi ]; then
+ . /etc/sysconfig/iscsi
+fi
+
+# Check that networking is up.
+if is_yes "${NETWORKING}"; then
+ if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then
+ msg_network_down "iSCSI devices"
+ exit 1
+ fi
+else
+ exit 0
+fi
+
+start() {
+ # Start daemons.
+ if [ ! -f /var/lock/subsys/iscsi-devices ]; then
+ # if no nodes are setup to startup automatically exit cleanly
+ grep -qrs "node.startup = automatic" /etc/iscsi/nodes
+ [ $? -eq 0 ] || exit 0
+
+ msg_starting "iSCSI devices"; busy
+ iscsiadm -m node --loginall=automatic 2>&1 > /dev/null | grep iscsiadm
+
+ # <sigh> iscsiadm does not always give a non 0 exit status in case of
+ # error so we grep for any messages to stderr and see those as errors too
+ if [ ${PIPESTATUS[0]} -ne 0 -o ${PIPESTATUS[1]} -eq 0 ]; then
+ deltext; fail
+ return 1
+ fi
+
+ deltext; ok
+ touch /var/lock/subsys/iscsi-devices
+ else
+ msg_already_running "iSCSI devices"
+ fi
+}
+
+stop() {
+ # Stop daemons.
+ if [ -f /var/lock/subsys/iscsi-devices ]; then
+ msg_stopping "iSCSI devices"; busy
+ iscsiadm -m node --logoutall=automatic 2>&1 > /dev/null | grep iscsiadm
+ # <sigh> iscsiadm does not always give a non 0 exit status in case of
+ # error so we grep for any messages to stderr and see those as errors too
+ if [ ${PIPESTATUS[0]} -ne 0 -o ${PIPESTATUS[1]} -eq 0 ]; then
+ deltext; fail
+ return 1
+ fi
+
+ deltext; ok
+
+ rm -f /var/lock/subsys/iscsi-devices >/dev/null 2>&1
+ else
+ msg_not_running "iSCSI devices"
+ fi
+}
+
+condrestart() {
+ if [ -f /var/lock/subsys/iscsi-devices ]; then
+ stop
+ start
+ else
+ msg_not_running "iSCSI devices"
+ RETVAL=$1
+ fi
+}
+
+RETVAL=0
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart)
+ stop
+ start
+ ;;
+ try-restart)
+ condrestart 0
+ ;;
+ force-reload)
+ condrestart 7
+ ;;
+ status)
+ # FIXME
+ exit $?
+ ;;
+ *)
+ msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+ exit 3
+esac
+exit $RETVAL
================================================================
---- CVS-web:
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/open-iscsi/open-iscsi.init?r1=1.10&r2=1.11&f=u
http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/open-iscsi/open-iscsi.spec?r1=1.23&r2=1.24&f=u
More information about the pld-cvs-commit
mailing list