aboutsummaryrefslogtreecommitdiffstats
path: root/main/open-iscsi
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2014-07-08 06:29:45 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2014-07-08 06:53:20 +0000
commit991001c6f9ccf4f57efd4acff85e30801b1d785d (patch)
tree8bb0cece92da03878c53747d9822fc18f43fd1f9 /main/open-iscsi
parent7d7811aa6295c3373d5cddd0cdffaa55293855c2 (diff)
downloadaports-991001c6f9ccf4f57efd4acff85e30801b1d785d.tar.bz2
aports-991001c6f9ccf4f57efd4acff85e30801b1d785d.tar.xz
Revert "main/open-iscsi: removed"
we still need open-iscsi for the initiator This reverts commit 570661a829deb7f4de4b62e5379a424acb2ed9e2.
Diffstat (limited to 'main/open-iscsi')
-rw-r--r--main/open-iscsi/APKBUILD50
-rw-r--r--main/open-iscsi/iscsid.confd13
-rw-r--r--main/open-iscsi/iscsid.initd128
3 files changed, 191 insertions, 0 deletions
diff --git a/main/open-iscsi/APKBUILD b/main/open-iscsi/APKBUILD
new file mode 100644
index 0000000000..b37759e55f
--- /dev/null
+++ b/main/open-iscsi/APKBUILD
@@ -0,0 +1,50 @@
+# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
+pkgname=open-iscsi
+pkgver=2.0.873
+_realver=${pkgver%.*}-${pkgver##*.}
+pkgrel=1
+pkgdesc="High performance, transport independent, multi-platform iSCSI initiator"
+url="http://www.open-iscsi.org"
+arch="all"
+license="GPL-2"
+depends=
+makedepends="openssl-dev"
+install=""
+subpackages="$pkgname-doc"
+source="http://www.open-iscsi.org/bits/open-iscsi-$_realver.tar.gz
+ iscsid.initd
+ iscsid.confd"
+
+_builddir="$srcdir"/$pkgname-$_realver
+
+prepare() {
+ cd "$_builddir"
+}
+
+build() {
+ cd "$_builddir"
+ make user || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make DESTDIR="$pkgdir" install_user
+ mkdir -p $pkgdir/usr/bin
+ mkdir -p $pkgdir/usr/sbin
+ mv $pkgdir/sbin/iscsi-iname $pkgdir/usr/bin
+ mv $pkgdir/sbin/iscsi_discovery $pkgdir/usr/bin
+ mv $pkgdir/sbin/iscsiadm $pkgdir/usr/bin
+ mv $pkgdir/sbin/iscsid $pkgdir/usr/sbin
+ install -Dm755 "$srcdir"/iscsid.initd "$pkgdir"/etc/init.d/iscsid
+ install -Dm644 "$srcdir"/iscsid.confd "$pkgdir"/etc/conf.d/iscsid
+}
+
+md5sums="8b8316d7c9469149a6cc6234478347f7 open-iscsi-2.0-873.tar.gz
+1462e44ce6ec4ae44ec83d0ffcd3cdda iscsid.initd
+b762b687d4628791b4362df22cf22d34 iscsid.confd"
+sha256sums="7dd9f2f97da417560349a8da44ea4fcfe98bfd5ef284240a2cc4ff8e88ac7cd9 open-iscsi-2.0-873.tar.gz
+3bad25eba8254de845e41016df65855673c85a76ff96af713c7eab62c646bb7a iscsid.initd
+673bf4744efc3276d372587c996270821d39dcdc0bf27a13691ea6b0e814b6d0 iscsid.confd"
+sha512sums="4e67116cb7dd49381c9279645e5a661f05596ae6be3b832772089828b3764ca2d04b5dea1bcc337071efb52c3c75a6fb943136c659ee59500f3a198ed0dcea6b open-iscsi-2.0-873.tar.gz
+ac3894a62d27a975c7ec6dbc639e7442d6f1472e4fe0967f813cc78de4a36418fcb584888012f1927a83bb2c73c26f85031cb411d49ba5356772dfd23e426c3f iscsid.initd
+075bb9cb783be7ccbc799947e0e042b85310d40b3045141dc1be40ca84ed1cc0e1e54559df501c512c179e28375314b27a03c15d9a6d4b1cabd428b2279985d3 iscsid.confd"
diff --git a/main/open-iscsi/iscsid.confd b/main/open-iscsi/iscsid.confd
new file mode 100644
index 0000000000..1c4cc40542
--- /dev/null
+++ b/main/open-iscsi/iscsid.confd
@@ -0,0 +1,13 @@
+# /etc/conf.d/iscsid
+
+# config file to use
+CONFIG_FILE=/etc/iscsi/iscsid.conf
+
+# you need to specify an initiatorname in the file
+INITIATORNAME_FILE=/etc/iscsi/initiatorname.iscsi
+
+# options to pass to iscsid
+OPTS="-i ${INITIATORNAME_FILE}"
+
+# Start automatic targets when iscsid is started
+AUTOSTARTTARGETS="yes"
diff --git a/main/open-iscsi/iscsid.initd b/main/open-iscsi/iscsid.initd
new file mode 100644
index 0000000000..f7d0a26289
--- /dev/null
+++ b/main/open-iscsi/iscsid.initd
@@ -0,0 +1,128 @@
+#!/sbin/runscript
+
+extra_started_commands="starttargets stoptargets restarttargets"
+
+depend() {
+ after modules
+ use net
+}
+
+checkconfig() {
+ if [ ! -e /etc/conf.d/${SVCNAME} ]; then
+ eerror "Config file /etc/conf.d/${SVCNAME} does not exist!"
+ return 1
+ fi
+ if [ ! -e "${CONFIG_FILE}" ]; then
+ eerror "Config file ${CONFIG_FILE} does not exist!"
+ return 1
+ fi
+ if [ ! -e ${INITIATORNAME_FILE} ] || [ ! "$(grep "^InitiatorName=iqn\." ${INITIATORNAME_FILE})" ]; then
+ ewarn "${INITIATORNAME_FILE} should contain a string with your initiatior name."
+ IQN=iqn.$(date +%Y-%m).$(hostname -f | awk 'BEGIN { FS=".";}{x=NF; while (x>0) {printf $x ;x--; if (x>0) printf ".";} print ""}'):openiscsi
+ IQN=${IQN}-$(echo ${RANDOM}${RANDOM}${RANDOM}${RANDOM}${RANDOM} | md5sum | sed -e "s/\(.*\) -/\1/g" -e 's/ //g')
+ ebegin "Creating InitiatorName ${IQN} in ${INITIATORNAME_FILE}"
+ echo "InitiatorName=${IQN}" >> "${INITIATORNAME_FILE}"
+ eend $?
+ fi
+}
+
+do_modules() {
+ msg="$1"
+ shift
+ modules="${1}"
+ shift
+ modopts="$@"
+ for m in ${modules}
+ do
+ if [ -n "$(find /lib/modules/`uname -r` | grep ${m})" ]
+ then
+ ebegin "${msg} ${m}"
+ modprobe ${modopts} ${m}
+ ret=$?
+ eend ${ret}
+ if [ ${ret} -ne 0 ]; then
+ return ${ret}
+ fi
+ else
+ ebegin "${msg} ${m}: not found"
+ return 1
+ fi
+ done
+ return 0
+}
+
+start() {
+ ebegin "Checking open-iSCSI configuration"
+ checkconfig
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eend 1
+ return 1
+ fi
+ ebegin "Loading iSCSI modules"
+ do_modules 'Loading' 'libiscsi scsi_transport_iscsi iscsi_tcp'
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eend 1
+ return 1
+ fi
+
+ ebegin "Starting ${SVCNAME}"
+ start-stop-daemon --start --quiet --exec /usr/sbin/iscsid -- ${OPTS}
+ ret=$?
+ if [ $ret -ne 0 ]; then
+ eend $?
+ return $?
+ fi
+
+ # Start automatic targets when iscsid is started
+ if [ "${AUTOSTARTTARGETS}" = "yes" ]; then
+ starttargets
+ return $?
+ fi
+ return 0
+}
+
+stop() {
+ local ret=
+ stoptargets
+ ebegin "Stopping ${SVCNAME}"
+ start-stop-daemon --signal HUP --stop --quiet --exec /usr/sbin/iscsid #--pidfile $PID_FILE
+ ret=$?
+ eend $ret
+
+ # ugly, but pid file is not removed by iscsid
+ rm -f $PID_FILE
+ return $ret
+}
+
+starttargets() {
+ ebegin "Setting up iSCSI targets"
+ /usr/bin/iscsiadm -m node --loginall=automatic
+ ret=$?
+ #Don't report error when no targets are configured
+ if [ "$ret" -eq "21" ]; then
+ ret="0"
+ fi
+ eend $ret
+ return $ret
+}
+
+stoptargets() {
+ ebegin "Disconnecting iSCSI targets"
+ sync
+ /usr/bin/iscsiadm -m node --logoutall=all
+ ret=$?
+ eend $ret
+ return $ret
+}
+
+restarttargets() {
+ stoptargets
+ starttargets
+}
+
+status() {
+ ebegin "Showing current active iSCSI sessions"
+ /usr/bin/iscsiadm -m session
+}