diff options
author | Carlo Landmeter <clandmeter@gmail.com> | 2011-11-03 14:43:41 +0000 |
---|---|---|
committer | Carlo Landmeter <clandmeter@gmail.com> | 2011-11-03 14:43:41 +0000 |
commit | b758cfb575b2f9d7158040a9d72ec00086da0e7d (patch) | |
tree | 6ec01e74c90630f6c57a36f1754d0461c38acaaa /testing/drbd | |
parent | f55d974cc88f02d8a3071dbba55b626756fa4a75 (diff) | |
download | aports-b758cfb575b2f9d7158040a9d72ec00086da0e7d.tar.bz2 aports-b758cfb575b2f9d7158040a9d72ec00086da0e7d.tar.xz |
testing/drbd: add initd and with pacemaker support
Diffstat (limited to 'testing/drbd')
-rw-r--r-- | testing/drbd/APKBUILD | 13 | ||||
-rw-r--r-- | testing/drbd/drbd.initd | 158 |
2 files changed, 167 insertions, 4 deletions
diff --git a/testing/drbd/APKBUILD b/testing/drbd/APKBUILD index fc74ab4dbc..4369f19678 100644 --- a/testing/drbd/APKBUILD +++ b/testing/drbd/APKBUILD @@ -3,7 +3,7 @@ pkgname=drbd pkgver=8.4.0 pkgbase=8.4 -pkgrel=1 +pkgrel=2 pkgdesc="Network-based RAID 1" url="http://www.drbd.org" arch="all" @@ -13,7 +13,8 @@ depends_dev="bash bison flex" makedepends="$depends_dev" install= subpackages="$pkgname-doc" -source="http://oss.linbit.com/$pkgname/$pkgbase/$pkgname-$pkgver.tar.gz" +source="http://oss.linbit.com/$pkgname/$pkgbase/$pkgname-$pkgver.tar.gz + $pkgname.initd" _builddir="$srcdir"/$pkgname-$pkgver @@ -30,8 +31,9 @@ build() { --mandir=/usr/share/man \ --infodir=/usr/share/info \ --localstatedir=/var \ + --with-pacemaker \ + --without-udev \ --without-heartbeat \ - --without-pacemaker \ --without-rgmanager \ --without-xen \ --without-bashcompletion @@ -42,6 +44,9 @@ build() { package() { cd "$_builddir" make DESTDIR="$pkgdir" install + install -m755 -D "$srcdir/$pkgname.initd" \ + "$pkgdir/etc/init.d/$pkgname" || return 1 } -md5sums="8519246dff4e2de14595d71abcd54db4 drbd-8.4.0.tar.gz" +md5sums="8519246dff4e2de14595d71abcd54db4 drbd-8.4.0.tar.gz +f2e0173a6056ce4b9c2e3847b59899ba drbd.initd" diff --git a/testing/drbd/drbd.initd b/testing/drbd/drbd.initd new file mode 100644 index 0000000000..5da2dda326 --- /dev/null +++ b/testing/drbd/drbd.initd @@ -0,0 +1,158 @@ +#!/sbin/runscript +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 or later +# $Header: /var/cvsroot/gentoo-x86/sys-cluster/drbd/files/drbd-8.0.rc,v 1.6 2010/08/02 04:42:36 xarthisius Exp $ + +opts="${opts} reload" + +depend() { + use logger + need net + before heartbeat + after sshd +} + +DEFAULTFILE="/etc/conf.d/drbd" +DRBDADM="/sbin/drbdadm" +PROC_DRBD="/proc/drbd" +MODPROBE="/sbin/modprobe" +RMMOD="/sbin/rmmod" +UDEV_TIMEOUT=10 +ADD_MOD_PARAM="" + +if [ -f $DEFAULTFILE ]; then + . $DEFAULTFILE +fi + +# Just in case drbdadm want to display any errors in the configuration +# file, or we need to ask the user about registering this installation +# at http://usage.drbd.org, we call drbdadm here without any IO +# redirection. +$DRBDADM sh-nop + +function assure_module_is_loaded() { + [ -e "$PROC_DRBD" ] && return + ebegin "Loading drbd module" + ret=0 + + $MODPROBE -s drbd `$DRBDADM sh-mod-parms` $ADD_MOD_PARAM || ret=20 + eend $ret + return $ret +} + +function adjust_with_progress() { + IFS_O=$IFS + NEWLINE=' +' + IFS=$NEWLINE + local D=0 + local S=0 + local N=0 + + einfon "Setting drbd parameters " + COMMANDS=`$DRBDADM -d adjust all` || { + eend 20 "Error executing drbdadm" + return 20 + } + echo -n "[ " + + for CMD in $COMMANDS; do + if echo $CMD | grep -q disk; then echo -n "d$D "; D=$(( D+1 )); + elif echo $CMD | grep -q syncer; then echo -n "s$S "; S=$(( S+1 )); + elif echo $CMD | grep -q net; then echo -n "n$N "; N=$(( N+1 )); + else echo echo -n ".. "; + fi + IFS=$IFS_O + $CMD || { + echo + eend 20 "cmd $CMD failed!" + return 20 + } + IFS=$NEWLINE + done + echo "]" + eend 0 + + IFS=$IFS_O +} + +start() { + einfo "Starting DRBD resources:" + eindent + assure_module_is_loaded || return $? + adjust_with_progress || return $? + + # make sure udev has time to create the device files + ebegin "Waiting for udev device creation ..." + for RESOURCE in `$DRBDADM sh-resources`; do + for DEVICE in `$DRBDADM sh-dev $RESOURCE`; do + UDEV_TIMEOUT_LOCAL=$UDEV_TIMEOUT + while [ ! -e $DEVICE ] && [ $UDEV_TIMEOUT_LOCAL -gt 0 ] ; do + sleep 1 + UDEV_TIMEOUT_LOCAL=$(( $UDEV_TIMEOUT_LOCAL-1 )) + done + done + done + eend 0 + + einfon "Waiting for connection " + $DRBDADM wait-con-int + ret=$? + echo + + sleep 5 + + einfon "Become primary if configured " + $DRBDADM sh-b-pri all + echo + + eend $ret + return $ret +} + +stop() { + ebegin "Stopping all DRBD resources" + + # Check for mounted drbd devices + if ! grep -q '^/dev/drbd' /proc/mounts &>/dev/null; then + if [ -e ${PROC_DRBD} ]; then + ${DRBDADM} down all + sleep 3 + if grep -q '^drbd' /proc/modules ; then + ${RMMOD} drbd + fi + fi + ret=$? + eend $ret + return $ret + else + einfo "drbd devices mounted, please umount them before trying to stop drbd!" + eend 1 + return 1 + fi +} + +status() { + # NEEDS to be heartbeat friendly... + # so: put some "OK" in the output. + + if [ -e $PROC_DRBD ]; then + ret=0 + ebegin "drbd driver loaded OK; device status:" + eend $ret + cat $PROC_DRBD + else + ebegin "drbd not loaded" + ret=3 + eend $ret + fi + return $ret +} + +reload() { + ebegin "Reloading DRBD" + ${DRBDADM} adjust all + ret=$? + eend $ret + return $ret +} |