tech-pkg archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

rc.d/pgsql script

I have never had to use the pgsql_flags variable in /etc/rc.conf until
recently and am now running into several problems.

- initdb takes different arguments than postgres, whereas the
  rc.d/pgsql script uses the contents of pgsql_flags for both.  This
  means that some options, e.g., setting ports with the -p option, will
  not work when passed to initdb.  It seems that there should be
  separate *_flags variables for the two programs.

- The number of backslashes used to quote the -o option appears
  incorrect.  As a result, pg_ctl complains while parsing the command

I believe that the patch below fixes both of these issues.  At least, I
have been able to run the script successfully when the following is set:

        pgsql_flags="-p 5433"

This same setup fails with the script shipped with pkgsrc.  Before I
commit the patch below I would appreciate someone looking at this to
confirm my thoughts.

Thanks a lot.


--- /etc/rc.d/pgsql.orig        2012-02-16 03:10:54.000000000 +0000
+++ /etc/rc.d/pgsql     2012-02-16 03:10:54.000000000 +0000
@@ -12,11 +12,15 @@
 # pgsql=YES
-# Optionally, "pgsql_flags" contains options for the PostgreSQL postmaster, 
+# Options for the PostgreSQL database server:
+#   common options:
+#      pgsql_home="/path/to/home"      # path to pgsql database directory
+#   options specific to postgres(1):
 #      pgsql_flags="-i"                # allows TCP/IP connections
 #      pgsql_flags="-i -l"             # enables SSL connections
-#      pgsql_home="/path/to/home"      # path to pgsql database directory
-# See postmaster(1) for possible options.
+#   options specific to initdb(1):
+#      pgsql_initdb_flags="-E encoding"        # set the default encoding
+# See postgres(1) and initdb(1) for other possible options.
 if [ -f /etc/rc.subr ]; then
        . /etc/rc.subr
@@ -45,9 +49,13 @@
        . /etc/rc.conf
+initdb_args="-s -D ${pgsql_home}/data"
+if [ -n "${pgsql_initdb_flags}" ]; then
+       initdb_args="${initdb_args} -o \"${pgsql_initdb_flags}\""
 command_args="-w -s -D ${pgsql_home}/data -m fast -l ${pgsql_home}/errlog"
 if [ -n "${pgsql_flags}" ]; then
-       command_args="${command_args} -o \\\"${pgsql_flags}\\\""
+       command_args="${command_args} -o \"${pgsql_flags}\""
@@ -69,7 +77,7 @@
                /usr/sbin/chown ${pgsql_user} ${pgsql_home}
                /usr/bin/chgrp ${pgsql_group} ${pgsql_home}
                /bin/chmod 0700 ${pgsql_home}
-               doit="/usr/bin/su -m ${pgsql_user} -c '${command} init 
+               doit="/usr/bin/su -m ${pgsql_user} -c '${command} init 
                eval $doit

Home | Main Index | Thread Index | Old Index