Commit 84f367ea authored by Natanael Copa's avatar Natanael Copa
Browse files

main/open-iscsi: fix init.d and install

- fix so the iscsid.conf is not installed as /etc/init.d/iscsid
- fix so we dont install a duplicate /usr/bin/iscsid and
  /usr/sbin/iscsid
- update /etc/init.d/iscsid to use latest from gentoo
parent 920c66f7
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=open-iscsi
pkgver=2.1.0
pkgrel=0
pkgrel=1
pkgdesc="High performance, transport independent, multi-platform iSCSI initiator"
url="https://www.open-iscsi.com"
arch="all"
......@@ -25,7 +25,6 @@ builddir="$srcdir"/$pkgname-$pkgver
build() {
make prefix=/usr \
exec_prefix=/usr \
sbindir=/usr/bin \
localstatedir=/var \
sysconfdir=/etc \
mandir=/usr/share/man \
......@@ -33,18 +32,14 @@ build() {
}
package() {
make prefix=/usr sbindir=/usr/bin DESTDIR="$pkgdir" install
install -Dm755 "$pkgdir"/usr/bin/iscsid "$pkgdir"/usr/sbin/iscsid
make prefix=/usr DESTDIR="$pkgdir" install
install -Dm755 "$srcdir"/iscsid.initd "$pkgdir"/etc/init.d/iscsid
local file
for file in initd confd conf; do
install -Dm644 "$srcdir"/iscsid.$file "$pkgdir"/etc/conf.d/iscsid
install -Dm644 "$srcdir"/iscsid.$file "$pkgdir"/etc/iscsi/iscsid.$file
done
install -Dm644 "$srcdir"/iscsid.confd "$pkgdir"/etc/conf.d/iscsid
install -Dm644 "$srcdir"/iscsid.conf "$pkgdir"/etc/iscsi/iscsid.conf
}
sha512sums="bb1a4ff2bab0562bfd4281d757dd888e8f5d2d1ae16561cabf5598073c343e8c2dc9b35992c2bc51398faffceb9b70ea2eae214ab205a586bcb971d741d5f59d open-iscsi-2.1.0.tar.gz
49ac7e1c9cd6aa444edcfc4d5dea1330a93cee286d69d82521cc1afecc66296027c359f2314e418671813f049c9ff18ba4bdd0f90922423fac94b6529c887cf5 iscsid.initd
a5544e35da3433dfde96984d2e5783991d961554b8843f4f96d4317a38d7534864882342633ed0dc15c2f9e49a419e51958593b0de1ce84644938dafabe392fc iscsid.initd
075bb9cb783be7ccbc799947e0e042b85310d40b3045141dc1be40ca84ed1cc0e1e54559df501c512c179e28375314b27a03c15d9a6d4b1cabd428b2279985d3 iscsid.confd
3686d31c5642e611c0c0c61f0f42a33030a74b518a2a108f004b9bd34b2b98d8e29ee2416a5b9cc447ab0449bdc94158b2323d977e7b7d2930dd4dcf0866da68 iscsid.conf
1b89ffd6de0dc7bb63fc2702a97e49df4369158c66ee609acfc041b1677c07fbd964b7a709f1f324fa51a9842d4d3e11611d9783e18d526372d468163c0ac8db musl-fixes.patch
......
#!/sbin/openrc-run
# Copyright 1999-2015 Gentoo Foundation, Inc.
# Distributed under the terms of the GNU General Public License, v2 or later
extra_started_commands="starttargets stoptargets restarttargets"
command="/usr/sbin/iscsid"
command_args="${OPTS}"
start_stop_daemon_args="-w 100" # iscsid might fail e.g. when the iSCSI kernel modules aren't available
pidfile=${PIDFILE:-/var/run/${SVCNAME}.pid}
extra_started_commands="starttargets stoptargets"
extra_commands="restarttargets"
ISCSIADM=/usr/sbin/iscsiadm
depend() {
after modules
after modules multipath
use net
}
......@@ -16,101 +26,44 @@ checkconfig() {
eerror "Config file ${CONFIG_FILE} does not exist!"
return 1
fi
if [ ! -e ${INITIATORNAME_FILE} ] || [ ! "$(grep "^InitiatorName=iqn\." ${INITIATORNAME_FILE})" ]; then
if [ -e ${INITIATORNAME_FILE} ]; then
. ${INITIATORNAME_FILE}
fi
if [ ! -e ${INITIATORNAME_FILE} -o -z "${InitiatorName}" ]; 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')
local IQN=$(/usr/sbin/iscsi-iname)
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
ebegin "${msg} ${m}"
modprobe ${modopts} ${m}
ret=$?
eend ${ret}
if [ ${ret} -ne 0 ]; then
return ${ret}
fi
done
return 0
starttargets() {
ebegin "Setting up iSCSI targets"
$ISCSIADM -m node --loginall=automatic
local ret=$?
eend $ret
return $ret
}
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
stoptargets() {
ebegin "Disconnecting iSCSI targets"
sync
$ISCSIADM -m node --logoutall=all
local ret=$?
ebegin "Starting ${SVCNAME}"
start-stop-daemon --start --quiet --exec /usr/sbin/iscsid -- ${OPTS}
ret=$?
if [ $ret -ne 0 ]; then
eend $?
return $?
if [ $ret -eq 21 ]; then
# See man iscsiadm(8)
einfo "No active sessions to disconnect"
eend 0
return 0
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
......@@ -118,5 +71,36 @@ restarttargets() {
status() {
ebegin "Showing current active iSCSI sessions"
/usr/bin/iscsiadm -m session
$ISCSIADM -m session
}
start_pre() {
local ret=1
ebegin "Checking Open-iSCSI configuration"
checkconfig
ret=$?
if [ $ret -ne 0 ]; then
eend 1
return 1
fi
eend 0
}
start_post() {
# Start automatic targets when iscsid is started
if [ "${AUTOSTARTTARGETS}" = "yes" ]; then
starttargets
local ret=$?
if [ "${AUTOSTART}" = "strict" -a $ret -ne 0 ]; then
stop
return $ret
fi
fi
return 0
}
stop_pre() {
stoptargets
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment