Subject: Confusing message on server install

From: Alexander Lakhin <[email-masked]>
Date: Fri, 18 Oct 2019 13:19:59 +0300

Hello,

While installing the postgresql-12 server package on Debian Buster I see
the following output:
# apt-get install postgresql-12
...
Creating new PostgreSQL cluster 12/main ...
/usr/lib/postgresql/12/bin/initdb -D /var/lib/postgresql/12/main
--auth-local peer --auth-host md5
...
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

Success. You can now start the database server using:

    pg_ctlcluster 12 main start

Ver Cluster Port Status Owner    Data directory              Log file
12  main    5432 down   postgres /var/lib/postgresql/12/main
/var/log/postgresql/postgresql-12-main.log
update-alternatives: using
/usr/share/postgresql/12/man/man1/postmaster.1.gz to provide
/usr/share/man/man1/postmaster.1.gz (postmaster.1.gz) in auto mode
Processing triggers for systemd (241-5) ...
Processing triggers for man-db (2.8.5-2) ...
Processing triggers for libc-bin (2.28-10) ...
root@debian10:/home/test# pg_ctlcluster 12 main status
pg_ctl: server is running (PID: 2733)
/usr/lib/postgresql/12/bin/postgres "-D" "/var/lib/postgresql/12/main"
"-c" "config_file=/etc/postgresql/12/main/postgresql.conf"

So I see the message "Success. You can now start the database server
using:", but in fact the server is running.

---

From: Alexander Lakhin <[email-masked]>
Date: Tue, 29 Oct 2019 10:00:00 +0300

Hello,

> using:", but in fact the server is running.
Please look at the proposed improvement that suppresses this confusing
message.

Best regards,
Alexander
--- a/pg_createcluster	2019-07-09 16:57:45.000000000 +0300
+++ b/pg_createcluster	2019-10-29 06:16:00.935081461 +0300
@@ -351,7 +351,9 @@
 } else {
     print "Creating new PostgreSQL cluster $version/$cluster ...\n";
     # ask initdb to print a different cluster start command (Debian patch)
-    $ENV{CLUSTER_START_COMMAND} = "pg_ctlcluster $version $cluster start";
+    if (!defined $ENV{CLUSTER_START_COMMAND}) {
+        $ENV{CLUSTER_START_COMMAND} = "pg_ctlcluster $version $cluster start";
+    }
     init_db $version, $datadir, $owneruid, $ownergid, \@initdb_opts_from_cli;
     $newcluster = 1;
 }
--- a/maintscripts-functions	2018-09-20 17:02:06.000000000 +0300
+++ b/maintscripts-functions	2019-10-29 07:41:55.892583740 +0300
@@ -86,6 +86,7 @@
         create=$(pg_conftool /etc/postgresql-common/createcluster.conf show -bs create_main_cluster || :)
         if [ -z "$2" ] && [ "$create" != "off" ]; then
             set_system_locale
+            export CLUSTER_START_COMMAND=""
             pg_createcluster -u postgres $VERSION main ||
                 echo "Error: could not create default cluster. Please create it manually with
 
Author: Christoph Berg <[email-masked]>
Description: Debian-specific cluster startup message from initdb
Forwarded: No, Debian specific

--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -3361,9 +3361,10 @@
 	/* translator: This is a placeholder in a shell command. */
 	appendPQExpBuffer(start_db_cmd, " -l %s start", _("logfile"));
 
-	printf(_("\nSuccess. You can now start the database server using:\n\n"
+	if (!getenv("CLUSTER_START_COMMAND") || strlen(getenv("CLUSTER_START_COMMAND")) > 0)
+		printf(_("\nSuccess. You can now start the database server using:\n\n"
 			 "    %s\n\n"),
-		   start_db_cmd->data);
+			   getenv("CLUSTER_START_COMMAND") ? getenv("CLUSTER_START_COMMAND") : start_db_cmd->data);
 
 	destroyPQExpBuffer(start_db_cmd);