Added aur/open-iscsi

This commit is contained in:
Mike Staszel 2011-01-07 13:52:36 -06:00
parent 866d75c49a
commit 2eaad28053
5 changed files with 238 additions and 0 deletions

48
aur/open-iscsi/PKGBUILD Normal file
View file

@ -0,0 +1,48 @@
# Contributor: Stefan Kirrmann <stefan.kirrmann at gmail dot com>
# Modified: Marco Lima <cipparello@gmail.com>
# No Plugbox changes, straight from AUR
pkgname=open-iscsi
pkgver=2.0.871.3
_pkgver=2.0-871.3
pkgrel=1
pkgdesc="userland tools"
arch=('i686' 'x86_64')
url="http://www.open-iscsi.org"
license=('GPL')
depends=('bash')
install="${pkgname}.install"
backup=('etc/iscsi/iscsid.conf' 'etc/iscsi/initiatorname.iscsi' 'etc/conf.d/open-iscsi')
source=("http://kernel.org/pub/linux/kernel/people/mnc/open-iscsi/releases/${pkgname}-${_pkgver}.tar.gz" \
"open-iscsi" "open-iscsi.conf.d" "open-iscsi-build-error.patch")
#source=("http://www.open-iscsi.org/bits/${pkgname}-${_pkgver}.tar.gz" \
options=('docs')
md5sums=('16474cb7cd5a41aea1b7b0b631ac996d'
'b191af2549f7aff89321b54421eab96f'
'd6e94c159ddfdeb1ebe69c0760ed1fa6'
'cafea1118930cd7d9eb6209706020b6a')
build() {
cd ${startdir}/src/${pkgname}-${_pkgver}
patch -Np1 -i ${srcdir}/open-iscsi-build-error.patch
# include iscsistart program in the package
sed -i -e '/^PROGRAMS = /s/$/ usr\/iscsistart/' Makefile
make user
make DESTDIR=${pkgdir} install_user
install -D -m755 ${startdir}/src/open-iscsi ${pkgdir}/etc/rc.d/open-iscsi
install -D -m644 ${startdir}/src/open-iscsi.conf.d ${pkgdir}/etc/conf.d/open-iscsi
# change permission configuration file
# chmod 600 ${startdir}/pkg/etc/iscsi/iscsid.conf
install -D -m644 ${startdir}/src/${pkgname}-${_pkgver}/etc/iscsid.conf ${pkgdir}/etc/iscsi
# copy docs
mkdir -p ${pkgdir}/usr/share/doc/${pkgname}
install -m644 Changelog ${pkgdir}/usr/share/doc/${pkgname}/
install -m644 README ${pkgdir}/usr/share/doc/${pkgname}/
}

152
aur/open-iscsi/open-iscsi Normal file
View file

