diff --git a/Makefile.in b/Makefile.in index d56721c7..4527f45f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -28,7 +28,7 @@ $(info Building against PostgreSQL $(MAJORVERSION)) REPMGR_CLIENT_OBJS = repmgr-client.o repmgr-action-master.o repmgr-action-standby.o repmgr-action-cluster.o \ config.o log.o strutil.o dbutils.o dirutil.o compat.o controldata.o -REPMGRD_OBJS = repmgrd.o +REPMGRD_OBJS = repmgrd.o config.o log.o dbutils.o strutil.o $(REPMGR_CLIENT_OBJS): repmgr-client.h diff --git a/repmgr-client.c b/repmgr-client.c index 366c0a75..8345bc16 100644 --- a/repmgr-client.c +++ b/repmgr-client.c @@ -1194,7 +1194,9 @@ do_help(void) printf(_("General options:\n")); printf(_(" -?, --help show this help, then exit\n")); printf(_(" -V, --version output version information, then exit\n")); + puts(""); + printf(_("General configuration options:\n")); printf(_(" -b, --pg_bindir=PATH path to PostgreSQL binaries (optional)\n")); printf(_(" -f, --config-file=PATH path to the repmgr configuration file\n")); diff --git a/repmgrd.c b/repmgrd.c index a9b1b11b..a8caad2e 100644 --- a/repmgrd.c +++ b/repmgrd.c @@ -5,12 +5,61 @@ */ #include "repmgr.h" +#include "config.h" #include +static void do_help(void); + int main(int argc, char **argv) { - puts("repmgr"); + /* Disallow running as root to prevent directory ownership problems */ + if (geteuid() == 0) + { + fprintf(stderr, + _("%s: cannot be run as root\n" + "Please log in (using, e.g., \"su\") as the " + "(unprivileged) user that owns " + "the data directory.\n" + ), + progname()); + exit(1); + } + + do_help(); return 0; } + +void +do_help(void) +{ + printf(_("%s: replication management daemon for PostgreSQL\n"), progname()); + puts(""); + + printf(_("Usage:\n")); + printf(_(" %s [OPTIONS]\n"), progname()); + printf(_("\n")); + printf(_("Options:\n")); + puts(""); + + printf(_("General options:\n")); + printf(_(" -?, --help show this help, then exit\n")); + printf(_(" -V, --version output version information, then exit\n")); + + puts(""); + + printf(_("General configuration options:\n")); + printf(_(" -v, --verbose output verbose activity information\n")); + printf(_(" -f, --config-file=PATH path to the configuration file\n")); + + puts(""); + + printf(_("General configuration options:\n")); + printf(_(" -d, --daemonize detach process from foreground\n")); + printf(_(" -p, --pid-file=PATH write a PID file\n")); + puts(""); + + printf(_("%s monitors a cluster of servers and optionally performs failover.\n"), progname()); +} +