diff options
author | Koichi Suzuki | 2013-02-01 07:25:38 +0000 |
---|---|---|
committer | Koichi Suzuki | 2013-02-01 07:25:38 +0000 |
commit | 7d7bc1351125cf43568990b19d1b41e57949e87f (patch) | |
tree | 888170df0ebba27b4583c890ad1d5a3101c8091e | |
parent | 7b36cbedc3e4f587e784de481f409b91da15ef1d (diff) |
Nikhil Sontakke kindly provided this to fix gtm_ctl dependency
on PATH environment, the bug 3602944.
modified: src/bin/gtm_ctl/gtm_ctl.c
modified: src/gtm/main/main.c
modified: src/gtm/proxy/proxy_main.c
-rw-r--r-- | src/bin/gtm_ctl/gtm_ctl.c | 45 | ||||
-rw-r--r-- | src/gtm/main/main.c | 6 | ||||
-rw-r--r-- | src/gtm/proxy/proxy_main.c | 6 |
3 files changed, 57 insertions, 0 deletions
diff --git a/src/bin/gtm_ctl/gtm_ctl.c b/src/bin/gtm_ctl/gtm_ctl.c index 2bc60d43d6..1aa5622f16 100644 --- a/src/bin/gtm_ctl/gtm_ctl.c +++ b/src/bin/gtm_ctl/gtm_ctl.c @@ -480,6 +480,45 @@ do_start(void) read_gtm_opts(); + /* The binary for both gtm and gtm_standby is the same */ + if (strcmp(gtm_app, "gtm_standby") == 0) + gtm_app = "gtm"; + + if (gtm_path == NULL) + { + int ret; + char *found_path; + char version_str[MAXPGPATH]; + + found_path = pg_malloc(MAXPGPATH); + sprintf(version_str, "%s (Postgres-XC) %s\n", gtm_app, PGXC_VERSION); + + if ((ret = find_other_exec(argv0, gtm_app, version_str, found_path)) < 0) + { + char full_path[MAXPGPATH]; + + if (find_my_exec(argv0, full_path) < 0) + strlcpy(full_path, progname, sizeof(full_path)); + + if (ret == -1) + write_stderr(_("The program \"%s\" is needed by gtm_ctl " + "but was not found in the\n" + "same directory as \"%s\".\n" + "Check your installation.\n"), + gtm_app, full_path); + else + write_stderr(_("The program \"%s\" was found by \"%s\"\n" + "but was not the same version as gtm_ctl.\n" + "Check your installation.\n"), + gtm_app, full_path); + exit(1); + } + + *last_dir_separator(found_path) = '\0'; + + gtm_path = found_path; + } + exitcode = start_gtm(); if (exitcode != 0) { @@ -923,6 +962,7 @@ do_help(void) printf(_(" -t SECS seconds to wait when using -w option\n")); printf(_(" -w wait until operation completes\n")); printf(_(" -W do not wait until operation completes\n")); + printf(_(" -V, --version output version information, then exit\n")); printf(_(" --help show this help, then exit\n")); printf(_("(The default is to wait for shutdown, but not for start or restart.)\n\n")); @@ -997,6 +1037,11 @@ main(int argc, char **argv) do_help(); exit(0); } + if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) + { + puts("gtm_ctl (Postgres-XC) " PGXC_VERSION); + exit(0); + } } /* diff --git a/src/gtm/main/main.c b/src/gtm/main/main.c index e6f6ac46bd..e03738725c 100644 --- a/src/gtm/main/main.c +++ b/src/gtm/main/main.c @@ -264,6 +264,7 @@ help(const char *progname) printf(_(" -D directory GTM working directory\n")); printf(_(" -l filename GTM server log file name \n")); printf(_(" -c show server status, then exit\n")); + printf(_(" -V, --version output version information, then exit\n")); printf(_(" --help show this help, then exit\n")); printf(_("\n")); printf(_("Options for Standby mode:\n")); @@ -338,6 +339,11 @@ main(int argc, char *argv[]) help(argv[0]); exit(0); } + if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) + { + puts("gtm (Postgres-XC) " PGXC_VERSION); + exit(0); + } } ListenAddresses = strdup(GTM_DEFAULT_HOSTNAME); diff --git a/src/gtm/proxy/proxy_main.c b/src/gtm/proxy/proxy_main.c index 262d71d16d..0285f26d40 100644 --- a/src/gtm/proxy/proxy_main.c +++ b/src/gtm/proxy/proxy_main.c @@ -549,6 +549,7 @@ help(const char *progname) printf(_(" -n count Number of worker threads\n")); printf(_(" -D directory GTM proxy working directory\n")); printf(_(" -l filename GTM proxy log file name \n")); + printf(_(" -V, --version output version information, then exit\n")); printf(_(" --help show this help, then exit\n")); } @@ -589,6 +590,11 @@ main(int argc, char *argv[]) help(argv[0]); exit(0); } + if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0) + { + puts("gtm_proxy (Postgres-XC) " PGXC_VERSION); + exit(0); + } } ListenAddresses = strdup(GTM_PROXY_DEFAULT_HOSTNAME); |