From: Eric Bollengier Date: Sun, 31 Aug 2008 20:35:40 +0000 (+0000) Subject: ebl Add the -B option that extract Catalog configuration from X-Git-Tag: Release-3.0.0~1037 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=8fc14a69f0caa1820e4f24b1e7fb4d822759a60d;p=bacula%2Fbacula ebl Add the -B option that extract Catalog configuration from bacula-dir.conf to dbcheck instead of bacula-dir. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7536 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/patches/testing/bacula-dir-B.patch b/bacula/patches/testing/bacula-dir-B.patch deleted file mode 100644 index 0d7df8e67a..0000000000 --- a/bacula/patches/testing/bacula-dir-B.patch +++ /dev/null @@ -1,124 +0,0 @@ -Index: src/dird/dird.c -=================================================================== ---- src/dird/dird.c (révision 7482) -+++ src/dird/dird.c (copie de travail) -@@ -40,7 +40,7 @@ - /* Forward referenced subroutines */ - void terminate_dird(int sig); - static bool check_resources(); --static bool check_catalog(); -+static bool check_catalog(bool printit=false); - static void dir_sql_query(JCR *jcr, const char *cmd); - - /* Exported subroutines */ -@@ -99,6 +99,7 @@ - " -r run now\n" - " -s no signals\n" - " -t test - read configuration and exit\n" -+" -B print catalog configuration and exit\n" - " -u userid\n" - " -v verbose user messages\n" - " -? print this message.\n" -@@ -124,6 +125,7 @@ - JCR *jcr; - bool no_signals = false; - bool test_config = false; -+ bool print_catalog = false; - char *uid = NULL; - char *gid = NULL; - -@@ -140,7 +142,7 @@ - - console_command = run_console_command; - -- while ((ch = getopt(argc, argv, "c:d:fg:r:stu:v?")) != -1) { -+ while ((ch = getopt(argc, argv, "c:d:fg:r:stu:vB?")) != -1) { - switch (ch) { - case 'c': /* specify config file */ - if (configfile != NULL) { -@@ -186,6 +188,11 @@ - test_config = true; - break; - -+ case 'B': /* print catalog config */ -+ test_config = true; -+ print_catalog = true; -+ break; -+ - case 'u': /* set uid */ - uid = optarg; - break; -@@ -249,7 +256,7 @@ - - drop(uid, gid); /* reduce privileges if requested */ - -- if (!check_catalog()) { -+ if (!check_catalog(print_catalog)) { - Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile); - } - -@@ -876,7 +883,7 @@ - return OK; - } - --static bool check_catalog() -+static bool check_catalog(bool printit) - { - bool OK = true; - bool need_tls; -@@ -907,6 +914,18 @@ - continue; - } - -+ if (printit) { /* print catalog information for scripting purpose */ -+ fprintf(stdout, -+ "catalog=%s\ndb_type=%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", -+ catalog->name(), db_get_type(), NPRTB(catalog->db_name), -+ NPRTB(catalog->db_driver), -+ NPRTB(catalog->db_user), NPRTB(catalog->db_password), -+ NPRTB(catalog->db_address), catalog->db_port, -+ NPRTB(catalog->db_socket)); -+ } -+ - /* Loop over all pools, defining/updating them in each database */ - POOL *pool; - foreach_res(pool, R_POOL) { -Index: src/cats/sqlite.c -=================================================================== ---- src/cats/sqlite.c (révision 7482) -+++ src/cats/sqlite.c (copie de travail) -@@ -59,14 +59,17 @@ - - int QueryDB(const char *file, int line, JCR *jcr, B_DB *db, char *select_cmd); - -- - /* - * Retrieve database type - */ - const char * - db_get_type(void) - { -+#ifdef HAVE_SQLITE3 -+ return "SQLite3"; -+#else - return "SQLite"; -+#endif - } - - /* -Index: src/baconfig.h -=================================================================== ---- src/baconfig.h (révision 7482) -+++ src/baconfig.h (copie de travail) -@@ -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/patches/testing/dbcheck-B.patch b/bacula/patches/testing/dbcheck-B.patch new file mode 100644 index 0000000000..2b92b38251 --- /dev/null +++ b/bacula/patches/testing/dbcheck-B.patch @@ -0,0 +1,107 @@ +Index: src/dird/dird_conf.c +=================================================================== +--- src/dird/dird_conf.c (révision 7525) ++++ src/dird/dird_conf.c (copie de travail) +@@ -509,6 +509,16 @@ + {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; +Index: src/dird/dird_conf.h +=================================================================== +--- src/dird/dird_conf.h (révision 7525) ++++ src/dird/dird_conf.h (copie de travail) +@@ -236,6 +236,7 @@ + + /* Methods */ + char *name() const; ++ char *display(POOLMEM *dst); /* Get catalog information */ + }; + + inline char *CAT::name() const { return hdr.name; } +Index: src/baconfig.h +=================================================================== +--- src/baconfig.h (révision 7525) ++++ src/baconfig.h (copie de travail) +@@ -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 +Index: src/tools/dbcheck.c +=================================================================== +--- src/tools/dbcheck.c (révision 7525) ++++ src/tools/dbcheck.c (copie de travail) +@@ -100,14 +100,14 @@ + static void do_interactive_mode(); + static bool yes_no(const char *prompt); + +- + 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" +@@ -121,6 +121,7 @@ + int ch; + const char *user, *password, *db_name, *dbhost; + int dbport = 0; ++ bool print_catalog=false; + char *configfile = NULL; + char *catalogname = NULL; + char *endptr; +@@ -136,8 +137,12 @@ + 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; +@@ -215,6 +220,16 @@ + 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;