@ -0,0 +1,152 @@
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
# general config
[ -f /etc/conf.d/open-iscsi ] && . /etc/conf.d/open-iscsi
# Set defaults if settings are missing
[ -z "${ISCSID_ARGS}" ] && ISCSID_ARGS=""
[ -z "$SEC_BEFORE_MOUNT" ] && SEC_BEFORE_MOUNT=2
[ -z "$ISCSIADM_EXTRAARGS" ] && ISCSIADM_EXTRAARGS=""
DAEMON_NAME="open-iscsi"
case "$1" in
start)
if [ "$SERVER" == "" ]; then
echo "Please configure \$SERVER in /etc/conf.d/open-iscsi!"
stat_fail
exit 1
fi
modprobe -q iscsi_tcp &>/dev/null
modprobe -q ib_iser &>/dev/null
stat_busy "Starting Open-iSCSI daemon"
/sbin/iscsid ${ISCSID_ARGS}
if [ $? -ne 0 ]; then
stat_fail
exit 2
else
add_daemon $DAEMON_NAME
stat_done
fi
stat_busy "Discovering targets"
/sbin/iscsiadm -m discovery -t sendtargets -p $SERVER $ISCSIADM_EXTRAARGS > /dev/null
if [ $? -ne 0 ]; then
stat_fail
exit 3
else
stat_done
fi
stat_busy "Login to all portals"
/sbin/iscsiadm -m node -L all > /dev/null
if [ $? -ne 0 ]; then
stat_fail
exit 4
else
stat_done
fi
if [[ "$MOUNT" != "" ]]; then
# wait n seconds to settle
sleep $SEC_BEFORE_MOUNT
status "Mounting devices"
for MTPT in ${MOUNT[@]}; do
stat_busy "mounting $MTPT"
mount $MTPT
sleep 1
if [ $? -eq 0 ]; then
stat_done
else
stat_fail
fi
done
else
status "No devices to mount defined"
fi
;;
stop)
if [[ "$MOUNT" != "" ]]; then
status "Unmounting devices"
# unmounting in reverse order
LEN=${#MOUNT[@]}
while [ $LEN -ne 0 ]; do
let LEN=$LEN-1;
UMOUNT="$UMOUNT ${MOUNT[$LEN]}";
done
for MTPT in $UMOUNT; do
MOUNTED=$(mount|grep -c `/bin/readlink -mns $MTPT`)
if [ $MOUNTED -ne 0 ]; then
stat_busy "unmounting $MTPT"
umount $MTPT
sleep 1
if [ $? -eq 0 ]; then
stat_done
else
stat_fail
exit 5
fi
else
status "$MTPT not mounted"
fi
done
sleep 2
else
status "No devices to unmount defined"
fi
stat_busy "Logout to all portals"
/sbin/iscsiadm -m node -U all > /dev/null
if [ $? -ne 0 ]; then
stat_fail
exit 6
else
stat_done
fi
stat_busy "Stopping Open-iSCSI daemon"
[ -f /var/run/iscsid.pid ] && kill -9 `cat /var/run/iscsid.pid` &> /dev/null
if [ $? -ne 0 ]; then
stat_fail
else
rm -f /var/run/iscsid.pid
killall iscsid > /dev/null
rm_daemon $DAEMON_NAME
stat_done
fi
;;
status)
status "Open-iSCSI status"
ck_daemon $DAEMON_NAME
status "Available portals on node"
echo
echo -ne " "
/sbin/iscsiadm -m node
echo
status "Connected portals for this session"
echo
echo -ne " "
/sbin/iscsiadm -m session
echo
;;
statusv)
status "Open-iSCSI status"
ck_daemon $DAEMON_NAME
status "Detailed session info"
echo
/sbin/iscsiadm -m session -P 2
echo
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
echo "usage: $0 {start|stop|status|statusv|restart}"
;;
esac
exit 0

View file

@ -0,0 +1,11 @@
--- a/usr/iscsi_sysfs.c
+++ b/usr/iscsi_sysfs.c
@@ -22,6 +22,8 @@
#include <string.h>
#include <errno.h>
#include <dirent.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include "log.h"
#include "initiator.h"

View file

@ -0,0 +1,15 @@
# Parameters to be passed to the iscsid daemon.
ISCSID_ARGS=""
# iSCSI server IP which will be discovered by iscsiadm
SERVER=""
# mountpoints from fstab to mount (first entry will be mounted first, and so on)
# example: MOUNT=(/dev/sdb1 /dev/sdb2)
MOUNT=()
# wait n seconds before mounting connected nodes
SEC_BEFORE_MOUNT=2
# Extra arguments to pass to iscsiadm
ISCSIADM_EXTRAARGS=""

View file

@ -0,0 +1,12 @@
## arg 1: the new package version
post_install() {
echo
echo "The open-iscsi package contains the userland tools of the"
echo "Open-iSCSI project. It depends on iSCSI modules which are already"
echo "present in current (>= 2.6.16) kernels and must be present on"
echo "your system or statically compiled inside your kernel image."
echo
echo ">>> Setting Initiatorname ..."
echo "InitiatorName=$(iscsi-iname)" > /etc/iscsi/initiatorname.iscsi
echo
}