initial import
This commit is contained in:
51
pgbouncer/PKGBUILD
Normal file
51
pgbouncer/PKGBUILD
Normal file
@@ -0,0 +1,51 @@
|
||||
# Maintainer: Jesus E. <heckyel@riseup.net>
|
||||
|
||||
pkgname=pgbouncer
|
||||
pkgver=1.15.0
|
||||
pkgrel=1
|
||||
pkgdesc="A lightweight connection pooler for PostgreSQL"
|
||||
arch=('i686' 'x86_64')
|
||||
url="https://wiki.postgresql.org/wiki/PgBouncer"
|
||||
license=('ISC')
|
||||
depends=('glibc' 'libevent' 'c-ares' 'libressl')
|
||||
makedepends=('asciidoc' 'xmlto')
|
||||
backup=('etc/pgbouncer/pgbouncer.ini'
|
||||
'etc/logrotate.d/pgbouncer'
|
||||
'etc/conf.d/pgbouncer')
|
||||
install=$pkgname.install
|
||||
source=("https://pgbouncer.github.io/downloads/files/$pkgver/$pkgname-$pkgver.tar.gz"
|
||||
"pgbouncer.ini"
|
||||
"pgbouncer.logrotate"
|
||||
"patch-lib_usual_tls_tls_c.patch"
|
||||
"pgbouncer.confd"
|
||||
"pgbouncer.initd")
|
||||
sha512sums=('5f78018ab80ab8d81f20ef3df1314ffc9557f1c6469d485d11ac822f596e3d4b554743fd9e9fe19b008a8aaf93bcf3673b42a8fb82bbd9611bd735cd2cbb98c6'
|
||||
'39abc7b11c9d7a2593941b4d2a82db998ac1b1e3da131ae276da73c7afc4eda7b69bbfd0acd39f7bce20ecb911baf0adba341ff58dcab1a57e419708e7c8d26f'
|
||||
'1dc86704fce211b23afe7962c947c7de80a15bef219928acbf486b915d80d44a6590fbc509fe650c97b694a508bcf95d2152663863f0c372323286e644c6d60a'
|
||||
'e4a12313d535b84ce1f9db077d2a4cc818356540cb0f35b7374fdde5c69861ccbb0ce437e8cda943cdd16bca9179c6c862891a2ff6f0b998b7618ac91adb93b2'
|
||||
'dbcd7f5860b7f1ec6b6372b718678ba74c5268e89eed0fe291cd292a50460f0e81876367cb86e97f1cfefc0ace8d698c41a313642ec64d2de0747c348665afba'
|
||||
'ecd34f017316b2c0aad172e5bf5393137da5ab841f4d6de93eb82a07abe9f234a2426ca7dada2dc047c33ea4c7dc0af3040b249ec1f9d7e0c1782fb0463a7293')
|
||||
|
||||
prepare() {
|
||||
cd "$srcdir/$pkgname-$pkgver/lib"
|
||||
patch -Np1 -i $srcdir/patch-lib_usual_tls_tls_c.patch
|
||||
}
|
||||
|
||||
build() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
./configure \
|
||||
--prefix=/usr \
|
||||
--disable-debug
|
||||
make
|
||||
}
|
||||
|
||||
package() {
|
||||
cd "$srcdir/$pkgname-$pkgver"
|
||||
make DESTDIR="$pkgdir/" install
|
||||
install -D -m644 COPYRIGHT -t "$pkgdir/usr/share/licenses/$pkgname"
|
||||
install -D -m644 $srcdir/pgbouncer.ini "$pkgdir/etc/pgbouncer/pgbouncer.ini"
|
||||
install -D -m644 $srcdir/pgbouncer.logrotate "$pkgdir/etc/logrotate.d/pgbouncer"
|
||||
install -D -m644 $srcdir/pgbouncer.confd "$pkgdir/etc/conf.d/pgbouncer"
|
||||
install -D -m755 $srcdir/pgbouncer.initd "$pkgdir/etc/init.d/pgbouncer"
|
||||
mkdir -p "$pkgdir/var/log/pgbouncer"
|
||||
}
|
||||
14
pgbouncer/patch-lib_usual_tls_tls_c.patch
Normal file
14
pgbouncer/patch-lib_usual_tls_tls_c.patch
Normal file
@@ -0,0 +1,14 @@
|
||||
$OpenBSD: patch-lib_usual_tls_tls_c,v 1.2 2018/01/22 10:57:29 landry Exp $
|
||||
|
||||
Index: lib/usual/tls/tls.c
|
||||
--- lib/usual/tls/tls.c.orig
|
||||
+++ lib/usual/tls/tls.c
|
||||
@@ -350,7 +350,7 @@ tls_info_callback(const SSL *ssl, int where, int rc)
|
||||
{
|
||||
struct tls *ctx = SSL_get_app_data(ssl);
|
||||
|
||||
-#ifdef USE_LIBSSL_INTERNALS
|
||||
+#if defined(USE_LIBSSL_INTERNALS) && (!defined(LIBRESSL_VERSION_NUMBER) || LIBRESSL_VERSION_NUMBER < 0x2050100fL)
|
||||
if (!(ctx->state & TLS_HANDSHAKE_COMPLETE) && ssl->s3) {
|
||||
/* steal info about used DH key */
|
||||
if (ssl->s3->tmp.dh && !ctx->used_dh_bits) {
|
||||
12
pgbouncer/pgbouncer.confd
Normal file
12
pgbouncer/pgbouncer.confd
Normal file
@@ -0,0 +1,12 @@
|
||||
# Location of configuration file for PgBouncer.
|
||||
INIFILE="/etc/pgbouncer/pgbouncer.ini"
|
||||
|
||||
# How long to wait in seconds for a safe shutdown. Equivalent to
|
||||
# issuing 'PAUSE;' and 'SHUTDOWN;' on psql console. (See 'man 1 pgbouncer'.)
|
||||
NICE_TIMEOUT=60
|
||||
|
||||
# Set to 'YES' to perform an immediate shutdown if the nice shutdown
|
||||
# doesn't work. Same as issuing 'SHUTDOWN;' on console. (See 'man 1
|
||||
# pgbouncer'.)
|
||||
FORCE_QUIT="no"
|
||||
FORCE_QUIT_TIMEOUT=2
|
||||
52
pgbouncer/pgbouncer.ini
Normal file
52
pgbouncer/pgbouncer.ini
Normal file
@@ -0,0 +1,52 @@
|
||||
[pgbouncer]
|
||||
logfile = /var/log/pgbouncer/pgbouncer.log
|
||||
pidfile = /run/pgbouncer/pgbouncer.pid
|
||||
|
||||
;; ip address or * which means all ip-s
|
||||
;listen_addr = 127.0.0.1
|
||||
;listen_port = 6432
|
||||
|
||||
unix_socket_dir = /run/postgresql
|
||||
unix_socket_mode = 0777
|
||||
|
||||
; any, trust, plain, crypt, md5
|
||||
auth_type = trust
|
||||
auth_file = /etc/pgbouncer/userlist.txt
|
||||
|
||||
; comma-separated list of users, who are allowed to change settings
|
||||
admin_users = postgres
|
||||
|
||||
; comma-separated list of users who are just allowed to use SHOW command
|
||||
stats_users = stats, postgres
|
||||
|
||||
; total number of clients that can connect
|
||||
max_client_conn = 100
|
||||
|
||||
; default pool size. 20 is good number when transaction pooling
|
||||
; is in use, in session pooling it needs to be the number of
|
||||
; max clients you want to handle at any moment
|
||||
default_pool_size = 20
|
||||
|
||||
|
||||
;; database name = connect string
|
||||
;;
|
||||
;; connect string params:
|
||||
;; dbname= host= port= user= password=
|
||||
;; client_encoding= datestyle= timezone=
|
||||
;; pool_size= connect_query=
|
||||
[databases]
|
||||
|
||||
; foodb over unix socket
|
||||
;foodb =
|
||||
|
||||
; redirect bardb to bazdb on localhost
|
||||
;bardb = host=localhost dbname=bazdb
|
||||
|
||||
; acceess to dest database will go with single user
|
||||
;forcedb = host=127.0.0.1 port=300 user=baz password=foo client_encoding=UNICODE datestyle=ISO connect_query='SELECT 1'
|
||||
|
||||
; use custom pool sizes
|
||||
;nondefaultdb = pool_size=50 reserve_pool=10
|
||||
|
||||
; fallback connect string
|
||||
;* = host=testserver
|
||||
88
pgbouncer/pgbouncer.initd
Normal file
88
pgbouncer/pgbouncer.initd
Normal file
@@ -0,0 +1,88 @@
|
||||
#!/sbin/openrc-run
|
||||
|
||||
extra_started_commands="reload"
|
||||
|
||||
depend() {
|
||||
use net
|
||||
after postgresql
|
||||
}
|
||||
|
||||
get_config() {
|
||||
[ -f "${INIFILE}" ] || eend 1 "'${INIFILE}' not found"
|
||||
|
||||
eval echo $(sed -e 's:;.*::' "${INIFILE}" | \
|
||||
awk '$1 == "'$1'" { print ($2 == "=" ? $3 : $2) }')
|
||||
}
|
||||
|
||||
PIDFILE="$(get_config pidfile)"
|
||||
UNIX_SOCKET_DIR="$(get_config unix_socket_dir)"
|
||||
|
||||
prep() {
|
||||
if [ -n "${UNIX_SOCKET_DIR}" ] ; then
|
||||
checkpath -o postgres:postgres -m 0775 -d "${UNIX_SOCKET_DIR}" \
|
||||
|| return 1
|
||||
fi
|
||||
checkpath -o pgbouncer:postgres -m 0755 -d "$(dirname ${PIDFILE})" \
|
||||
|| return 1
|
||||
checkpath -o pgbouncer:postgres -m 0644 -f "${PIDFILE}" \
|
||||
|| return 1
|
||||
checkpath -o pgbouncer:postgres -m 0755 -d "$(dirname $(get_config logfile))" \
|
||||
|| return 1
|
||||
checkpath -o pgbouncer:postgres -m 0640 -f "$(get_config logfile)" \
|
||||
|| return 1
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
start() {
|
||||
ebegin "Starting PgBouncer"
|
||||
prep
|
||||
local ret=$?
|
||||
if [ $ret -ne 0 ] ; then
|
||||
eend $ret
|
||||
exit $ret
|
||||
fi
|
||||
start-stop-daemon --start \
|
||||
--pidfile ${PIDFILE} \
|
||||
--user pgbouncer \
|
||||
--exec /usr/bin/pgbouncer -- -q -d "${INIFILE}"
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
local seconds=$(( ${NICE_TIMEOUT} + ${FORCE_QUIT_TIMEOUT} ))
|
||||
ebegin "Stopping PgBouncer (this can take up to ${seconds} seconds)"
|
||||
|
||||
local retries=SIGINT/${NICE_TIMEOUT}
|
||||
|
||||
if [ "${FORCE_QUIT}" = "YES" ] ; then
|
||||
einfo "FORCE_QUIT enabled."
|
||||
retries="${retries}/SIGTERM/${FORCE_QUIT_TIMEOUT}"
|
||||
fi
|
||||
|
||||
# Loops through nice and force quit in one go.
|
||||
start-stop-daemon --stop \
|
||||
--pidfile ${PIDFILE} \
|
||||
--retry ${retries}
|
||||
|
||||
eend $?
|
||||
}
|
||||
|
||||
restart() {
|
||||
if [ -n "${UNIX_SOCKET_DIR}" ] ; then
|
||||
ebegin "Performing online restart of PgBouncer"
|
||||
start-stop-daemon --start \
|
||||
--pidfile ${PIDFILE} \
|
||||
--user pgbouncer \
|
||||
--exec /usr/bin/pgbouncer -- -q -d -R "${INIFILE}"
|
||||
eend $?
|
||||
else
|
||||
stop && start
|
||||
fi
|
||||
}
|
||||
|
||||
reload() {
|
||||
ebegin "Reloading PgBouncer configuration from '${INIFILE}'"
|
||||
start-stop-daemon --signal HUP --pidfile ${PIDFILE}
|
||||
eend $?
|
||||
}
|
||||
34
pgbouncer/pgbouncer.install
Normal file
34
pgbouncer/pgbouncer.install
Normal file
@@ -0,0 +1,34 @@
|
||||
post_install() {
|
||||
if [ ! -d '/var/lib/postgres' ]; then
|
||||
mkdir -p '/var/lib/postgres'
|
||||
fi
|
||||
if ! getent group postgres &>/dev/null; then
|
||||
groupadd -g 88 postgres
|
||||
fi
|
||||
if ! getent passwd postgres &>/dev/null; then
|
||||
useradd -c 'PostgreSQL user' -u 88 -g postgres -d '/var/lib/postgres' -s /bin/bash postgres
|
||||
passwd -l postgres >/dev/null
|
||||
fi
|
||||
if ! getent group pgbouncer &>/dev/null; then
|
||||
groupadd -r pgbouncer
|
||||
fi
|
||||
if ! getent passwd pgbouncer &>/dev/null; then
|
||||
useradd -c 'PGBouncer user' -r -g pgbouncer -d '/etc/pgbouncer' -s /bin/bash pgbouncer
|
||||
passwd -l pgbouncer >/dev/null
|
||||
fi
|
||||
chown pgbouncer:pgbouncer /var/log/pgbouncer
|
||||
gpasswd -a pgbouncer postgres
|
||||
}
|
||||
|
||||
post_upgrade() {
|
||||
post_install
|
||||
}
|
||||
|
||||
post_remove() {
|
||||
if getent passwd pgbouncer &>/dev/null; then
|
||||
userdel pgbouncer >/dev/null
|
||||
fi
|
||||
if getent group pgbouncer &>/dev/null; then
|
||||
groupdel pgbouncer >/dev/null
|
||||
fi
|
||||
}
|
||||
8
pgbouncer/pgbouncer.logrotate
Normal file
8
pgbouncer/pgbouncer.logrotate
Normal file
@@ -0,0 +1,8 @@
|
||||
/var/log/pgbouncer/pgbouncer.log {
|
||||
copytruncate
|
||||
missingok
|
||||
notifempty
|
||||
postrotate
|
||||
/bin/kill -HUP $(cat /run/pgbouncer/pgbouncer.pid 2>/dev/null) 2> /dev/null || true
|
||||
endscript
|
||||
}
|
||||
Reference in New Issue
Block a user