diff options
author | 2015-08-06 02:38:08 +0000 | |
---|---|---|
committer | 2015-08-06 02:38:08 +0000 | |
commit | a1c687a2a320b7ae05cda8fa4cc55728894fc805 (patch) | |
tree | 7846c372ac47fb02976683f46584968d06e0ab53 /sys-cluster | |
parent | Add REQUIRED_USE settings for dbus #556668 by Kirill A. Shutemov. (diff) | |
download | gentoo-2-a1c687a2a320b7ae05cda8fa4cc55728894fc805.tar.gz gentoo-2-a1c687a2a320b7ae05cda8fa4cc55728894fc805.tar.bz2 gentoo-2-a1c687a2a320b7ae05cda8fa4cc55728894fc805.zip |
add rbdmap init script, bug 553292, thanks frank <skunk at legalise.it>
(Portage version: 2.2.20/cvs/Linux x86_64, signed Manifest commit with key 0xAABEFD55)
Diffstat (limited to 'sys-cluster')
-rw-r--r-- | sys-cluster/ceph/ChangeLog | 6 | ||||
-rw-r--r-- | sys-cluster/ceph/ceph-0.94.2.ebuild | 3 | ||||
-rw-r--r-- | sys-cluster/ceph/files/rbdmap.initd | 122 |
3 files changed, 129 insertions, 2 deletions
diff --git a/sys-cluster/ceph/ChangeLog b/sys-cluster/ceph/ChangeLog index f3502855f80a..4a183756acce 100644 --- a/sys-cluster/ceph/ChangeLog +++ b/sys-cluster/ceph/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog for sys-cluster/ceph # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/sys-cluster/ceph/ChangeLog,v 1.75 2015/08/04 15:47:03 dlan Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-cluster/ceph/ChangeLog,v 1.76 2015/08/06 02:38:08 dlan Exp $ + + 06 Aug 2015; Yixun Lan <dlan@gentoo.org> ceph-0.94.2.ebuild, + +files/rbdmap.initd: + add rbdmap init script, bug 553292, thanks frank <skunk at legalise.it> *ceph-0.80.10-r1 (04 Aug 2015) diff --git a/sys-cluster/ceph/ceph-0.94.2.ebuild b/sys-cluster/ceph/ceph-0.94.2.ebuild index 8c528c095f4a..2f313ed9a89c 100644 --- a/sys-cluster/ceph/ceph-0.94.2.ebuild +++ b/sys-cluster/ceph/ceph-0.94.2.ebuild @@ -1,6 +1,6 @@ # Copyright 1999-2015 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-cluster/ceph/ceph-0.94.2.ebuild,v 1.1 2015/07/15 08:57:51 dlan Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-cluster/ceph/ceph-0.94.2.ebuild,v 1.2 2015/08/06 02:38:08 dlan Exp $ EAPI=5 PYTHON_COMPAT=( python2_7 ) @@ -127,6 +127,7 @@ src_install() { keepdir /var/lib/${PN}/tmp keepdir /var/log/${PN}/stat + newinitd "${FILESDIR}/rbdmap.initd" rbdmap newinitd "${FILESDIR}/${PN}.initd-r1" ${PN} newconfd "${FILESDIR}/${PN}.confd-r1" ${PN} diff --git a/sys-cluster/ceph/files/rbdmap.initd b/sys-cluster/ceph/files/rbdmap.initd new file mode 100644 index 000000000000..fa5832d113b8 --- /dev/null +++ b/sys-cluster/ceph/files/rbdmap.initd @@ -0,0 +1,122 @@ +#!/sbin/runscript + +DESC="RBD Mapping:" +RBDMAPFILE="/etc/ceph/rbdmap" + +extra_started_commands="reload" + +depend() { + need localmount net + before netmount +} + +start() { + + if [ ! -f "${RBDMAPFILE}" ]; then + ewarn "$DESC : No ${RBDMAPFILE} found." + exit 0 + fi + + RET=0 + # Read /etc/ceph/rbdmap to create non-existant mapping + while read DEV PARAMS; do + case "$DEV" in + ""|\#*) + continue + ;; + */*) + ;; + *) + DEV=rbd/$DEV + ;; + esac + ebegin "${DESC} '${DEV}'" + newrbd="" + MAP_RV="" + RET_OP=0 + OIFS=$IFS + IFS=',' + for PARAM in ${PARAMS[@]}; do + CMDPARAMS="${CMDPARAMS} --$(echo ${PARAM} | tr '=' ' ')" + done + IFS=$OIFS + if [ ! -b /dev/rbd/${DEV} ]; then + MAP_RV=$(rbd map ${DEV} ${CMDPARAMS} 2>&1) + if [ $? -eq 0 ]; then + newrbd="yes" + else + RET=$((${RET}+$?)) + RET_OP=1 + fi + fi + eend ${RET_OP} "${MAP_RV}" + + if [ "$newrbd" ]; then + ## Mount new rbd + MNT_RV="" + mount --fake /dev/rbd/${DEV} >>/dev/null 2>&1 \ + && MNT_RV=$(mount -vn /dev/rbd/${DEV} 2>&1) + [ -n "${MNT_RV}" ] && einfo "mount: ${MNT_RV}" + + ## post-mapping + if [ -x "/etc/ceph/rbd.d/${DEV}" ]; then + einfo "RBD Running post-map hook '/etc/ceph/rbd.d/${DEV}'" + /etc/ceph/rbd.d/${DEV} map "/dev/rbd/${DEV}" + fi + fi + done < ${RBDMAPFILE} + eend ${RET} +} + +stop() { + + RET=0 + ## Unmount and unmap all rbd devices + if ls /dev/rbd[0-9]* >/dev/null 2>&1; then + for DEV in /dev/rbd[0-9]*; do + ## pre-unmapping + for L in $(find /dev/rbd -type l); do + LL="${L##/dev/rbd/}" + if [ "$(readlink -f $L)" = "${DEV}" ] \ + && [ -x "/etc/ceph/rbd.d/${LL}" ]; then + einfo "RBD pre-unmap: '${DEV}' hook '/etc/ceph/rbd.d/${LL}'" + /etc/ceph/rbd.d/${LL} unmap "$L" + break + fi + done + + ebegin "Unmapping RBD device: '${DEV}'" + UMNT_RV="" + UMAP_RV="" + RET_OP=0 + MNT=$(findmnt --mtab --source ${DEV} --noheadings | awk '{print $1'}) + if [ -n "${MNT}" ]; then + einfo "un-mounting '${MNT}'" + UMNT_RV=$(umount "${MNT}" 2>&1) + fi + if mountpoint -q "${MNT}"; then + ## Un-mounting failed. + RET_OP=1 + RET=$((${RET}+1)) + else + ## Un-mapping. + UMAP_RV=$(rbd unmap $DEV 2>&1) + if [ $? -ne 0 ]; then + RET=$((${RET}+$?)) + RET_OP=1 + fi + fi + eend ${RET_OP} "${UMAP_RV}" + [ -n "${UMNT_RV}" ] && einfo "${UMNT_RV}" + done + fi + eend ${RET} +} + +reload() { + start +} + +status() { + rbd showmapped +} |