diff options
author | Martin Matuska <mm@FreeBSD.org> | 2008-08-11 20:09:15 +0000 |
---|---|---|
committer | Martin Matuska <mm@FreeBSD.org> | 2008-08-11 20:09:15 +0000 |
commit | c8e18c63b1c9ebccafda95775be503ce65cecb7f (patch) | |
tree | d9207416c469167b5ad0a18f061e6a44e0380fea /databases | |
parent | 1115f16ecf876c1e7cdbbe47578fe277ebdcf571 (diff) | |
download | ports-c8e18c63b1c9ebccafda95775be503ce65cecb7f.tar.gz ports-c8e18c63b1c9ebccafda95775be503ce65cecb7f.zip |
- Update pgbouncer to 1.2.3
- Add new UID and GID for pgbouncer
- Improve handling of example configuration files
- Add support for the reload rc command
- Other minor enhancements
PR: ports/126454
Submitted by: mm
Approved by: skv (maintainer)
Notes
Notes:
svn path=/head/; revision=218419
Diffstat (limited to 'databases')
-rw-r--r-- | databases/pgbouncer/Makefile | 61 | ||||
-rw-r--r-- | databases/pgbouncer/distinfo | 6 | ||||
-rw-r--r-- | databases/pgbouncer/files/patch-etc...pgbouncer.ini | 13 | ||||
-rw-r--r-- | databases/pgbouncer/files/pgbouncer.sh.in | 5 | ||||
-rw-r--r-- | databases/pgbouncer/files/pkg-deinstall.in | 30 | ||||
-rw-r--r-- | databases/pgbouncer/files/pkg-install.in | 98 | ||||
-rw-r--r-- | databases/pgbouncer/files/pkg-message.in | 9 | ||||
-rw-r--r-- | databases/pgbouncer/pkg-plist | 6 |
8 files changed, 197 insertions, 31 deletions
diff --git a/databases/pgbouncer/Makefile b/databases/pgbouncer/Makefile index 6faf300a64e7..8d7c09b303aa 100644 --- a/databases/pgbouncer/Makefile +++ b/databases/pgbouncer/Makefile @@ -6,10 +6,9 @@ # PORTNAME= pgbouncer -PORTVERSION= 1.1.2 -PORTREVISION= 1 +PORTVERSION= 1.2.3 CATEGORIES= databases -MASTER_SITES= http://pgfoundry.org/frs/download.php/1532/ +MASTER_SITES= http://pgfoundry.org/frs/download.php/1873/ MAINTAINER= skv@FreeBSD.org COMMENT= Lightweight connection pooler for PostgreSQL @@ -17,7 +16,7 @@ COMMENT= Lightweight connection pooler for PostgreSQL LIB_DEPENDS= event-1.3e:${PORTSDIR}/devel/libevent USE_RC_SUBR= pgbouncer.sh -SUB_FILES= pkg-message +SUB_FILES= pkg-message pkg-install pkg-deinstall GNU_CONFIGURE= yes USE_GMAKE= yes @@ -29,14 +28,62 @@ MAN5= pgbouncer.5 CONFIGURE_ARGS= --with-libevent=${LOCALBASE} +PKGINSTALL= ${WRKDIR}/pkg-install +PKGDEINSTALL= ${WRKDIR}/pkg-deinstall +PKGMESSAGE= ${WRKDIR}/pkg-message + +PGBOUNCER_USER?= pgbouncer +PGBOUNCER_GROUP?= pgbouncer + +PGBOUNCER_RUNDIR?= /var/run/pgbouncer +PGBOUNCER_LOGDIR?= /var/log/pgbouncer + +.include <bsd.port.pre.mk> +# Parse ${PORTSDIR}/UIDs and GIDs for the defaults +USER!= ${GREP} -E '^${PGBOUNCER_USER}:' ${PORTSDIR}/UIDs | \ + ${SED} -Ee 's/^([^:]*):([^:]*):([^:]*):([^:]*)::0:0:([^:]*):([^:]*):([^:]*)$$/USER="\1" UID="\3" GECOS="\5" HOME="\6" SHELL="\7"/' +GROUP!= ${GREP} -E '^${PGBOUNCER_GROUP}:' ${PORTSDIR}/GIDs | \ + ${SED} -Ee 's/^([^:]*):([^:]*):([^:]*):$$/GROUP="\1" GID="\3"/' + +# Apply the defaults where necessary +PGBOUNCER_USER?= ${USER:MUSER*:C/^[^=]*=\"([^\"]*)\"$/\1/} +PGBOUNCER_UID?= ${USER:MUID*:C/^[^=]*=\"([^\"]*)\"$/\1/} +PGBOUNCER_GECOS?= ${USER:MGECOS*:C/^[^=]*=\"([^\"]*)\"$/\1/} +PGBOUNCER_HOME?= ${USER:MHOME*:C/^[^=]*=\"([^\"]*)\"$/\1/} +PGBOUNCER_SHELL?= ${USER:MSHELL*:C/^[^=]*=\"([^\"]*)\"$/\1/} +PGBOUNCER_GROUP?= ${GROUP:MGROUP*:C/^[^=]*=\"([^\"]*)\"$/\1/} +PGBOUNCER_GID?= ${GROUP:MGID*:C/^[^=]*=\"([^\"]*)\"$/\1/} + +SUB_LIST+= PGBOUNCER_USER="${PGBOUNCER_USER}" \ + PGBOUNCER_UID="${PGBOUNCER_UID}" \ + PGBOUNCER_GECOS="${PGBOUNCER_GECOS}" \ + PGBOUNCER_HOME="${PGBOUNCER_HOME}" \ + PGBOUNCER_SHELL="${PGBOUNCER_SHELL}" \ + PGBOUNCER_GROUP="${PGBOUNCER_GROUP}" \ + PGBOUNCER_GID="${PGBOUNCER_GID}" \ + PGBOUNCER_LOGDIR="${PGBOUNCER_LOGDIR}" \ + PGBOUNCER_RUNDIR="${PGBOUNCER_RUNDIR}" \ + CHMOD="${CHMOD}" CHOWN="${CHOWN}" MKDIR="${MKDIR}" PW="${PW}" + +post-patch: + @${REINPLACE_CMD} -e "s|= pgbouncer.log|= ${PGBOUNCER_LOGDIR}/pgbouncer.log|g" \ + -e "s|= pgbouncer.pid|= ${PGBOUNCER_RUNDIR}/pgbouncer.pid|g" \ + ${WRKSRC}/etc/pgbouncer.ini + do-install: ${INSTALL_PROGRAM} ${WRKSRC}/pgbouncer ${PREFIX}/bin/ .if ! defined(NO_INSTALL_MANPAGES) ${INSTALL_MAN} ${WRKSRC}/doc/pgbouncer.1 ${PREFIX}/man/man1/ ${INSTALL_MAN} ${WRKSRC}/doc/pgbouncer.5 ${PREFIX}/man/man5/ .endif - ${MKDIR} ${EXAMPLESDIR} - ${INSTALL_DATA} ${WRKSRC}/etc/pgbouncer.ini ${EXAMPLESDIR} + ${INSTALL_DATA} ${WRKSRC}/etc/pgbouncer.ini ${PREFIX}/etc/pgbouncer.ini.sample + ${INSTALL_DATA} ${WRKSRC}/etc/userlist.txt ${PREFIX}/etc/pgbouncer.users.sample + +post-install: + @if [ ! -f ${PREFIX}/etc/pgbouncer.ini ]; then \ + ${CP} -p ${PREFIX}/etc/pgbouncer.ini.sample ${PREFIX}/etc/pgbouncer.ini ; \ + fi + @${SH} ${PKGINSTALL} ${PKGNAME} POST-INSTALL @${CAT} ${PKGMESSAGE} -.include <bsd.port.mk> +.include <bsd.port.post.mk> diff --git a/databases/pgbouncer/distinfo b/databases/pgbouncer/distinfo index 992a0e26272c..0494528cb134 100644 --- a/databases/pgbouncer/distinfo +++ b/databases/pgbouncer/distinfo @@ -1,3 +1,3 @@ -MD5 (pgbouncer-1.1.2.tar.gz) = 47bde1402f1a99dfc69f2f610fc1a36c -SHA256 (pgbouncer-1.1.2.tar.gz) = 155790b6edd8185f29b25c980506c612a69cf0b3133d4a033cefdf00990cd4dd -SIZE (pgbouncer-1.1.2.tar.gz) = 122054 +MD5 (pgbouncer-1.2.3.tar.gz) = e8afc79103cd464c109a56e418a9ba24 +SHA256 (pgbouncer-1.2.3.tar.gz) = 3dfbdf1afd506f676bdb517da43791a37b76def2c4cc8735ded017e12c829a6a +SIZE (pgbouncer-1.2.3.tar.gz) = 145372 diff --git a/databases/pgbouncer/files/patch-etc...pgbouncer.ini b/databases/pgbouncer/files/patch-etc...pgbouncer.ini deleted file mode 100644 index 8cb9973a6a41..000000000000 --- a/databases/pgbouncer/files/patch-etc...pgbouncer.ini +++ /dev/null @@ -1,13 +0,0 @@ ---- etc/pgbouncer.ini.orig Thu Jul 19 11:50:45 2007 -+++ etc/pgbouncer.ini Thu Jul 19 11:51:00 2007 -@@ -17,8 +17,8 @@ - ;;; Administrative settings - ;;; - --logfile = pgbouncer.log --pidfile = pgbouncer.pid -+logfile = /var/log/pgbouncer.log -+pidfile = /var/run/pgbouncer.pid - - ;;; - ;;; Where to wait for clients diff --git a/databases/pgbouncer/files/pgbouncer.sh.in b/databases/pgbouncer/files/pgbouncer.sh.in index a4b80b25ef85..a42f9465e411 100644 --- a/databases/pgbouncer/files/pgbouncer.sh.in +++ b/databases/pgbouncer/files/pgbouncer.sh.in @@ -18,15 +18,18 @@ name="pgbouncer" rcvar=`set_rcvar` +extra_commands="reload" + command="%%PREFIX%%/bin/pgbouncer" config_file="%%PREFIX%%/etc/$name.ini" command_args="-d ${config_file}" -pidfile="/var/run/$name.pid" +pidfile="%%PGBOUNCER_RUNDIR%%/$name.pid" required_files="${config_file}" # read configuration and set defaults load_rc_config "$name" : ${pgbouncer_enable="NO"} +: ${pgbouncer_user="%%PGBOUNCER_USER%%"} : ${pgbouncer_flags=""} run_rc_command "$1" diff --git a/databases/pgbouncer/files/pkg-deinstall.in b/databases/pgbouncer/files/pkg-deinstall.in new file mode 100644 index 000000000000..9ff4f2d7f305 --- /dev/null +++ b/databases/pgbouncer/files/pkg-deinstall.in @@ -0,0 +1,30 @@ +#! /bin/sh +# $FreeBSD$ + +if [ "$2" != "POST-DEINSTALL" ]; then + exit 0 +fi + +pgbouncer_user=%%PGBOUNCER_USER%% +pgbouncer_group=%%PGBOUNCER_GROUP%% + +PGBOUNCER_RUNDIR=%%PGBOUNCER_RUNDIR%% +PGBOUNCER_LOGDIR=%%PGBOUNCER_LOGDIR%% + +PW="%%PW%%" + +if ${PW} usershow "${pgbouncer_user}" 2>/dev/null 1>&2; then + echo "To delete ${pgbouncer_user} user permanently, use the following command:" + echo "${PW} userdel \"${pgbouncer_user}\"" +fi +if ${PW} groupshow "${pgbouncer_group}" 2>/dev/null 1>&2; then + echo "To delete ${pgbouncer_group} group permanently, use the following command:" + echo "${PW} groupdel \"${pgbouncer_group}\"" +fi +for DIR in ${PGBOUNCER_RUNDIR} ${PGBOUNCER_LOGDIR}; do + if test -d "${DIR}"; then + echo "You may want to remove the no longer required directory:" + echo "${DIR}" + fi +done +exit 0 diff --git a/databases/pgbouncer/files/pkg-install.in b/databases/pgbouncer/files/pkg-install.in new file mode 100644 index 000000000000..10073bd98c5d --- /dev/null +++ b/databases/pgbouncer/files/pkg-install.in @@ -0,0 +1,98 @@ +#! /bin/sh +# $FreeBSD# + +if [ "$2" != "POST-INSTALL" ]; then + exit 0 +fi + +pgbouncer_user="%%PGBOUNCER_USER%%" +pgbouncer_uid="%%PGBOUNCER_UID%%" +pgbouncer_group="%%PGBOUNCER_GROUP%%" +pgbouncer_gid="%%PGBOUNCER_GID%%" +pgbouncer_gecos="%%PGBOUNCER_GECOS%%" +pgbouncer_home="%%PGBOUNCER_HOME%%" +pgbouncer_shell="%%PGBOUNCER_SHELL%%" + +PGBOUNCER_RUNDIR="%%PGBOUNCER_RUNDIR%%" +PGBOUNCER_LOGDIR="%%PGBOUNCER_LOGDIR%%" + +CHMOD="%%CHMOD%%" +CHOWN="%%CHOWN%%" +MKDIR="%%MKDIR%%" +PW=%%PW%% + +create_group() { + local group gid + + group=$1 + gid=$2 + + + if ${PW} group show -n $group >/dev/null 2>&1 ; then + echo "===> Using existing group $group" + else + if ${PW} groupadd -n $group -g $gid ; then + echo "===> Created group $group" + else + cat <<-EOERRORMSG +*** Failed to create group $group. + +Please add user $user and group $group +manually with the following commands: + + ${PW} groupadd -n $group -g $gid + ${PW} useradd -n $user -u $uid -g $group -c "$gecos" \\ + -d $home -s $shell -h - + +and retry installing this package. +EOERRORMSG + exit 1 + fi + fi + +} + + +create_user() { + local user uid group gecos home shell + + user=$1 + uid=$2 + group=$3 + gecos=$4 + home=$5 + shell=$6 + + if ${PW} user show -n $user >/dev/null 2>&1 ; then + echo "===> Using existing user $user" + else + if ${PW} useradd -n $user -u $uid -g $group -c "$gecos" \ + -d "$home" -s "$shell" -h - ; then + echo "===> Created user $user" + else + cat <<-EOERRORMSG +*** Failed to create user $user. + +Please add user $user manually with the following command: + + ${PW} useradd -n $user -u $uid -g $group -c "$gecos" \\ + -d $home -s $shell -h - + +and retry installing this package. +EOERRORMSG + exit 1 + fi + fi +} + +create_group $pgbouncer_group $pgbouncer_gid +create_user $pgbouncer_user $pgbouncer_uid $pgbouncer_group \ + "$pgbouncer_gecos" "$pgbouncer_home" "$pgbouncer_shell" +for DIR in ${PGBOUNCER_RUNDIR} ${PGBOUNCER_LOGDIR}; do + echo "===> Creating directory ${DIR}" + ${MKDIR} ${DIR} + echo "===> Changing ownership of ${DIR}" + ${CHOWN} -R ${pgbouncer_user}:${pgbouncer_group} ${DIR} + echo "===> Changing permissions of ${DIR}" + ${CHMOD} -R 770 ${DIR} +done diff --git a/databases/pgbouncer/files/pkg-message.in b/databases/pgbouncer/files/pkg-message.in index 4c892f3d75df..4d2facfe0ca9 100644 --- a/databases/pgbouncer/files/pkg-message.in +++ b/databases/pgbouncer/files/pkg-message.in @@ -1,13 +1,12 @@ ===> CONFIGURATION NOTE: - To setup pgbouncer, you need to copy - %%EXAMPLESDIR%%/pgbouncer.ini - to %%PREFIX%%/etc/pgbouncer.ini and edit appropriately. + To setup pgbouncer you need to edit the configuration file: + %%PREFIX%%/etc/pgbouncer.ini You will also need to define the list of allowed users as - per the pgbouncer(5) man page. + per the pgbouncer(5) man page. See the sample file: + %%PREFIX%%/etc/pgbouncer.users.sample To run pgbouncer from startup, add pgbouncer_enable="YES" in your /etc/rc.conf. - diff --git a/databases/pgbouncer/pkg-plist b/databases/pgbouncer/pkg-plist index b9470859ec4c..b4127b2fecf2 100644 --- a/databases/pgbouncer/pkg-plist +++ b/databases/pgbouncer/pkg-plist @@ -1,3 +1,5 @@ bin/pgbouncer -%%EXAMPLESDIR%%/pgbouncer.ini -@dirrm %%EXAMPLESDIR%% +@unexec if cmp -s %D/etc/pgbouncer.ini %D/etc/pgbouncer.ini.sample; then rm -f %D/etc/pgbouncer.ini; fi +etc/pgbouncer.ini.sample +@exec [ -f %B/pgbouncer.ini ] || cp %B/%f %B/pgbouncer.ini +etc/pgbouncer.users.sample |