-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathinstall-pgbouncer-rr-patch.sh
executable file
·98 lines (90 loc) · 2.48 KB
/
install-pgbouncer-rr-patch.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
#
# Copyright 2015-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Amazon Software License (the "License").
# You may not use this file except in compliance with the License. A copy of the License is located at
#
# http://aws.amazon.com/asl/
#
# or in the "license" file accompanying this file.
# This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied.
# See the License for the specific language governing permissions and limitations under the License.
#
# pgbouncer-rr-patch:
# Script to patch pgbouncer distribution with pgbouncer-rr enhancements
#
USAGE="Usage: $0 <pgbouncer dir>"
usage() {
echo $USAGE
exit 1
}
PGDIR=$1
[ -z "$PGDIR" ] && usage
PATCHDIR=$(pwd)
patchstatus=0
# Patch each modified file
MERGEFILES="\
Makefile\
src/client.c\
src/main.c\
include/bouncer.h\
include/janitor.h\
include/loader.h\
include/objects.h\
include/pktbuf.h\
include/util.h\
src/admin.c\
src/janitor.c\
src/loader.c\
src/objects.c\
src/pktbuf.c\
src/server.c\
src/util.c\
doc/config.md\
"
for file in $MERGEFILES
do
echo Merging pgbouncer-rr changes to: $PGDIR/$file
patch -d $PGDIR -f -b -p1 < $PATCHDIR/$file.diff || patchstatus=1
done
# copy pgbouncer-rr source files
mkdir -p $PGDIR/images
NEWFILES="\
README.md\
LICENSE.txt\
NOTICE.txt\
pgbouncer-example.ini\
users.txt\
rewrite_query.py\
routing_rules.py\
images/diagram1.jpg\
images/diagram2-routing.jpg\
images/diagram3-rewrite.jpg\
src/pycall.c\
src/rewrite_query.c\
src/route_connection.c\
include/pycall.h\
include/rewrite_query.h\
include/route_connection.h\
"
echo -n "copying pgbouncer-rr files: "
for file in $NEWFILES
do
echo -n "$file "
cp $PATCHDIR/$file $PGDIR/$file || patchstatus=1
done
echo
if [ $patchstatus -eq 1 ]; then
echo "Failures encountered during merge of pgbouncer-rr with pgbouncer."
echo "See error messages above."
echo "Possible causes: "
echo " pgbouncer-rr-patch already installed in target directory?"
echo " new version of pgbouncer with changed source files that can't be patched?"
echo " - last tested with pgbouncer v1.19 (September 2023)"
echo " - Try getting pgbouncer with: git clone https://github.com/pgbouncer/pgbouncer.git --branch \"stable-1.19\""
echo "Status: pgbouncer-rr-patch merge FAILED"
else
echo "Status: pgbouncer-rr-patch merge SUCEEDED"
fi
exit $patchstatus