From: Eric Bollengier Date: Thu, 25 Sep 2008 21:09:42 +0000 (+0000) Subject: ebl Add -B option to dbcheck to get catalog information X-Git-Tag: Release-3.0.0~932 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=3cdcc3f38f358ce5c737a176321c20b3d1f75e31;p=bacula%2Fbacula ebl Add -B option to dbcheck to get catalog information git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7648 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/baconfig.h b/bacula/src/baconfig.h index 53de5b4028..ffd3562d04 100644 --- a/bacula/src/baconfig.h +++ b/bacula/src/baconfig.h @@ -79,7 +79,8 @@ /* Allow printing of NULL pointers */ #define NPRT(x) (x)?(x):_("*None*") - +#define NPRTB(x) (x)?(x):"" + #if defined(HAVE_WIN32) #define WIN32_REPARSE_POINT 1 diff --git a/bacula/src/dird/dird_conf.c b/bacula/src/dird/dird_conf.c index 5f4a570a13..e4ed00a022 100644 --- a/bacula/src/dird/dird_conf.c +++ b/bacula/src/dird/dird_conf.c @@ -507,6 +507,16 @@ struct s_kw ReplaceOptions[] = { {NULL, 0} }; +char *CAT::display(POOLMEM *dst) { + Mmsg(dst,"catalog=%s\ndb_name=%s\ndb_driver=%s\ndb_user=%s\n" + "db_password=%s\ndb_address=%s\ndb_port=%i\n" + "db_socket=%s\n", + name(), NPRTB(db_name), + NPRTB(db_driver), NPRTB(db_user), NPRTB(db_password), + NPRTB(db_address), db_port, NPRTB(db_socket)); + return dst; +} + const char *level_to_str(int level) { int i; diff --git a/bacula/src/dird/dird_conf.h b/bacula/src/dird/dird_conf.h index d33a1156f4..9a3fabbe91 100644 --- a/bacula/src/dird/dird_conf.h +++ b/bacula/src/dird/dird_conf.h @@ -236,6 +236,7 @@ public: /* Methods */ char *name() const; + char *display(POOLMEM *dst); /* Get catalog information */ }; inline char *CAT::name() const { return hdr.name; } diff --git a/bacula/src/tools/dbcheck.c b/bacula/src/tools/dbcheck.c index 2c13325892..45072dda56 100644 --- a/bacula/src/tools/dbcheck.c +++ b/bacula/src/tools/dbcheck.c @@ -109,14 +109,14 @@ static int check_idx_handler(void *ctx, int num_fields, char **row); /* Global variables */ static const char *idx_tmp_name; - static void usage() { fprintf(stderr, -"Usage: dbcheck [-c config] [-C catalog name] [-d debug_level] [] []\n" +"Usage: dbcheck [-c config ] [-B] [-C catalog name] [-d debug_level] [] []\n" " -b batch mode\n" " -C catalog name in the director conf file\n" " -c Director conf filename\n" +" -B print catalog configuration and exit\n" " -d set debug level to \n" " -dt print timestamp in debug output\n" " -f fix inconsistencies\n" @@ -130,6 +130,7 @@ int main (int argc, char *argv[]) int ch; const char *user, *password, *db_name, *dbhost; int dbport = 0; + bool print_catalog=false; char *configfile = NULL; char *catalogname = NULL; char *endptr; @@ -144,8 +145,12 @@ int main (int argc, char *argv[]) memset(&id_list, 0, sizeof(id_list)); memset(&name_list, 0, sizeof(name_list)); - while ((ch = getopt(argc, argv, "bc:C:d:fv?")) != -1) { + while ((ch = getopt(argc, argv, "bc:C:d:fvB?")) != -1) { switch (ch) { + case 'B': + print_catalog = true; /* get catalog information from config */ + break; + case 'b': /* batch */ batch = true; break; @@ -223,6 +228,16 @@ int main (int argc, char *argv[]) exit(1); } set_working_directory(director->working_directory); + + /* Print catalog information and exit (-B) */ + if (print_catalog) { + POOLMEM *buf = get_pool_memory(PM_MESSAGE); + printf("%sdb_type=%s\nworking_dir=%s\n", catalog->display(buf), + db_get_type(), working_directory); + free_pool_memory(buf); + exit(0); + } + db_name = catalog->db_name; user = catalog->db_user; password = catalog->db_password; diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index 241f5eb79b..bdb8357ee5 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -19,6 +19,7 @@ remove reader/writer in FOPTS???? General: 25Sep08 +ebl Add -B option to dbcheck to get catalog information kes Fix Win32 build to include new library function. kes Remove some old reader/writer code. kes Implement ./configure --with-plugindir=xxx