summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Shvetsov <alexxy@gentoo.org>2009-11-25 16:33:12 +0000
committerAlexey Shvetsov <alexxy@gentoo.org>2009-11-25 16:33:12 +0000
commit4b6e3ccc5b359ff68e3bfb332d6a6597417d71cf (patch)
treede4ad4e538f6d5c09f0df7b814ebc4ceffe0d5a2 /sys-block/tgt
parentAutomated update of use.local.desc (diff)
downloadgentoo-2-4b6e3ccc5b359ff68e3bfb332d6a6597417d71cf.tar.gz
gentoo-2-4b6e3ccc5b359ff68e3bfb332d6a6597417d71cf.tar.bz2
gentoo-2-4b6e3ccc5b359ff68e3bfb332d6a6597417d71cf.zip
[sys-block/tgt] Initial import per bug #228729
(Portage version: 2.2_rc51/cvs/Linux x86_64)
Diffstat (limited to 'sys-block/tgt')
-rw-r--r--sys-block/tgt/ChangeLog10
-rw-r--r--sys-block/tgt/files/tgtd127
-rw-r--r--sys-block/tgt/metadata.xml15
-rw-r--r--sys-block/tgt/tgt-0.9.10.ebuild42
4 files changed, 194 insertions, 0 deletions
diff --git a/sys-block/tgt/ChangeLog b/sys-block/tgt/ChangeLog
new file mode 100644
index 000000000000..22cb14d04124
--- /dev/null
+++ b/sys-block/tgt/ChangeLog
@@ -0,0 +1,10 @@
+# ChangeLog for sys-block/tgt
+# Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2
+# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/ChangeLog,v 1.1 2009/11/25 16:33:11 alexxy Exp $
+
+*tgt-0.9.10 (25 Nov 2009)
+
+ 25 Nov 2009; Alexey Shvetsov <alexxy@gentoo.org> +tgt-0.9.10.ebuild,
+ +files/tgtd, +metadata.xml:
+ Initial import per bug
+
diff --git a/sys-block/tgt/files/tgtd b/sys-block/tgt/files/tgtd
new file mode 100644
index 000000000000..cbf209ed54f4
--- /dev/null
+++ b/sys-block/tgt/files/tgtd
@@ -0,0 +1,127 @@
+#!/sbin/runscript
+# Copyright 1999-2008 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/files/tgtd,v 1.1 2009/11/25 16:33:12 alexxy Exp $
+
+TGTD_CONFIG=/etc/tgt/targets.conf
+
+TASK=$1
+
+depend() {
+ need net
+}
+
+start()
+{
+ ebegin "Starting target framework daemon"
+ ebegin "Starting ${SVCNAME}"
+ # Start tgtd first.
+ start-stop-daemon --start --quiet \
+ --name tgtd \
+ --exec /usr/sbin/tgtd
+ RETVAL=$?
+ if [ "$RETVAL" -ne 0 ] ; then
+ echo "Could not start tgtd (is tgtd already running?)"
+ exit 1
+ fi
+ # We need to wait for 1 second before do anything with tgtd
+ sleep 1
+ # Put tgtd into "offline" state until all the targets are configured.
+ # We don't want initiators to (re)connect and fail the connection
+ # if it's not ready
+ tgtadm --op update --mode sys --name State -v offline
+ # Configure the targets.
+ tgt-admin --update ALL -c $TGTD_CONFIG
+ # Put tgtd into "ready" state.
+ tgtadm --op update --mode sys --name State -v ready
+ eend $?
+}
+
+stop()
+{
+ ebegin "Stopping ${SVCNAME}"
+ ebegin "Stopping target framework daemon"
+ # start-stop-daemon --stop --exec /usr/sbin/tgtd --quiet
+ if [ "$RUNLEVEL" == 0 -o "$RUNLEVEL" == 6 ] ; then
+ forcedstop
+ fi
+ # Remove all targets. It only removes targets which are not in use.
+ tgt-admin --update ALL -c /dev/null &>/dev/null
+ # tgtd will exit if all targets were removed
+ tgtadm --op delete --mode system &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ [ "$TASK" != "restart" ] && exit 1
+ elif [ "$RETVAL" -ne 0 ] ; then
+ echo "Some initiators are still connected - could not stop tgtd"
+ exit 2
+ fi
+ # echo -n
+ eend $?
+}
+
+forcedstop()
+{
+ # NOTE: Forced shutdown of the iscsi target may cause data corruption
+ # for initiators that are connected.
+ echo "Force-stopping target framework daemon"
+ # Offline everything first. May be needed if we're rebooting, but
+ # expect the initiators to reconnect cleanly when we boot again
+ # (i.e. we don't want them to reconnect to a tgtd which is still
+ # working, but the target is gone).
+ tgtadm --op update --mode sys --name State -v offline &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ [ "$TASK" != "restart" ] && exit 1
+ else
+ tgt-admin --offline ALL
+ # Remove all targets, even if they are still in use.
+ tgt-admin --update ALL -c /dev/null -f
+ # It will shut down tgtd only after all targets were removed.
+ tgtadm --op delete --mode system
+ RETVAL=$?
+ if [ "$RETVAL" -ne 0 ] ; then
+ echo "Failed to shutdown tgtd"
+ exit 1
+ fi
+ fi
+ echo -n
+}
+
+reload()
+{
+ echo "Updating target framework daemon configuration"
+ # Update configuration for targets. Only targets which
+ # are not in use will be updated.
+ tgt-admin --update ALL -c $TGTD_CONFIG &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ exit 1
+ fi
+}
+
+forcedreload()
+{
+ echo "Force-updating target framework daemon configuration"
+ # Update configuration for targets, even those in use.
+ tgt-admin --update ALL -f -c $TGTD_CONFIG &>/dev/null
+ RETVAL=$?
+ if [ "$RETVAL" -eq 107 ] ; then
+ echo "tgtd is not running"
+ exit 1
+ fi
+}
+
+status()
+{
+ # Don't name this script "tgtd"...
+ TGTD_PROC=$(ps -C tgtd | grep -c tgtd)
+ if [ "$TGTD_PROC" -eq 2 ] ; then
+ echo "tgtd is running. Run 'tgt-admin -s' to see detailed target info."
+ else
+ echo "tgtd is NOT running."
+ fi
+}
diff --git a/sys-block/tgt/metadata.xml b/sys-block/tgt/metadata.xml
new file mode 100644
index 000000000000..c7f81ebfd167
--- /dev/null
+++ b/sys-block/tgt/metadata.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd">
+<pkgmetadata>
+<herd>cluster</herd>
+<longdescription>
+iSCSI Target daemon with rdma support
+</longdescription>
+<use>
+ <flag name='ibmvio'>Add support for IBM Virtual I/O</flag>
+ <flag name='infiniband'>Add support for iSCSI over RDMA (iser). All needed
+ libs can be found in science overlay</flag>
+ <flag name='fcp'>Add support for new FC protocol</flag>
+ <flag name='fcoe'>Add support for FCoE protocol</flag>
+</use>
+</pkgmetadata>
diff --git a/sys-block/tgt/tgt-0.9.10.ebuild b/sys-block/tgt/tgt-0.9.10.ebuild
new file mode 100644
index 000000000000..89c73a8a19f9
--- /dev/null
+++ b/sys-block/tgt/tgt-0.9.10.ebuild
@@ -0,0 +1,42 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/sys-block/tgt/tgt-0.9.10.ebuild,v 1.1 2009/11/25 16:33:11 alexxy Exp $
+
+EAPI="2"
+
+inherit flag-o-matic linux-info
+
+DESCRIPTION="Linux SCSI target framework (tgt)"
+HOMEPAGE="http://stgt.berlios.de/"
+SRC_URI="http://stgt.berlios.de/releases/${P}.tar.bz2"
+
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="ibmvio infiniband fcp fcoe"
+
+DEPEND="dev-perl/config-general
+ infiniband? (
+ sys-infiniband/libibverbs
+ sys-infiniband/librdmacm
+ )"
+RDEPEND="${DEPEND}
+ sys-apps/sg3_utils"
+
+src_configure() {
+ local myconf
+ use ibmvio && myconf="${myconf} IBMVIO=1"
+ use infiniband && myconf="${myconf} ISCSI_RDMA=1"
+ use fcp && myconf="${myconf} FCP=1"
+ use fcoe && myconf="${myconf} FCOE=1"
+}
+
+src_compile() {
+ emake -C usr/ KERNELSRC="${KERNEL_DIR}" ISCSI=1 ${myconf}
+}
+
+src_install() {
+ emake -C usr/ install DESTDIR="${D}" || die "install failed"
+ doinitd "${FILESDIR}/tgtd"
+ dodoc doc/README.* doc/targets.conf.example doc/tmf.txt
+}