aboutsummaryrefslogtreecommitdiffstats
path: root/main/drbd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-10-18 17:44:09 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-10-18 17:47:59 +0000
commit8ddd19ebf77c0fb29136d21b81033991f46a340c (patch)
treed2432456ca1697f2c7bd6c8cb9bae141c0510ca8 /main/drbd
parent2d36899e096c47d1e7508545ba6ff19f10dd8002 (diff)
downloadaports-8ddd19ebf77c0fb29136d21b81033991f46a340c.tar.bz2
aports-8ddd19ebf77c0fb29136d21b81033991f46a340c.tar.xz
main/drbd: move from testing
fixes #2222
Diffstat (limited to 'main/drbd')
-rw-r--r--main/drbd/APKBUILD63
-rw-r--r--main/drbd/drbd.initd158
2 files changed, 221 insertions, 0 deletions
diff --git a/main/drbd/APKBUILD b/main/drbd/APKBUILD
new file mode 100644
index 0000000000..e4fd22a7f9
--- /dev/null
+++ b/main/drbd/APKBUILD
@@ -0,0 +1,63 @@
+# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+pkgname=drbd
+pkgver=8.4.3
+pkgbase=${pkgver%.*}
+pkgrel=1
+pkgdesc="Network-based RAID 1"
+url="http://www.drbd.org"
+arch="all"
+license="GPL"
+depends="bash"
+depends_dev="bash bison flex"
+makedepends="$depends_dev"
+install=
+subpackages="$pkgname-doc $pkgname-pacemaker"
+source="http://oss.linbit.com/$pkgname/$pkgbase/$pkgname-$pkgver.tar.gz
+ $pkgname.initd"
+
+
+_builddir="$srcdir"/$pkgname-$pkgver
+
+prepare() {
+ cd "$_builddir"
+ sed -i "s/mv --force/mv -f/" drbd/Makefile || return 1
+}
+
+build() {
+ cd "$_builddir"
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --mandir=/usr/share/man \
+ --infodir=/usr/share/info \
+ --localstatedir=/var \
+ --with-pacemaker \
+ --without-udev \
+ --without-heartbeat \
+ --without-rgmanager \
+ --without-xen \
+ --without-bashcompletion
+
+ make || return 1
+}
+
+package() {
+ cd "$_builddir"
+ make DESTDIR="$pkgdir" install
+ install -m755 -D "$srcdir/$pkgname.initd" \
+ "$pkgdir/etc/init.d/$pkgname" || return 1
+}
+
+pacemaker() {
+ arch="noarch"
+ depends="drbd"
+ mkdir -p "$subpkgdir"/usr/lib
+ mv "$pkgdir"/usr/lib/ocf "$subpkgdir"/usr/lib
+}
+
+md5sums="0c54a69603fa28b41de5fb33e03fd9e8 drbd-8.4.3.tar.gz
+d60b4214a512a5dd450fb298cf421c97 drbd.initd"
+sha256sums="abeb09309b77b533b8e738a601d703b338dce6e4d6cf59741e2f0693fbf94527 drbd-8.4.3.tar.gz
+e91440fb27e4824fe171283f605f3f554f60facd903d3dfd304ab54b48676d48 drbd.initd"
+sha512sums="cdc90bdd9491fe6d29e3b779d69ba2aac1aacdb336586f1ef414d0a0195d922dbefa8b2d9c4868a2476998a713c893403344a2934c7768ff6f4ba9f13bb7277a drbd-8.4.3.tar.gz
+200e0203706fe5146ba266b518e6ff6ce61aa2cd2e3ca06cccabadff58df834dd61d700a375a31a2bc382f838f87d44c79b80fa15ade628aee345ee3431ede74 drbd.initd"
diff --git a/main/drbd/drbd.initd b/main/drbd/drbd.initd
new file mode 100644
index 0000000000..26dab09431
--- /dev/null
+++ b/main/drbd/drbd.initd
@@ -0,0 +1,158 @@
+#!/sbin/runscript
+# Copyright 1999-2013 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.8 2013/01/17 19:09:04 robbat2 Exp $
+
+extra_started_commands="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
+
+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
+}
+
+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 -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
+ ret=$?
+ sleep 3
+ if [ -e /proc/modules ] && grep -q '^drbd' /proc/modules ; then
+ ${RMMOD} drbd
+ fi
+ fi
+ 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
+}