aboutsummaryrefslogtreecommitdiffstats
path: root/net/csync2
diff options
context:
space:
mode:
authorstefan <stefan@FreeBSD.org>2010-06-27 20:26:55 +0800
committerstefan <stefan@FreeBSD.org>2010-06-27 20:26:55 +0800
commitde02063670c1d0648961024857aeaaf13fbf296d (patch)
treef70b3511c9dc82e546b2a524d7bd1fedfcc3094b /net/csync2
parent8693ab2d87dcfebaa51867520ce511eb427b1d9a (diff)
downloadfreebsd-ports-gnome-de02063670c1d0648961024857aeaaf13fbf296d.tar.gz
freebsd-ports-gnome-de02063670c1d0648961024857aeaaf13fbf296d.tar.zst
freebsd-ports-gnome-de02063670c1d0648961024857aeaaf13fbf296d.zip
- Fix/update rc.d script.
- Make installation of csync2-compare optional. - Generate certificates and create directories during installation if necessary. - Assign maintainership to submitter. PR: 146970 Submitted by: Alexey V. Degtyarev <alexey@renatasystems.org> Feature safe: yes
Diffstat (limited to 'net/csync2')
-rw-r--r--net/csync2/Makefile36
-rw-r--r--net/csync2/files/csync2.in58
-rw-r--r--net/csync2/files/patch-Makefile.in13
-rw-r--r--net/csync2/files/patch-csync2-compare8
-rw-r--r--net/csync2/files/pkg-install.in68
-rw-r--r--net/csync2/pkg-message9
6 files changed, 157 insertions, 35 deletions
diff --git a/net/csync2/Makefile b/net/csync2/Makefile
index 02c8abde9456..3c2635a02f54 100644
--- a/net/csync2/Makefile
+++ b/net/csync2/Makefile
@@ -7,12 +7,12 @@
PORTNAME= csync2
PORTVERSION= 1.34
-PORTREVISION= 7
+PORTREVISION= 8
CATEGORIES= net
MASTER_SITES= http://oss.linbit.com/csync2/ \
http://people.freebsd.org/~aaron/distfiles/
-MAINTAINER= ports@FreeBSD.org
+MAINTAINER= alexey@renatasystems.org
COMMENT= A cluster synchronization tool
LIB_DEPENDS= rsync.1:${PORTSDIR}/net/librsync \
@@ -22,21 +22,37 @@ LIB_DEPENDS= rsync.1:${PORTSDIR}/net/librsync \
gcrypt.16:${PORTSDIR}/security/libgcrypt \
gpg-error.0:${PORTSDIR}/security/libgpg-error
-MAN1= csync2.1
+OPTIONS= CSYNC2_COMPARE "Install csync2-compare script" off
+
+.include <bsd.port.pre.mk>
+
+MAN1= csync2.1
GNU_CONFIGURE= yes
CONFIGURE_ARGS= --sysconfdir=${PREFIX}/etc
-CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include"
-CONFIGURE_ENV+= LDFLAGS="-L${LOCALBASE}/lib"
-CONFIGURE_ENV+= LIBGNUTLS_CONFIG="${LOCALBASE}/bin/pkg-config gnutls"
+CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
+ LDFLAGS="-L${LOCALBASE}/lib" \
+ LIBGNUTLS_CONFIG="${LOCALBASE}/bin/pkg-config gnutls"
USE_RC_SUBR= csync2
PLIST_FILES= etc/csync2.cfg-dist \
- sbin/csync2 \
- sbin/csync2-compare
+ sbin/csync2
+
+.if defined(WITH_CSYNC2_COMPARE)
+RUN_DEPENDS+= bash>=0:${PORTSDIR}/shells/bash
+PLIST_FILES+= sbin/csync2-compare
+CSYNC2_COMPARE= csync2-compare
+.else
+CSYNC2_COMPARE=
+.endif
+
+SUB_FILES= pkg-install
+
+post-patch:
+ ${REINPLACE_CMD} -E "s#%%CSYNC2_COMPARE%%#${CSYNC2_COMPARE}#" ${WRKSRC}/Makefile.in
post-install:
- @${CAT} ${PKGMESSAGE}
+ @PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
-.include <bsd.port.mk>
+.include <bsd.port.post.mk>
diff --git a/net/csync2/files/csync2.in b/net/csync2/files/csync2.in
index cd1e95639817..ca24293c32ea 100644
--- a/net/csync2/files/csync2.in
+++ b/net/csync2/files/csync2.in
@@ -6,6 +6,14 @@
# Add the following line to /etc/rc.conf to enable csync2:
# csync2_enable="YES"
+#
+# Optional configuration of csync2:
+# csync2_cfg (str): Path to csync2 main configuration.
+# Default is %%PREFIX%%/etc/csync2.cfg.
+# csync2_flags (str): Extra flags passed to csync2 program.
+# Default to "-ii -v".
+# csync2_logfile (str): Path to logfile where daemon' output logged to.
+# Default to "/var/log/csync2.log".
. /etc/rc.subr
@@ -13,26 +21,48 @@ name="csync2"
rcvar=${name}_enable
pidfile=/var/run/${name}.pid
-start_cmd="${name}_start"
-stop_cmd="${name}_stop"
+command=%%PREFIX%%/sbin/csync2
+
+start_cmd="csync2_start"
load_rc_config $name
: ${csync2_enable="NO"}
+: ${csync2_flags="-ii -v"}
+: ${csync2_cfg="%%PREFIX%%/etc/csync2.cfg"}
+: ${csync2_logfile="/var/log/csync2.log"}
+
+required_files="${csync2_cfg}"
-csync2_start()
+csync2_check_keys()
{
- %%PREFIX%%/sbin/csync2 -ii & echo $! > ${pidfile}
+ [ -f "${csync2_cfg}" ] || return 1
+
+ _key=`grep '^[[:blank:]]*key[[:space:]]\+.\+;\?$' ${csync2_cfg} |\
+ awk '{print($2)}'`
+ [ -n "${_key}" ] || return 1
+
+ for _file in ${_key}; do
+ _file=${_file%;}
+ [ ! -f "${_file}" ] && \
+ warn "PSK specified but not found, use csync2 -k ${_file} to create it."
+ done
+
+ return 0
}
-csync2_stop()
-{
- if [ -f "${pidfile}" ]; then
- kill `cat ${pidfile}`
- wait_for_pid `cat ${pidfile}`
- rm -f ${pidfile}
- else
- echo "PIDFILE not found: ${pidfile}, ${name} may already be stopped"
- fi
+
+csync2_start() {
+
+ if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
+ echo 1>&2 "${name} already running? (pid=$rc_pid)."
+ return 1
+ fi
+
+ csync2_check_keys
+
+ check_startmsgs && echo "Starting ${name}."
+
+ /usr/sbin/daemon -p ${pidfile} \
+ ${command} ${csync2_flags} >> ${csync2_logfile} 2>&1
}
run_rc_command "$1"
-
diff --git a/net/csync2/files/patch-Makefile.in b/net/csync2/files/patch-Makefile.in
index 545f4916f060..002aa80210ad 100644
--- a/net/csync2/files/patch-Makefile.in
+++ b/net/csync2/files/patch-Makefile.in
@@ -1,5 +1,14 @@
---- ./Makefile.in.orig 2007-07-24 14:04:25.000000000 -0700
-+++ ./Makefile.in 2008-01-17 02:39:42.822708243 -0800
+--- Makefile.in.orig 2007-07-24 21:04:25.000000000 +0000
++++ Makefile.in 2010-05-20 10:51:32.000000000 +0000
+@@ -150,7 +150,7 @@
+ target_alias = @target_alias@
+
+ sbin_PROGRAMS = csync2
+-sbin_SCRIPTS = csync2-compare
++sbin_SCRIPTS = %%CSYNC2_COMPARE%%
+ man_MANS = csync2.1
+
+ csync2_SOURCES = action.c cfgfile_parser.y cfgfile_scanner.l check.c \
@@ -168,7 +168,7 @@
AM_CFLAGS = $(am__append_2) $(am__append_6)
AM_LDFLAGS = $(am__append_3) $(am__append_7)
diff --git a/net/csync2/files/patch-csync2-compare b/net/csync2/files/patch-csync2-compare
new file mode 100644
index 000000000000..2e2d1a17713e
--- /dev/null
+++ b/net/csync2/files/patch-csync2-compare
@@ -0,0 +1,8 @@
+--- csync2-compare.orig 2010-05-20 10:55:31.000000000 +0000
++++ csync2-compare 2010-05-20 10:55:50.000000000 +0000
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/local/bin/bash
+
+ verbose=0
+
diff --git a/net/csync2/files/pkg-install.in b/net/csync2/files/pkg-install.in
new file mode 100644
index 000000000000..afbe4f364b60
--- /dev/null
+++ b/net/csync2/files/pkg-install.in
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+: ${PREFIX:="%%PREFIX%%"}
+: ${CSYNC2_DBDIR:="/var/db/csync2"}
+: ${CSYNC2_BACKUPDIR:="/var/backups/csync2"}
+
+create_cert() {
+
+ _errlog=`mktemp /tmp/.${0##*/}.XXXXX`
+ code=0
+
+ exec 3>&2 2>${_errlog}
+
+ openssl genrsa -out ${PREFIX}/etc/csync2_ssl_key.pem 1024 || code=1
+ yes '' | openssl req -new -key ${PREFIX}/etc/csync2_ssl_key.pem \
+ -out /tmp/csync2_ssl_cert.csr || code=1
+ openssl x509 -req -days 600 -in /tmp/csync2_ssl_cert.csr \
+ -signkey ${PREFIX}/etc/csync2_ssl_key.pem \
+ -out ${PREFIX}/etc/csync2_ssl_cert.pem || code=1
+
+ rm -f /tmp/csync2_ssl_cert.csr
+
+ if [ ${code} -ne 0 ]; then
+ echo "csync2: OpenSSL error occured:"
+ echo
+ cat ${_errlog}
+ echo
+ rm -f ${_errlog}
+ return 1
+ fi
+
+ exec 2>&3
+
+ rm -f ${_errlog}
+
+ chmod 600 ${PREFIX}/etc/csync2_ssl_key.pem \
+ ${PREFIX}/etc/csync2_ssl_cert.pem
+
+ echo "csync2: RSA certificate-key pair installed."
+
+ return 0
+}
+
+pre_install() {
+ return 0
+}
+
+post_install() {
+
+ [ -n "${PACKAGE_BUILDING}" ] && return 0
+
+ for _dir in ${CSYNC2_DBDIR} ${CSYNC2_BACKUPDIR}; do
+ [ ! -d ${_dir} ] && mkdir -p -m 700 ${_dir}
+ done
+
+ if [ ! -f ${PREFIX}/etc/csync2_ssl_cert.pem ]; then
+ create_cert || return $?
+ fi
+
+ return 0
+}
+
+[ $# -eq 2 ] || exit 0
+
+case $2 in
+ "PRE-INSTALL") pre_install ;;
+ "POST-INSTALL") post_install ;;
+esac
diff --git a/net/csync2/pkg-message b/net/csync2/pkg-message
deleted file mode 100644
index a24f0efb7a2d..000000000000
--- a/net/csync2/pkg-message
+++ /dev/null
@@ -1,9 +0,0 @@
-***********************************************************************
-
-There is a fair amount of post installation configuration that must be
-done before csync2 will work properly. Please refer to section 3.3 Post
-Installation in the official documentation found at:
-
-http://www.clifford.at/papers/2005/csync2/paper.pdf
-
-***********************************************************************