mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 01:39:16 -04:00
- 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:
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
|
@ -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
|
||||
|
||||
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>
|
||||
|
|
|
@ -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"}
|
||||
|
||||
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()
|
||||
{
|
||||
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"
|
||||
|
||||
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"
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
8
net/csync2/files/patch-csync2-compare
Normal file
8
net/csync2/files/patch-csync2-compare
Normal 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
|
||||
|
68
net/csync2/files/pkg-install.in
Normal file
68
net/csync2/files/pkg-install.in
Normal 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
|
|
@ -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
|
||||
|
||||
***********************************************************************
|
Loading…
Add table
Reference in a new issue