community/pgbouncer: init script issues
A) The get_config
function references $conffile
but should actually be $cfgfile
B) Since postgresql & pgbouncer share the same socket dir by default, I'm proposing some changes so they don't fight over it's permissions and ownership.
- Change the mode from 0755 to 1775 like the postgresql init script
- Default the group to
postgres
instead ofpostgresql
- Add
socket_dir_user
&socket_dir_group
variables for cases where users run postgresql with a non-default user/group
--- /etc/init.d/pgbouncer-old 2023-09-26 19:55:25.610984470 +0000
+++ /etc/init.d/pgbouncer 2023-09-26 19:57:47.750796278 +0000
@@ -3,7 +3,9 @@
extra_started_commands="reload"
: ${user:="pgbouncer"}
-: ${group:="postgresql"}
+: ${group:="postgres"}
+: ${socket_dir_user:="postgres"}
+: ${socket_dir_group:="postgres"}
: ${cfgfile:="/etc/pgbouncer/pgbouncer.ini"}
: ${nice_timeout:=60}
: ${force_quit:="no"}
@@ -29,7 +31,7 @@
start_pre() {
local socket_dir=$(get_config unix_socket_dir)
if [ -n "$socket_dir" ]; then
- checkpath -d -m 0755 -o postgres:postgres "$socket_dir" || return 1
+ checkpath -d -m 1775 -o $socket_dir_user:$socket_dir_group "$socket_dir" || return 1
fi
local logfile="$(get_config logfile)"
@@ -78,7 +80,7 @@
local name="$1"
local default="${2:-}"
- if [ ! -f "$conffile" ]; then
+ if [ ! -f "$cfgfile" ]; then
printf '%s\n' "$default"
return 1
fi
@@ -87,6 +89,6 @@
s/\s*$//; # trim trailing whitespaces
s/^['\"](.*)['\"]$/\1/; # remove delimiting quotes
p
- }" "$conffile" \
+ }" "$cfgfile" \
| grep . || printf '%s\n' "$default"
}
Edited by Matt Adams