From e8bc5521a542981aeeba2152bbc03951a8a4483f Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Wed, 24 Dec 2014 19:07:08 +0900 Subject: [PATCH] Add option "--initdb-no-pwprompt" Previously repmgr passed the -W flag to initdb, which forced manual input of a password; this option removes the -W flag to make repetitive testing easier. Conflicts: repmgr.c repmgr.h --- HISTORY | 2 +- repmgr.c | 11 ++++++++--- repmgr.h | 3 ++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/HISTORY b/HISTORY index e42067ef..eca77aeb 100644 --- a/HISTORY +++ b/HISTORY @@ -1,7 +1,7 @@ 2.0.3 2015-??-?? - Add option "--initdb-no-pwprompt" (Ian) Add -S/--superuser option for witness database creation Ian) Add -X/--fast-checkpoint option for cloning (Christoph) + Add option "--initdb-no-pwprompt" (Ian) 2.0.2 2015-02-17 Add "--checksum" in rsync when using "--force" (Jaime) diff --git a/repmgr.c b/repmgr.c index 4efe1874..5da74658 100644 --- a/repmgr.c +++ b/repmgr.c @@ -112,6 +112,7 @@ main(int argc, char **argv) {"ignore-rsync-warning", no_argument, NULL, 'I'}, {"verbose", no_argument, NULL, 'v'}, {"fast-checkpoint", no_argument, NULL, 'X'}, + {"initdb-no-pwprompt", no_argument, NULL, 1}, {NULL, 0, NULL, 0} }; @@ -194,6 +195,8 @@ main(int argc, char **argv) break; case 'X': runtime_options.fast_checkpoint = true; + case 1: + runtime_options.initdb_no_pwprompt = true; break; default: usage(); @@ -1719,8 +1722,10 @@ do_witness_create(void) if (!runtime_options.superuser[0]) strncpy(runtime_options.superuser, "postgres", MAXLEN); - sprintf(script, "%s/pg_ctl %s -D %s init -o \"-W -U %s\"", options.pg_bindir, - options.pgctl_options, runtime_options.dest_dir, runtime_options.superuser); + sprintf(script, "%s/pg_ctl %s -D %s init -o \"%s-U %s\"", options.pg_bindir, + options.pgctl_options, runtime_options.dest_dir, + runtime_options.initdb_no_pwprompt ? "" : "-W ", + runtime_options.superuser); log_info("Initialize cluster for witness: %s.\n", script); r = system(script); @@ -1959,7 +1964,7 @@ help(const char *progname) " to happen\n")); printf(_(" -W, --wait wait for a master to appear\n")); printf(_(" -X, --fast-checkpoint force immediate checkpoint when cloning\n")); - + printf(_(" --initdb-no-pwprompt don't require superuser password when running initdb\n")); printf(_("\n%s performs some tasks like clone a node, promote it or making follow\n"), progname); printf(_("another node and then exits.\n\n")); printf(_("COMMANDS:\n")); diff --git a/repmgr.h b/repmgr.h index b57fb315..bc2882b7 100644 --- a/repmgr.h +++ b/repmgr.h @@ -62,6 +62,7 @@ typedef struct bool force; bool wait_for_master; bool ignore_rsync_warn; + bool initdb_no_pwprompt; bool fast_checkpoint; char masterport[MAXLEN]; @@ -71,6 +72,6 @@ typedef struct int keep_history; } t_runtime_options; -#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, "", "", 0} +#define T_RUNTIME_OPTIONS_INITIALIZER { "", "", "", "", "", "", "", DEFAULT_WAL_KEEP_SEGMENTS, false, false, false, false, false, false, "", "", 0} #endif