diff options
-rw-r--r-- | pcr/corosync/PKGBUILD | 38 | ||||
-rwxr-xr-x | pcr/corosync/corosync.init | 126 | ||||
-rw-r--r-- | pcr/corosync/corosync.service | 13 |
3 files changed, 177 insertions, 0 deletions
diff --git a/pcr/corosync/PKGBUILD b/pcr/corosync/PKGBUILD new file mode 100644 index 000000000..e7c019a66 --- /dev/null +++ b/pcr/corosync/PKGBUILD @@ -0,0 +1,38 @@ +# Maintainer: Eric Renfro <erenfro@gmail.com> + +pkgname=corosync +pkgver=2.1.0 +pkgrel=4 +pkgdesc="Cluster engine for nodal communication systems with additional features for implementing high availability within applications." +arch=('i686' 'x86_64') +url="http://www.corosync.org/" +license=('BSD') +makedepends=('nss' 'libstatgrab' 'net-snmp' 'libqb') +depends=('nss' 'libstatgrab' 'net-snmp' 'libqb') +provides=('corosync=2.1.0') +conflicts=('corosync1') +#source=(ftp://ftp:downloads@ftp.corosync.org/downloads/${pkgname}-${pkgver}/${pkgname}-${pkgver}.tar.gz) +source=("https://github.com/downloads/corosync/corosync/corosync-${pkgver}.tar.gz" + "corosync.init" + "corosync.service") +md5sums=('dc5152e6dfdb4638ab544e587884483a' + 'fdc3b648f020e165eaa7c3283ce5b9ac' + 'abc267226faafc7dc8246634277705ea') + +build() { + cd "${srcdir}/${pkgname}-${pkgver}" + ./configure --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var \ + --enable-systemd \ + --enable-monitoring \ + --enable-snmp \ + --enable-dbus \ + --with-systemddir=/usr/lib/systemd/system + make || return 1 + make DESTDIR="${pkgdir}" install || return 1 + ## Updated and fixed up systemd service unit and associated start/stop script: + cp ${srcdir}/corosync.service ${pkgdir}/usr/lib/systemd/system/corosync.service || return 1 + cp ${srcdir}/corosync.init ${pkgdir}/usr/share/corosync/corosync || return 1 +} + diff --git a/pcr/corosync/corosync.init b/pcr/corosync/corosync.init new file mode 100755 index 000000000..b97186dee --- /dev/null +++ b/pcr/corosync/corosync.init @@ -0,0 +1,126 @@ +#!/bin/bash + +# Authors: +# Eric Renfro <erenfro@gmail.com> + +desc="Corosync Cluster Engine" +prog="corosync" + +# set secure PATH +PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/sbin" + +status() +{ + pid=$(pidof $prog 2>/dev/null) + return $? +} + +if [ -d /etc/default ]; then + [ -f /etc/default/$prog ] && . /etc/default/$prog + [ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/$prog" +fi + +cluster_disabled_at_boot() +{ + if grep -q nocluster /proc/cmdline && \ + [ "$(tty)" = "/dev/console" ]; then + return 1 + fi + return 0 +} + +wait_for_ipc() +{ + local try=0 + while [ "$try" -le "20" ]; do + if corosync-cfgtool -s > /dev/null 2>&1; then + return 0 + fi + sleep 0.5 + let try++ + done + + return 1 +} + +start() +{ + echo -n "Starting $desc ($prog): " + + ! cluster_disabled_at_boot && return + + # most recent distributions use tmpfs for /var/run + # to avoid to clean it up on every boot. + # they also assume that init scripts will create + # required subdirectories for proper operations + mkdir -p /var/run + + if status $prog > /dev/null 2>&1; then + rtrn=0 + else + $prog > /dev/null 2>&1 + + if ! wait_for_ipc; then + echo "FAILED" + rtrn=1 + fi + touch $LOCK_FILE + rtrn=0 + fi + echo "OK" +} + +stop() +{ + ! status $prog > /dev/null 2>&1 && return + + echo -n "Signaling $desc ($prog) to terminate: " + kill -TERM $(pidof $prog) > /dev/null 2>&1 + echo "OK" + + echo -n "Waiting for $prog services to unload:" + while status $prog > /dev/null 2>&1; do + sleep 1 + echo -n "." + done + + rm -f $LOCK_FILE + echo " OK" + rtrn=0 +} + +restart() +{ + stop + start +} + +rtrn=0 + +case "$1" in +start) + start + ;; +restart|reload|force-reload) + restart + ;; +condrestart|try-restart) + if status $prog > /dev/null 2>&1; then + restart + fi + ;; +status) + status $prog + rtrn=$? + ;; +stop) + stop + ;; +*) + echo "usage: $0 {start|stop|restart|reload|force-reload|condrestart|try-restart|status}" + rtrn=2 + ;; +esac + +exit $rtrn + diff --git a/pcr/corosync/corosync.service b/pcr/corosync/corosync.service new file mode 100644 index 000000000..e601181ee --- /dev/null +++ b/pcr/corosync/corosync.service @@ -0,0 +1,13 @@ +[Unit] +Description=Corosync Cluster Engine +ConditionKernelCommandLine=!nocluster +Requires=network.target +After=network.target + +[Service] +ExecStart=/usr/share/corosync/corosync start +ExecStop=/usr/share/corosync/corosync stop +Type=forking + +[Install] +WantedBy=multi-user.target |