- 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
This commit is contained in:
Stefan Walter 2010-06-27 12:26:55 +00:00
parent 4f20e044b8
commit f6558c43ca
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=257059
6 changed files with 157 additions and 35 deletions

View file

@ -7,12 +7,12 @@
PORTNAME= csync2 PORTNAME= csync2
PORTVERSION= 1.34 PORTVERSION= 1.34
PORTREVISION= 7 PORTREVISION= 8
CATEGORIES= net CATEGORIES= net
MASTER_SITES= http://oss.linbit.com/csync2/ \ MASTER_SITES= http://oss.linbit.com/csync2/ \
http://people.freebsd.org/~aaron/distfiles/ http://people.freebsd.org/~aaron/distfiles/
MAINTAINER= ports@FreeBSD.org MAINTAINER= alexey@renatasystems.org
COMMENT= A cluster synchronization tool COMMENT= A cluster synchronization tool
LIB_DEPENDS= rsync.1:${PORTSDIR}/net/librsync \ LIB_DEPENDS= rsync.1:${PORTSDIR}/net/librsync \
@ -22,21 +22,37 @@ LIB_DEPENDS= rsync.1:${PORTSDIR}/net/librsync \
gcrypt.16:${PORTSDIR}/security/libgcrypt \ gcrypt.16:${PORTSDIR}/security/libgcrypt \
gpg-error.0:${PORTSDIR}/security/libgpg-error gpg-error.0:${PORTSDIR}/security/libgpg-error
OPTIONS= CSYNC2_COMPARE "Install csync2-compare script" off
.include <bsd.port.pre.mk>
MAN1= csync2.1 MAN1= csync2.1
GNU_CONFIGURE= yes GNU_CONFIGURE= yes
CONFIGURE_ARGS= --sysconfdir=${PREFIX}/etc CONFIGURE_ARGS= --sysconfdir=${PREFIX}/etc
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
CONFIGURE_ENV+= LDFLAGS="-L${LOCALBASE}/lib" LDFLAGS="-L${LOCALBASE}/lib" \
CONFIGURE_ENV+= LIBGNUTLS_CONFIG="${LOCALBASE}/bin/pkg-config gnutls" LIBGNUTLS_CONFIG="${LOCALBASE}/bin/pkg-config gnutls"
USE_RC_SUBR= csync2 USE_RC_SUBR= csync2
PLIST_FILES= etc/csync2.cfg-dist \ PLIST_FILES= etc/csync2.cfg-dist \
sbin/csync2 \ sbin/csync2
sbin/csync2-compare
.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: post-install:
@${CAT} ${PKGMESSAGE} @PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL
.include <bsd.port.mk> .include <bsd.port.post.mk>

View file

@ -6,6 +6,14 @@
# Add the following line to /etc/rc.conf to enable csync2: # Add the following line to /etc/rc.conf to enable csync2:
# csync2_enable="YES" # 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 . /etc/rc.subr
@ -13,26 +21,48 @@ name="csync2"
rcvar=${name}_enable rcvar=${name}_enable
pidfile=/var/run/${name}.pid pidfile=/var/run/${name}.pid
start_cmd="${name}_start" command=%%PREFIX%%/sbin/csync2
stop_cmd="${name}_stop"
start_cmd="csync2_start"
load_rc_config $name load_rc_config $name
: ${csync2_enable="NO"} : ${csync2_enable="NO"}
: ${csync2_flags="-ii -v"}
: ${csync2_cfg="%%PREFIX%%/etc/csync2.cfg"}
: ${csync2_logfile="/var/log/csync2.log"}
csync2_start() required_files="${csync2_cfg}"
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()
{ csync2_start() {
if [ -f "${pidfile}" ]; then
kill `cat ${pidfile}` if [ -z "$rc_fast" -a -n "$rc_pid" ]; then
wait_for_pid `cat ${pidfile}` echo 1>&2 "${name} already running? (pid=$rc_pid)."
rm -f ${pidfile} return 1
else
echo "PIDFILE not found: ${pidfile}, ${name} may already be stopped"
fi 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" run_rc_command "$1"

View file

@ -1,5 +1,14 @@
--- ./Makefile.in.orig 2007-07-24 14:04:25.000000000 -0700 --- Makefile.in.orig 2007-07-24 21:04:25.000000000 +0000
+++ ./Makefile.in 2008-01-17 02:39:42.822708243 -0800 +++ 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 @@ @@ -168,7 +168,7 @@
AM_CFLAGS = $(am__append_2) $(am__append_6) AM_CFLAGS = $(am__append_2) $(am__append_6)
AM_LDFLAGS = $(am__append_3) $(am__append_7) AM_LDFLAGS = $(am__append_3) $(am__append_7)

View file

@ -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

View file

@ -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

View file

@ -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
***********************************************************************