source: branches/stable/mondo/src/mondoarchive/mondoarchive.c @ 1594

Last change on this file since 1594 was 1594, checked in by bruno, 12 years ago

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

  • Property svn:keywords set to Id
File size: 19.6 KB
Line 
1/***************************************************************************
2* $Id: mondoarchive.c 1594 2007-08-26 10:26:06Z bruno $
3*/
4
5
6/**
7 * @file
8 * The main file for mondoarchive.
9 */
10
11/************************* #include statements *************************/
12#include <pthread.h>
13#include <stdio.h>
14#include <stdlib.h>
15#include <sys/types.h>
16#include <sys/stat.h>
17#include <unistd.h>
18#include <locale.h>
19
20#include "mr_gettext.h"
21#include "mondoarchive.h"
22#include "mr_mem.h"
23#include "mr_str.h"
24#include "mr_msg.h"
25#include "mr_file.h"
26#include "mr_err.h"
27#include "mr_conf.h"
28
29#include "my-stuff.h"
30#include "mondostructures.h"
31#include "libmondo.h"
32#include "mondo-cli-EXT.h"
33
34// for CVS
35//static char cvsid[] = "$Id: mondoarchive.c 1594 2007-08-26 10:26:06Z bruno $";
36
37/************************* external variables *************************/
38extern void set_signals(int);
39extern int g_current_media_number;
40extern void register_pid(pid_t, char *);
41extern int g_currentY;
42extern bool g_text_mode;
43extern char *g_boot_mountpt;
44extern bool g_remount_cdrom_at_end, g_remount_floppy_at_end;
45extern char *g_tmpfs_mountpt;
46extern char *g_erase_tmpdir_and_scratchdir;
47extern char *g_cdrw_drive_is_here;
48extern double g_kernel_version;
49extern char *g_magicdev_command;
50extern t_bkptype g_backup_media_type;
51extern int g_loglevel;
52
53extern char *get_uname_m(void);
54
55static char *g_cdrom_drive_is_here = NULL;
56static char *g_dvd_drive_is_here = NULL;
57
58struct mr_ar_conf *mr_conf = NULL;
59
60/***************** global vars ******************/
61long diffs;
62
63/****************** subroutines used only here ******************/
64
65
66/**
67 * Print a "don't panic" message to the log and a message about the logfile to the screen.
68 */
69static void welcome_to_mondoarchive(void)
70{
71    char *tmp = NULL;
72
73    mr_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org", PACKAGE_VERSION);
74    mr_msg(0, "running %s binaries", get_architecture());
75    tmp = get_uname_m();
76    mr_msg(0, "running on %s architecture", tmp);
77    mr_free(tmp);
78    mr_msg(0, "-----------------------------------------------------------");
79    mr_msg(0, "NB: Mondo logs almost everything, so don't panic if you see");
80    mr_msg(0, "some error messages.  Please read them carefully before you");
81    mr_msg(0, "decide to break out in a cold sweat.    Despite (or perhaps");
82    mr_msg(0, "because of) the wealth of messages. some users are inclined");
83    mr_msg(0, "to stop reading this log. If Mondo stopped for some reason,");
84    mr_msg(0, "chances are it's detailed here.  More than likely there's a");
85    mr_msg(0, "message at the very end of this log that will tell you what");
86    mr_msg(0, "is wrong. Please read it!                          -Devteam");
87    mr_msg(0, "-----------------------------------------------------------");
88
89    mr_msg(0, "Zero...");
90    mr_msg(1, "One...");
91    mr_msg(2, "Two...");
92    mr_msg(3, "Three...");
93    mr_msg(4, "Four...");
94    mr_msg(5, "Five...");
95    mr_msg(6, "Six...");
96    mr_msg(7, "Seven...");
97    mr_msg(8, "Eight...");
98    printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
99}
100
101/**
102 * Do whatever is necessary to insure a successful backup on the Linux distribution
103 * of the day.
104 */
105static void distro_specific_kludges_at_start_of_mondoarchive(void)
106{
107    mr_msg(2, "Unmounting old ramdisks if necessary");
108    stop_magicdev_if_necessary();   // for RH+Gnome users
109    run_program_and_log_output
110        ("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
111    unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
112    mount_boot_if_necessary();  // for Gentoo users with non-mounted /boot partitions
113    clean_up_KDE_desktop_if_necessary();    // delete various misc ~/.* files that get in the way
114}
115
116
117/**
118 * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive().
119 */
120static void distro_specific_kludges_at_end_of_mondoarchive(void)
121{
122    mr_msg(2, "Restarting magicdev if necessary");
123    sync();
124    restart_magicdev_if_necessary();    // for RH+Gnome users
125
126    mr_msg(2, "Restarting supermounts if necessary");
127    sync();
128    remount_supermounts_if_necessary(); // for Mandrake users
129
130    mr_msg(2, "Unmounting /boot if necessary");
131    sync();
132    unmount_boot_if_necessary();    // for Gentoo users
133}
134
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
172/* fill the mr_ar_conf structure from mindi's conf file */
173static void mr_ar_store_conf_mindi(struct mr_ar_conf *mr_cnf) {
174   
175    char *p = NULL;
176
177    p = mr_conf_sread("mr_iso_creation_cmd");
178    if (p != NULL) {
179        mr_cnf->iso_creation_cmd = p;
180    }
181    p = mr_conf_sread("mr_iso_creation_opt");
182    if (p != NULL) {
183        mr_cnf->iso_creation_opt = p;
184    }
185}
186
187/* create the mr_ar_conf structure from mondo's conf file */
188static void mr_ar_store_conf(struct mr_ar_conf *mr_cnf) {
189   
190    char *p = NULL;
191
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    }
343    mr_msg(5, "Directory for images is %s", mr_cnf->images_dir);
344}
345
346/* destroy the mr_ar_conf structure's content */
347static void mr_ar_clean_conf(struct mr_ar_conf *mr_cnf) {
348   
349    if (mr_cnf == NULL) {
350        return;
351    }
352    mr_free(mr_cnf->iso_creation_cmd);
353    mr_free(mr_cnf->iso_creation_opt);
354    mr_free(mr_cnf->iso_burning_cmd);
355    mr_free(mr_cnf->iso_burning_dev);
356    mr_free(mr_cnf->iso_burning_opt);
357    mr_free(mr_cnf->media_device);
358    mr_free(mr_cnf->prefix);
359    mr_free(mr_cnf->deplist_file);
360    mr_free(mr_cnf->kernel);
361    mr_free(mr_cnf->additional_modules);
362    mr_free(mr_cnf->boot_loader);
363    mr_free(mr_cnf->compression_tool);
364    mr_free(mr_cnf->exclude_paths);
365    mr_free(mr_cnf->include_paths);
366    mr_free(mr_cnf->ui_mode);
367    mr_free(mr_cnf->scratch_dir);
368    mr_free(mr_cnf->tmp_dir);
369    mr_free(mr_cnf->images_dir);
370    mr_free(mr_cnf);
371}
372
373/* Create the pointer to the function called in mr_exit */
374void (*mr_cleanup)(void) = NULL;
375
376/* Just for init */
377void mr_ar_cleanup_empty(void) {
378}
379
380/* Cleanup all memory allocated in various structures */
381void mr_ar_cleanup(void) {
382    /* Highly incomplete function for the moment */
383    /* We have to free all allocated memory */
384    mr_ar_clean_conf(mr_conf);
385    /* We have to remove all temporary files */
386    /* We have to unmount what has been mounted */
387    /* We have to properly end newt */
388    /* We have to remind people of log files */
389
390    mr_msg_close();
391}
392
393/*-----------------------------------------------------------*/
394
395
396
397/**
398 * Backup/verify the user's data.
399 * What did you think it did, anyway? :-)
400 */
401int main(int argc, char *argv[])
402{
403    struct s_bkpinfo *bkpinfo = NULL;
404    struct stat stbuf;
405    char *tmp = NULL;
406    int res = 0;
407    int retval = 0;
408    char *say_at_end = NULL;
409    char *say_at_end2 = NULL;
410
411#ifdef ENABLE_NLS
412    setlocale(LC_ALL, "");
413    (void) textdomain("mondo");
414#endif
415    printf(_("Initializing...\n"));
416
417    /* Reference a dummy cleanup function for mr_exit temporarily */
418    mr_cleanup = &mr_ar_cleanup_empty;
419
420    /* initialize log file with time stamp */
421    /* We start with a loglevel of 4 - Adapted later on */
422    /* It's mandatory to set this up first as all mr_ functions rely on it */
423    unlink(MONDO_LOGFILE);
424    mr_msg_init(MONDO_LOGFILE,4);
425    mr_msg(0, _("Time started: %s"), mr_date());
426
427    /* Make sure I'm root; abort if not */
428    if (getuid() != 0) {
429        mr_log_exit(127, _("Please run as root."));
430    }
431
432    /* If -V, -v or --version then echo version no. and quit */
433    if (argc == 2
434        && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
435            || !strcmp(argv[argc - 1], "--version"))) {
436        printf(_("mondoarchive v%s\nSee man page for help\n"), PACKAGE_VERSION);
437        mr_exit(0, NULL);
438    }
439
440    /* Conf file management */
441    mr_conf = mr_malloc(sizeof(struct mr_ar_conf));
442    mr_ar_reset_conf(mr_conf);
443    /* Check md5 sum before */
444    /* Get content */
445    if (mr_conf_open(MONDO_CONF_DIR"/mondo.conf.dist") != 0) {
446            mr_log_exit(-1, "Unable to open "MONDO_CONF_DIR"/mondo.conf.dist");
447    }
448    mr_ar_store_conf(mr_conf);
449    /* Reference the right cleanup function for mr_exit now it's allocated */
450    mr_cleanup = &mr_ar_cleanup;
451    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    }
457
458    /* Check md5 sum before */
459    /* Get content of mindi conf file now to finish structure initialization */
460/* Tempo Hack */
461#define MINDI_CONF_DIR MONDO_CONF_DIR"/../mindi"
462    if (mr_conf_open(MINDI_CONF_DIR"/mindi.conf.dist") != 0) {
463            mr_log_exit(-1, "Unable to open "MINDI_CONF_DIR"/mindi.conf.dist");
464    }
465    mr_ar_store_conf_mindi(mr_conf);
466    mr_conf_close();
467
468    if (mr_conf_open(MINDI_CONF_DIR"/mindi.conf") == 0) {
469        mr_ar_store_conf_mindi(mr_conf);
470        mr_conf_close();
471    }
472    mr_msg(5, "Command for ISO images is %s", mr_conf->iso_creation_cmd);
473
474    /* Add MONDO_SHARE + other environment variables for mindi */
475    setenv_mondo_var();
476
477    /* Initialize variables */
478    malloc_libmondo_global_strings();
479    diffs = 0;
480    bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
481    if (stat(MONDO_CACHE, &stbuf) != 0) {
482        mr_mkdir(MONDO_CACHE,0x755);
483    }
484
485    /* BERLIOS: Hardcoded to be improved */
486    unlink(MONDO_CACHE"/mindi.conf");
487    unlink(MONDORESTORECFG);
488
489    /* Configure the bkpinfo structure, global file paths, etc. */
490    g_main_pid = getpid();
491    mr_msg(9, "This");
492
493    register_pid(g_main_pid, "mondo");
494    set_signals(TRUE);          // catch SIGTERM, etc.
495    run_program_and_log_output("dmesg -n1", TRUE);
496
497    mr_msg(9, "Next");
498    welcome_to_mondoarchive();
499    distro_specific_kludges_at_start_of_mondoarchive();
500    g_kernel_version = get_kernel_version();
501
502    if (argc == 4 && !strcmp(argv[1], "getfattr")) {
503        g_loglevel = 10;
504        g_text_mode = TRUE;
505        setup_newt_stuff();
506        if (!strstr(argv[2], "filelist")) {
507            mr_msg(1,_("Sorry - filelist goes first\n"));
508            finish(1);
509        } else {
510            finish(get_fattr_list(argv[2], argv[3]));
511        }
512        finish(0);
513    }
514    if (argc == 4 && !strcmp(argv[1], "setfattr")) {
515        g_loglevel = 10;
516        g_text_mode = TRUE;
517        setup_newt_stuff();
518        finish(set_fattr_list(argv[2], argv[3]));
519    }
520
521    if (argc == 3 && !strcmp(argv[1], "wildcards")) {
522        g_loglevel = 10;
523        g_text_mode = TRUE;
524        setup_newt_stuff();
525        tmp = mr_stresc(argv[2], WILDCHARS, BACKSLASH);
526        printf("in=%s; out=%s\n", argv[2], tmp);
527        mr_free(tmp);
528        finish(1);
529    }
530
531    if (argc == 4 && !strcmp(argv[1], "getfacl")) {
532        g_loglevel = 10;
533        g_text_mode = TRUE;
534        setup_newt_stuff();
535        if (!strstr(argv[2], "filelist")) {
536            mr_msg(1,_("Sorry - filelist goes first\n"));
537            finish(1);
538        } else {
539            finish(get_acl_list(argv[2], argv[3]));
540        }
541        finish(0);
542    }
543    if (argc == 4 && !strcmp(argv[1], "setfacl")) {
544        g_loglevel = 10;
545        g_text_mode = TRUE;
546        setup_newt_stuff();
547        finish(set_acl_list(argv[2], argv[3]));
548    }
549
550    if (argc > 2 && !strcmp(argv[1], "find-cd")) {
551        g_loglevel = 10;
552        g_text_mode = TRUE;
553        setup_newt_stuff();
554        malloc_string(tmp);
555        if (find_cdrw_device(tmp)) {
556            mr_msg(1,_("Failed to find CDR-RW drive\n"));
557        } else {
558            mr_msg(1,_("CD-RW is at %s\n"), tmp);
559        }
560        tmp[0] = '\0';
561        if (find_cdrom_device(tmp, atoi(argv[2]))) {
562            mr_msg(1,_("Failed to find CD-ROM drive\n"));
563        } else {
564            mr_msg(1,_("CD-ROM is at %s\n"), tmp);
565        }
566        mr_free(tmp);
567        finish(0);
568    }
569
570    if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
571        g_loglevel = 10;
572        g_text_mode = TRUE;
573        setup_newt_stuff();
574        malloc_string(tmp);
575        if (find_dvd_device(tmp, atoi(argv[2]))) {
576            mr_msg(1,_("Failed to find DVD drive\n"));
577        } else {
578            mr_msg(1,_("DVD is at %s\n"), tmp);
579        }
580        mr_free(tmp);
581        finish(0);
582    }
583
584    if (argc > 2 && !strcmp(argv[1], "disksize")) {
585        printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
586        finish(0);
587    }
588    if (argc > 2 && !strcmp(argv[1], "test-dev")) {
589        if (is_dev_an_NTFS_dev(argv[2])) {
590            mr_msg(1,_("%s is indeed an NTFS dev\n"), argv[2]);
591        } else {
592            mr_msg(1,_("%s is _not_ an NTFS dev\n"), argv[2]);
593        }
594        finish(0);
595    }
596
597    if (pre_param_configuration(bkpinfo)) {
598        fatal_error
599            ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
600    }
601    sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
602            bkpinfo->scratchdir);
603
604    /* Process command line, if there is one. If not, ask user for info. */
605    if (argc == 1) {
606        g_text_mode = FALSE;
607        setup_newt_stuff();
608        res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE);   /* yes, archiving */
609        if (res) {
610            fatal_error
611                ("Syntax error. Please review the parameters you have supplied and try again.");
612        }
613    } else {
614        res = handle_incoming_parameters(argc, argv, bkpinfo);
615        if (res) {
616            mr_msg(1,
617                _("Errors were detected in the command line you supplied.\n"));
618            mr_msg(1,_("Please review the log file - %s \n"),MONDO_LOGFILE);
619            mr_msg(1, "Mondoarchive will now exit.");
620            finish(1);
621        }
622        setup_newt_stuff();
623    }
624
625/* Finish configuring global structures */
626    if (post_param_configuration(bkpinfo)) {
627        fatal_error
628            ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
629    }
630
631    log_to_screen
632        (_("BusyBox's sources are available from http://www.busybox.net"));
633
634    sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
635            bkpinfo->scratchdir);
636
637    /* If we're meant to backup then backup */
638    if (bkpinfo->backup_data) {
639        res = backup_data(bkpinfo);
640        retval += res;
641        if (res) {
642            mr_strcat(say_at_end,
643                   _("Data archived. Please check the logs, just as a precaution. "));
644        } else {
645            mr_strcat(say_at_end, _("Data archived OK. "));
646        }
647    }
648
649    /* If we're meant to verify then verify */
650    if (bkpinfo->verify_data) {
651        res = verify_data(bkpinfo);
652        if (res < 0) {
653            mr_asprintf(&say_at_end2, _("%d difference%c found."), -res,
654                    (-res != 1) ? 's' : ' ');
655            res = 0;
656        }
657        retval += res;
658    }
659
660    /* Report result of entire operation (success? errors?) */
661    if (!retval) {
662        mvaddstr_and_log_it(g_currentY++, 0,
663                            _("Backup and/or verify ran to completion. Everything appears to be fine."));
664    } else {
665        mvaddstr_and_log_it(g_currentY++, 0,
666                            _("Backup and/or verify ran to completion. However, errors did occur."));
667    }
668
669    if (does_file_exist(MINDI_CACHE"/mondorescue.iso")) {
670        log_to_screen
671            (_(MINDI_CACHE"/mondorescue.iso, a boot/utility CD, is available if you want it."));
672    }
673
674
675    if (length_of_file("/tmp/changed.files") > 2) {
676        if (g_text_mode) {
677            log_to_screen
678                (_("Type 'less /tmp/changed.files' to see which files don't match the archives"));
679        } else {
680            mr_msg(1,
681                    _("Type 'less /tmp/changed.files' to see which files don't match the archives"));
682            mr_msg(2, "Calling popup_changelist_from_file()");
683            popup_changelist_from_file("/tmp/changed.files");
684            mr_msg(2, "Returned from popup_changelist_from_file()");
685        }
686    } else {
687        unlink("/tmp/changed.files");
688    }
689    log_to_screen(say_at_end);
690    mr_free(say_at_end);
691    if (say_at_end2 != NULL) {
692        log_to_screen(say_at_end2);
693        mr_free(say_at_end2);
694    }
695
696    mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
697    run_program_and_log_output(tmp, TRUE);
698    mr_free(tmp);
699    run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
700
701    run_program_and_log_output("mount", 2);
702
703    system("rm -f /var/cache/mondo-archive/last-backup.aborted");
704    system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
705    if (!retval) {
706        printf(_("Mondoarchive ran OK.\n"));
707    } else {
708        printf(_("Errors occurred during backup. Please check logfile.\n"));
709    }
710    distro_specific_kludges_at_end_of_mondoarchive();
711    register_pid(0, "mondo");
712    set_signals(FALSE);
713    chdir("/tmp");              // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
714    system(g_erase_tmpdir_and_scratchdir);
715    free_libmondo_global_strings();
716    mr_free(bkpinfo);
717
718    unlink("/tmp/filelist.full");
719    unlink("/tmp/filelist.full.gz");
720
721    if (!g_cdrom_drive_is_here) {
722        mr_msg(10, "FYI, g_cdrom_drive_is_here was never used");
723    }
724    if (!g_dvd_drive_is_here) {
725        mr_msg(10, "FYI, g_dvd_drive_is_here was never used");
726    }
727
728    /* finalize log file with time stamp */
729    mr_msg(1, "Time finished: %s", mr_date());
730    mr_msg_close();
731
732    if (!g_text_mode) {
733        popup_and_OK
734            (_("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt."));
735        log_to_screen(_("See %s for details of backup run."), MONDO_LOGFILE);
736        finish(retval);
737    } else {
738        printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
739        mr_exit(retval, NULL);
740    }
741
742    return EXIT_SUCCESS;
743}
Note: See TracBrowser for help on using the repository browser.