Ignore:
Timestamp:
Aug 26, 2007, 12:26:06 PM (13 years ago)
Author:
Bruno Cornec
Message:

Use of conf file entries (iso_burning_*, media_device, media_size)
and adapatation of the rest of the code to that (including bkpinfo)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/mondoarchive/mondoarchive.c

    r1592 r1594  
    9696    mr_msg(7, "Seven...");
    9797    mr_msg(8, "Eight...");
    98     printf("See %s for details of backup run.\n", MONDO_LOGFILE);
     98    printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
    9999}
    100100
     
    133133}
    134134
     135/* reset/empty the mr_ar_conf structure from mondo's conf file */
     136static void mr_ar_reset_conf(struct mr_ar_conf *mr_cnf) {
     137
     138    /* This should correspond to the default conf file */
     139    /* Especially for boolean values */
     140    mr_cnf->iso_creation_cmd = NULL;
     141    mr_cnf->iso_creation_opt = NULL;
     142    mr_cnf->iso_burning_cmd = NULL;
     143    mr_cnf->iso_burning_opt = NULL;
     144    mr_cnf->iso_burning_dev = NULL;
     145    mr_cnf->iso_burning_speed = 0;
     146    mr_cnf->media_size = 0;
     147    mr_cnf->media_device = NULL;
     148    mr_cnf->iso_burning_dev = NULL;
     149    mr_cnf->manual_tray = FALSE;
     150    mr_cnf->log_level = 0;
     151    mr_cnf->prefix = NULL;
     152    mr_cnf->external_tape_blocksize = 0;
     153    mr_cnf->internal_tape_blocksize = 0;
     154    mr_cnf->slice_size = 0;
     155    mr_cnf->deplist_file = NULL;
     156    mr_cnf->create_mindi_cd = FALSE;
     157    mr_cnf->kernel = NULL;
     158    mr_cnf->additional_modules = NULL;
     159    mr_cnf->boot_loader = NULL;
     160    mr_cnf->differential = FALSE;
     161    mr_cnf->compression_tool = NULL;
     162    mr_cnf->compression_level = 0;
     163    mr_cnf->exclude_paths = NULL;
     164    mr_cnf->include_paths = NULL;
     165    mr_cnf->ui_mode = NULL;
     166    mr_cnf->automatic_restore = FALSE;
     167    mr_cnf->scratch_dir = NULL;
     168    mr_cnf->tmp_dir = NULL;
     169    mr_cnf->images_dir = NULL;
     170}
     171
    135172/* fill the mr_ar_conf structure from mindi's conf file */
    136173static void mr_ar_store_conf_mindi(struct mr_ar_conf *mr_cnf) {
     
    153190    char *p = NULL;
    154191
    155     mr_asprintf(&p, mr_conf_sread("mondo_iso_burning_cmd"));
    156     mr_cnf->iso_burning_cmd = p;
    157     p = NULL;
    158 
    159     mr_asprintf(&p, mr_conf_sread("mondo_iso_burning_opt"));
    160     mr_cnf->iso_burning_opt = p;
    161     p = NULL;
    162 
    163     mr_cnf->iso_burning_speed = mr_conf_iread("mondo_iso_burning_speed");
    164     mr_cnf->media_size = mr_conf_iread("mondo_media_size");
    165 
    166     mr_asprintf(&p, mr_conf_sread("mondo_media_device"));
    167     mr_cnf->media_device = p;
    168     p = NULL;
    169 
    170     mr_cnf->manual_tray = mr_conf_bread("mondo_manual_tray");
    171     mr_cnf->log_level = mr_conf_iread("mondo_log_level");
    172 
    173     mr_asprintf(&p, mr_conf_sread("mondo_prefix"));
    174     mr_cnf->prefix = p;
    175     p = NULL;
    176 
    177     mr_cnf->external_tape_blocksize = mr_conf_iread("mondo_external_tape_blocksize");
    178     mr_cnf->internal_tape_blocksize = mr_conf_iread("mondo_internal_tape_blocksize");
    179     mr_cnf->slice_size = mr_conf_iread("mondo_slice_size");
    180 
    181     mr_asprintf(&p, mr_conf_sread("mondo_deplist_file"));
    182     mr_cnf->deplist_file = p;
    183     p = NULL;
    184 
    185     mr_cnf->create_mindi_cd = mr_conf_bread("mondo_create_mindi_cd");
    186 
    187     mr_asprintf(&p, mr_conf_sread("mondo_kernel"));
    188     mr_cnf->kernel = p;
    189     p = NULL;
    190 
    191     mr_asprintf(&p, mr_conf_sread("mondo_additional_modules"));
    192     mr_cnf->additional_modules = p;
    193     p = NULL;
    194 
    195     mr_asprintf(&p, mr_conf_sread("mondo_boot_loader"));
    196     mr_cnf->boot_loader = p;
    197     p = NULL;
    198 
    199     mr_cnf->differential = mr_conf_bread("mondo_differential");
    200 
    201     mr_asprintf(&p, mr_conf_sread("mondo_compression_tool"));
    202     mr_cnf->compression_tool = p;
    203     p = NULL;
    204 
    205     mr_cnf->compression_level = mr_conf_iread("mondo_compression_level");
    206 
    207     mr_asprintf(&p, mr_conf_sread("mondo_exclude_paths"));
    208     mr_cnf->exclude_paths = p;
    209     p = NULL;
    210 
    211     mr_asprintf(&p, mr_conf_sread("mondo_include_paths"));
    212     mr_cnf->include_paths = p;
    213     p = NULL;
    214 
    215     mr_asprintf(&p, mr_conf_sread("mondo_ui_mode"));
    216     mr_cnf->ui_mode = p;
    217     p = NULL;
    218 
    219     mr_cnf->automatic_restore = mr_conf_bread("mondo_automatic_restore");
    220 
    221     mr_asprintf(&p, mr_conf_sread("mondo_scratch_dir"));
    222     mr_cnf->scratch_dir = p;
    223     p = NULL;
    224 
    225     mr_asprintf(&p, mr_conf_sread("mondo_tmp_dir"));
    226     mr_cnf->tmp_dir = p;
    227     p = NULL;
    228 
    229     mr_asprintf(&p, mr_conf_sread("mondo_images_dir"));
    230     mr_cnf->images_dir = p;
    231     p = NULL;
     192    p = mr_conf_sread("mondo_iso_burning_cmd");
     193    if (p != NULL) {
     194        mr_cnf->iso_burning_cmd = p;
     195    }
     196
     197    p = mr_conf_sread("mondo_iso_burning_opt");
     198    if (p != NULL) {
     199        mr_cnf->iso_burning_opt = p;
     200    }
     201
     202    p = mr_conf_sread("mondo_iso_burning_dev");
     203    if (p != NULL) {
     204        mr_cnf->iso_burning_dev = p;
     205    }
     206
     207    p = mr_conf_iread("mondo_iso_burning_speed");
     208    if (p != NULL ) {
     209        mr_cnf->iso_burning_speed = atoi(p);
     210        mr_free(p);
     211    }
     212
     213    p = mr_conf_iread("mondo_media_size");
     214    if (p != NULL ) {
     215        mr_cnf->media_size = atoi(p);
     216        mr_free(p);
     217    }
     218
     219    p = mr_conf_sread("mondo_media_device");
     220    if (p != NULL) {
     221        mr_cnf->media_device = p;
     222    }
     223    /* If no specific device name for the burning command (a la ATAPI:0,0,0),
     224     * then use the normal device name (a la /dev/hda) */
     225    if ((mr_cnf->iso_burning_dev == NULL) && (mr_cnf->media_device != NULL)) {
     226        mr_asprintf(&p, mr_cnf->media_device);
     227        mr_cnf->iso_burning_dev = p;
     228    }
     229
     230    p = mr_conf_bread("mondo_manual_tray");
     231    if (p != NULL) {
     232        mr_cnf->manual_tray = mr_atob(p);
     233        mr_free(p);
     234    }
     235
     236    p = mr_conf_iread("mondo_log_level");
     237    if (p != NULL) {
     238        mr_cnf->log_level = atoi(p);
     239        mr_free(p);
     240    }
     241
     242    p = mr_conf_sread("mondo_prefix");
     243    if (p != NULL) {
     244        mr_cnf->prefix = p;
     245    }
     246
     247    p = mr_conf_iread("mondo_external_tape_blocksize");
     248    if (p != NULL) {
     249        mr_cnf->external_tape_blocksize = atoi(p);
     250        mr_free(p);
     251    }
     252
     253    p = mr_conf_iread("mondo_internal_tape_blocksize");
     254    if (p != NULL) {
     255        mr_cnf->internal_tape_blocksize = atoi(p);
     256        mr_free(p);
     257    }
     258
     259    p = mr_conf_iread("mondo_slice_size");
     260    if (p != NULL) {
     261        mr_cnf->slice_size = atoi(p);
     262        mr_free(p);
     263    }
     264
     265    p = mr_conf_sread("mondo_deplist_file");
     266    if (p != NULL) {
     267        mr_cnf->deplist_file = p;
     268    }
     269
     270    p = mr_conf_bread("mondo_create_mindi_cd");
     271    if (p != NULL) {
     272        mr_cnf->create_mindi_cd = mr_atob(p);
     273        mr_free(p);
     274    }
     275
     276    p = mr_conf_sread("mondo_kernel");
     277    if (p != NULL) {
     278        mr_cnf->kernel = p;
     279    }
     280
     281    p = mr_conf_sread("mondo_additional_modules");
     282    if (p != NULL) {
     283        mr_cnf->additional_modules = p;
     284    }
     285
     286    p = mr_conf_sread("mondo_boot_loader");
     287    if (p != NULL) {
     288        mr_cnf->boot_loader = p;
     289    }
     290
     291    p = mr_conf_bread("mondo_differential");
     292    if (p != NULL) {
     293        mr_cnf->differential = mr_atob(p);
     294        mr_free(p);
     295    }
     296
     297    p = mr_conf_sread("mondo_compression_tool");
     298    if (p != NULL) {
     299        mr_cnf->compression_tool = p;
     300    }
     301
     302    p = mr_conf_iread("mondo_compression_level");
     303    if (p != NULL) {
     304        mr_cnf->compression_level = atoi(p);
     305        mr_free(p);
     306    }
     307
     308    p = mr_conf_sread("mondo_exclude_paths");
     309    if (p != NULL) {
     310        mr_cnf->exclude_paths = p;
     311    }
     312
     313    p = mr_conf_sread("mondo_include_paths");
     314    if (p != NULL) {
     315        mr_cnf->include_paths = p;
     316    }
     317
     318    p = mr_conf_sread("mondo_ui_mode");
     319    if (p != NULL) {
     320        mr_cnf->ui_mode = p;
     321    }
     322
     323    p = mr_conf_bread("mondo_automatic_restore");
     324    if (p != NULL) {
     325        mr_cnf->automatic_restore = mr_atob(p);
     326        mr_free(p);
     327    }
     328
     329    p = mr_conf_sread("mondo_scratch_dir");
     330    if (p != NULL) {
     331        mr_cnf->scratch_dir = p;
     332    }
     333
     334    p = mr_conf_sread("mondo_tmp_dir");
     335    if (p != NULL) {
     336        mr_cnf->tmp_dir = p;
     337    }
     338
     339    p = mr_conf_sread("mondo_images_dir");
     340    if (p != NULL) {
     341        mr_cnf->images_dir = p;
     342    }
    232343    mr_msg(5, "Directory for images is %s", mr_cnf->images_dir);
    233344}
     
    242353    mr_free(mr_cnf->iso_creation_opt);
    243354    mr_free(mr_cnf->iso_burning_cmd);
     355    mr_free(mr_cnf->iso_burning_dev);
    244356    mr_free(mr_cnf->iso_burning_opt);
    245357    mr_free(mr_cnf->media_device);
     
    301413    (void) textdomain("mondo");
    302414#endif
    303     printf(_("Initializing..."));
     415    printf(_("Initializing...\n"));
    304416
    305417    /* Reference a dummy cleanup function for mr_exit temporarily */
     
    327439
    328440    /* Conf file management */
     441    mr_conf = mr_malloc(sizeof(struct mr_ar_conf));
     442    mr_ar_reset_conf(mr_conf);
    329443    /* Check md5 sum before */
    330444    /* Get content */
     
    332446            mr_log_exit(-1, "Unable to open "MONDO_CONF_DIR"/mondo.conf.dist");
    333447    }
    334     mr_conf = malloc(sizeof(struct mr_ar_conf));
    335448    mr_ar_store_conf(mr_conf);
    336449    /* Reference the right cleanup function for mr_exit now it's allocated */
    337450    mr_cleanup = &mr_ar_cleanup;
    338 
    339451    mr_conf_close();
     452
     453    if (mr_conf_open(MONDO_CONF_DIR"/mondo.conf") == 0) {
     454        mr_ar_store_conf(mr_conf);
     455        mr_conf_close();
     456    }
    340457
    341458    /* Check md5 sum before */
Note: See TracChangeset for help on using the changeset viewer.