]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/dird.c
New var.c file + implement multiple simultaneous jobs
[bacula/bacula] / bacula / src / dird / dird.c
index aafc5a72bf4a46d48f78f9a18594ad12cee25057..029ca2b26181aaf713b81035bb3274820457399c 100644 (file)
@@ -183,7 +183,7 @@ int main (int argc, char *argv[])
    parse_config(configfile);
 
    if (!check_resources()) {
-      Jmsg(NULL, M_ERROR_TERM, 0, "Please correct configuration file: %s\n", configfile);
+      Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile);
    }
 
    if (test_config) {
@@ -291,7 +291,7 @@ static void reload_config(int sig)
    }
 
    /* Reset globals */
-   working_directory = director->working_directory;
+   set_working_directory(director->working_directory);
    FDConnectTimeout = director->FDConnectTimeout;
    SDConnectTimeout = director->SDConnectTimeout;
  
@@ -322,11 +322,7 @@ static int check_resources()
 Without that I don't know who I am :-(\n"), configfile);
       OK = FALSE;
    } else {
-      if (!director->working_directory) {
-         Jmsg(NULL, M_FATAL, 0, _("No working directory specified. Cannot continue.\n"));
-        OK = FALSE;
-      }       
-      working_directory = director->working_directory;
+      set_working_directory(director->working_directory);
       if (!director->messages) {       /* If message resource not specified */
         director->messages = (MSGS *)GetNextRes(R_MSGS, NULL);
         if (!director->messages) {
@@ -374,13 +370,34 @@ Without that I don't know who I am :-(\n"), configfile);
                            catalog->db_password, catalog->db_address,
                            catalog->db_port, catalog->db_socket);
         if (!db_open_database(NULL, db)) {
-            Jmsg(NULL, M_FATAL,  0, "%s", db_strerror(db));
+            Jmsg(NULL, M_FATAL, 0, _("Could not open %s database \"%s\".\n"),
+                catalog_db, catalog->db_name);
+           OK = FALSE;
         } else {
            /* If a pool is defined for this job, create the pool DB       
             *  record if it is not already created. 
             */
            if (job->pool) {
-              create_pool(NULL, db, job->pool, 0);  /* update request */
+              create_pool(NULL, db, job->pool, POOL_OP_UPDATE);  /* update request */
+           }
+           /* Set default value in all counters */
+           for (COUNTER *counter=NULL; (counter = (COUNTER *)GetNextRes(R_COUNTER, (RES *)counter)); ) {
+              /* Write to catalog? */
+              if (!counter->created && counter->Catalog == catalog) {
+                 COUNTER_DBR cr;
+                 bstrncpy(cr.Counter, counter->hdr.name, sizeof(cr.Counter));
+                 cr.MinValue = counter->MinValue;
+                 cr.MaxValue = counter->MaxValue;
+                 cr.CurrentValue = counter->MinValue;
+                 bstrncpy(cr.WrapCounter, counter->WrapCounter->hdr.name, sizeof(cr.WrapCounter));
+                 if (db_create_counter_record(NULL, db, &cr)) {
+                    counter->CurrentValue = cr.CurrentValue;
+                    counter->created = true;
+//                   Dmsg2(000, "Create counter %s val=%d\n", counter->hdr.name, counter->CurrentValue);
+                 }
+              } else {
+                 counter->CurrentValue = counter->MinValue;  /* default value */
+              }
            }
            db_close_database(NULL, db);
         }