diff options
author | Leonardo Arena <rnalrd@alpinelinux.org> | 2012-04-18 09:29:18 +0000 |
---|---|---|
committer | Leonardo Arena <rnalrd@alpinelinux.org> | 2012-04-18 09:30:53 +0000 |
commit | b7aa1c92a86b7f27d237f090528ec112ac9696f0 (patch) | |
tree | 0d770d656f37af308f64f4ce5f66fca0b2acaea1 /main | |
parent | abec1f391ad1400086af5369127605ce2c90e59e (diff) | |
download | aports-b7aa1c92a86b7f27d237f090528ec112ac9696f0.tar.bz2 aports-b7aa1c92a86b7f27d237f090528ec112ac9696f0.tar.xz |
main/open-iscsi: restore package
This reverts commit bdeb1544255f85ed635bf584636808c45a1abad5.
Newer kernels merged open-iscsi module. We need the userland utils back.
Diffstat (limited to 'main')
-rw-r--r-- | main/open-iscsi/APKBUILD | 44 | ||||
-rw-r--r-- | main/open-iscsi/iscsid.confd | 13 | ||||
-rw-r--r-- | main/open-iscsi/iscsid.initd | 124 |
3 files changed, 181 insertions, 0 deletions
diff --git a/main/open-iscsi/APKBUILD b/main/open-iscsi/APKBUILD new file mode 100644 index 0000000000..f8eff5b440 --- /dev/null +++ b/main/open-iscsi/APKBUILD @@ -0,0 +1,44 @@ +# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org> +pkgname=open-iscsi +pkgver=2.0.872 +_realver=${pkgver%.*}-${pkgver##*.} +pkgrel=3 +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://kernel.org/pub/linux/kernel/people/mnc/open-iscsi/releases/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="b4df94f08c241352bb964043b3e44779 open-iscsi-2.0-872.tar.gz +9971f5abe255764ee616566e60955dba iscsid.initd +b762b687d4628791b4362df22cf22d34 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..8ac8e1d9b5 --- /dev/null +++ b/main/open-iscsi/iscsid.initd @@ -0,0 +1,124 @@ +#!/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=$? + 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 +} |