summaryrefslogtreecommitdiffstats
path: root/share/postgresql-setup/library.sh.in
diff options
context:
space:
mode:
Diffstat (limited to 'share/postgresql-setup/library.sh.in')
-rw-r--r--share/postgresql-setup/library.sh.in20
1 files changed, 19 insertions, 1 deletions
diff --git a/share/postgresql-setup/library.sh.in b/share/postgresql-setup/library.sh.in
index fe38f6c..cfbf213 100644
--- a/share/postgresql-setup/library.sh.in
+++ b/share/postgresql-setup/library.sh.in
@@ -71,7 +71,7 @@ parse_upgrade_setup()
test -d "$upgrade_confdir" || die "can't read confdir $upgrade_confdir"
local my_vars="id comment data_default engine description major scls \
- redhat_sockets_hack"
+ redhat_sockets_hack pghost_override"
while read conffile
do
read_config_file "$conffile" "$my_vars"
@@ -119,3 +119,21 @@ parse_upgrade_setup()
}
+# run_cmd_as_dbadmin COMMAND STDOUT STDERR
+run_cmd_as_dbadmin()
+{
+ # Convenient tool-aliases
+ local SU_POSTGRES="@SU_POSTGRES@"
+
+ local cmd="@SCL_SOURCE@$1"
+ local stdout="$2" stderr="$3"
+
+ # don't print additional spaces
+ set -- $cmd
+ debug "running command under postgres user: $@"
+ (
+ test -n "$stdout" && exec >>"$stdout"
+ test -n "$stderr" && exec 2>>"$stderr"
+ $SU_POSTGRES -c "$cmd" < /dev/null
+ )
+}