source: MondoRescue/branches/stable/mondo/src/mondoarchive/mondoarchive.c@ 1625

Last change on this file since 1625 was 1625, checked in by Bruno Cornec, 17 years ago

remove g_loglevel and replaced with mr_conf->log_level

  • Property svn:keywords set to Id
File size: 19.6 KB
Line 
1/***************************************************************************
2* $Id: mondoarchive.c 1625 2007-09-08 23:00:49Z 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 1625 2007-09-08 23:00:49Z 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;
51
52extern char *get_uname_m(void);
53
54static char *g_cdrom_drive_is_here = NULL;
55static char *g_dvd_drive_is_here = NULL;
56
57struct mr_ar_conf *mr_conf = NULL;
58
59/***************** global vars ******************/
60long diffs;
61
62/****************** subroutines used only here ******************/
63
64
65/**
66 * Print a "don't panic" message to the log and a message about the logfile to the screen.
67 */
68static void welcome_to_mondoarchive(void)
69{
70 char *tmp = NULL;
71
72 mr_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org", PACKAGE_VERSION);
73 mr_msg(0, "running %s binaries", get_architecture());
74 tmp = get_uname_m();
75 mr_msg(0, "running on %s architecture", tmp);
76 mr_free(tmp);
77 mr_msg(0, "-----------------------------------------------------------");
78 mr_msg(0, "NB: Mondo logs almost everything, so don't panic if you see");
79 mr_msg(0, "some error messages. Please read them carefully before you");
80 mr_msg(0, "decide to break out in a cold sweat. Despite (or perhaps");
81 mr_msg(0, "because of) the wealth of messages. some users are inclined");
82 mr_msg(0, "to stop reading this log. If Mondo stopped for some reason,");
83 mr_msg(0, "chances are it's detailed here. More than likely there's a");
84 mr_msg(0, "message at the very end of this log that will tell you what");
85 mr_msg(0, "is wrong. Please read it! -Devteam");
86 mr_msg(0, "-----------------------------------------------------------");
87
88 mr_msg(0, "Zero...");
89 mr_msg(1, "One...");
90 mr_msg(2, "Two...");
91 mr_msg(3, "Three...");
92 mr_msg(4, "Four...");
93 mr_msg(5, "Five...");
94 mr_msg(6, "Six...");
95 mr_msg(7, "Seven...");
96 mr_msg(8, "Eight...");
97 printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
98}
99
100/**
101 * Do whatever is necessary to insure a successful backup on the Linux distribution
102 * of the day.
103 */
104static void distro_specific_kludges_at_start_of_mondoarchive(void)
105{
106 mr_msg(2, "Unmounting old ramdisks if necessary");
107 stop_magicdev_if_necessary(); // for RH+Gnome users
108 run_program_and_log_output
109 ("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
110 unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
111 mount_boot_if_necessary(); // for Gentoo users with non-mounted /boot partitions
112 clean_up_KDE_desktop_if_necessary(); // delete various misc ~/.* files that get in the way
113}
114
115
116/**
117 * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive().
118 */
119static void distro_specific_kludges_at_end_of_mondoarchive(void)
120{
121 mr_msg(2, "Restarting magicdev if necessary");
122 sync();
123 restart_magicdev_if_necessary(); // for RH+Gnome users
124
125 mr_msg(2, "Restarting supermounts if necessary");
126 sync();
127 remount_supermounts_if_necessary(); // for Mandrake users
128
129 mr_msg(2, "Unmounting /boot if necessary");
130 sync();
131 unmount_boot_if_necessary(); // for Gentoo users
132}
133
134/* reset/empty the mr_ar_conf structure from mondo's conf file */
135static void mr_ar_reset_conf(struct mr_ar_conf *mr_cnf) {
136
137 /* This should correspond to the default conf file */
138 /* Especially for boolean values */
139 mr_cnf->iso_creation_cmd = NULL;
140 mr_cnf->iso_creation_opt = NULL;
141 mr_cnf->iso_burning_cmd = NULL;
142 mr_cnf->iso_burning_opt = NULL;
143 mr_cnf->iso_burning_dev = NULL;
144 mr_cnf->iso_burning_speed = 0;
145 mr_cnf->media_size = 0;
146 mr_cnf->media_device = NULL;
147 mr_cnf->iso_burning_dev = NULL;
148 mr_cnf->manual_tray = FALSE;
149 mr_cnf->log_level = 0;
150 mr_cnf->prefix = NULL;
151 mr_cnf->external_tape_blocksize = 0;
152 mr_cnf->internal_tape_blocksize = 0;
153 mr_cnf->slice_size = 0;
154 mr_cnf->deplist_file = NULL;
155 mr_cnf->create_mindi_cd = FALSE;
156 mr_cnf->kernel = NULL;
157 mr_cnf->additional_modules = NULL;
158 mr_cnf->boot_loader = NULL;
159 mr_cnf->differential = FALSE;
160 mr_cnf->compression_tool = NULL;
161 mr_cnf->compression_level = 0;
162 mr_cnf->exclude_paths = NULL;
163 mr_cnf->include_paths = NULL;
164 mr_cnf->ui_mode = NULL;
165 mr_cnf->automatic_restore = FALSE;
166 mr_cnf->scratch_dir = NULL;
167 mr_cnf->tmp_dir = NULL;
168 mr_cnf->images_dir = NULL;
169}
170
171/* fill the mr_ar_conf structure from mindi's conf file */
172static void mr_ar_store_conf_mindi(struct mr_ar_conf *mr_cnf) {
173
174 char *p = NULL;
175
176 p = mr_conf_sread("mr_iso_creation_cmd");
177 if (p != NULL) {
178 mr_cnf->iso_creation_cmd = p;
179 }
180 p = mr_conf_sread("mr_iso_creation_opt");
181 if (p != NULL) {
182 mr_cnf->iso_creation_opt = p;
183 }
184}
185
186/* create the mr_ar_conf structure from mondo's conf file */
187static void mr_ar_store_conf(struct mr_ar_conf *mr_cnf) {
188
189 char *p = NULL;
190
191 p = mr_conf_sread("mondo_iso_burning_cmd");
192 if (p != NULL) {
193 mr_cnf->iso_burning_cmd = p;
194 }
195
196 p = mr_conf_sread("mondo_iso_burning_opt");
197 if (p != NULL) {
198 mr_cnf->iso_burning_opt = p;
199 }
200
201 p = mr_conf_sread("mondo_iso_burning_dev");
202 if (p != NULL) {
203 mr_cnf->iso_burning_dev = p;
204 }
205
206 p = mr_conf_iread("mondo_iso_burning_speed");
207 if (p != NULL ) {
208 mr_cnf->iso_burning_speed = atoi(p);
209 mr_free(p);
210 }
211
212 p = mr_conf_iread("mondo_media_size");
213 if (p != NULL ) {
214 mr_cnf->media_size = atoi(p);
215 mr_free(p);
216 }
217
218 p = mr_conf_sread("mondo_media_device");
219 if (p != NULL) {
220 mr_cnf->media_device = p;
221 }
222 /* If no specific device name for the burning command (a la ATAPI:0,0,0),
223 * then use the normal device name (a la /dev/hda) */
224 if ((mr_cnf->iso_burning_dev == NULL) && (mr_cnf->media_device != NULL)) {
225 mr_asprintf(&p, mr_cnf->media_device);
226 mr_cnf->iso_burning_dev = p;
227 }
228
229 p = mr_conf_bread("mondo_manual_tray");
230 if (p != NULL) {
231 mr_cnf->manual_tray = mr_atob(p);
232 mr_free(p);
233 }
234
235 p = mr_conf_iread("mondo_log_level");
236 if (p != NULL) {
237 mr_cnf->log_level = atoi(p);
238 mr_free(p);
239 }
240
241 p = mr_conf_sread("mondo_prefix");
242 if (p != NULL) {
243 mr_cnf->prefix = p;
244 }
245
246 p = mr_conf_iread("mondo_external_tape_blocksize");
247 if (p != NULL) {
248 mr_cnf->external_tape_blocksize = atoi(p);
249 mr_free(p);
250 }
251
252 p = mr_conf_iread("mondo_internal_tape_blocksize");
253 if (p != NULL) {
254 mr_cnf->internal_tape_blocksize = atoi(p);
255 mr_free(p);
256 }
257
258 p = mr_conf_iread("mondo_slice_size");
259 if (p != NULL) {
260 mr_cnf->slice_size = atoi(p);
261 mr_free(p);
262 }
263
264 p = mr_conf_sread("mondo_deplist_file");
265 if (p != NULL) {
266 mr_cnf->deplist_file = p;
267 }
268
269 p = mr_conf_bread("mondo_create_mindi_cd");
270 if (p != NULL) {
271 mr_cnf->create_mindi_cd = mr_atob(p);
272 mr_free(p);
273 }
274
275 p = mr_conf_sread("mondo_kernel");
276 if (p != NULL) {
277 mr_cnf->kernel = p;
278 }
279
280 p = mr_conf_sread("mondo_additional_modules");
281 if (p != NULL) {
282 mr_cnf->additional_modules = p;
283 }
284
285 p = mr_conf_sread("mondo_boot_loader");
286 if (p != NULL) {
287 mr_cnf->boot_loader = p;
288 }
289
290 p = mr_conf_bread("mondo_differential");
291 if (p != NULL) {
292 mr_cnf->differential = mr_atob(p);
293 mr_free(p);
294 }
295
296 p = mr_conf_sread("mondo_compression_tool");
297 if (p != NULL) {
298 mr_cnf->compression_tool = p;
299 }
300
301 p = mr_conf_iread("mondo_compression_level");
302 if (p != NULL) {
303 mr_cnf->compression_level = atoi(p);
304 mr_free(p);
305 }
306
307 p = mr_conf_sread("mondo_exclude_paths");
308 if (p != NULL) {
309 mr_cnf->exclude_paths = p;
310 }
311
312 p = mr_conf_sread("mondo_include_paths");
313 if (p != NULL) {
314 mr_cnf->include_paths = p;
315 }
316
317 p = mr_conf_sread("mondo_ui_mode");
318 if (p != NULL) {
319 mr_cnf->ui_mode = p;
320 }
321
322 p = mr_conf_bread("mondo_automatic_restore");
323 if (p != NULL) {
324 mr_cnf->automatic_restore = mr_atob(p);
325 mr_free(p);
326 }
327
328 p = mr_conf_sread("mondo_scratch_dir");
329 if (p != NULL) {
330 mr_cnf->scratch_dir = p;
331 }
332
333 p = mr_conf_sread("mondo_tmp_dir");
334 if (p != NULL) {
335 mr_cnf->tmp_dir = p;
336 }
337
338 p = mr_conf_sread("mondo_images_dir");
339 if (p != NULL) {
340 mr_cnf->images_dir = p;
341 }
342 mr_msg(5, "Directory for images is %s", mr_cnf->images_dir);
343}
344
345/* destroy the mr_ar_conf structure's content */
346static void mr_ar_clean_conf(struct mr_ar_conf *mr_cnf) {
347
348 if (mr_cnf == NULL) {
349 return;
350 }
351 mr_free(mr_cnf->iso_creation_cmd);
352 mr_free(mr_cnf->iso_creation_opt);
353 mr_free(mr_cnf->iso_burning_cmd);
354 mr_free(mr_cnf->iso_burning_dev);
355 mr_free(mr_cnf->iso_burning_opt);
356 mr_free(mr_cnf->media_device);
357 mr_free(mr_cnf->prefix);
358 mr_free(mr_cnf->deplist_file);
359 mr_free(mr_cnf->kernel);
360 mr_free(mr_cnf->additional_modules);
361 mr_free(mr_cnf->boot_loader);
362 mr_free(mr_cnf->compression_tool);
363 mr_free(mr_cnf->exclude_paths);
364 mr_free(mr_cnf->include_paths);
365 mr_free(mr_cnf->ui_mode);
366 mr_free(mr_cnf->scratch_dir);
367 mr_free(mr_cnf->tmp_dir);
368 mr_free(mr_cnf->images_dir);
369 mr_free(mr_cnf);
370}
371
372/* Create the pointer to the function called in mr_exit */
373void (*mr_cleanup)(void) = NULL;
374
375/* Just for init */
376void mr_ar_cleanup_empty(void) {
377}
378
379/* Cleanup all memory allocated in various structures */
380void mr_ar_cleanup(void) {
381 /* Highly incomplete function for the moment */
382 /* We have to free all allocated memory */
383 mr_ar_clean_conf(mr_conf);
384 /* We have to remove all temporary files */
385 /* We have to unmount what has been mounted */
386 /* We have to properly end newt */
387 /* We have to remind people of log files */
388
389 mr_msg_close();
390}
391
392/*-----------------------------------------------------------*/
393
394
395
396/**
397 * Backup/verify the user's data.
398 * What did you think it did, anyway? :-)
399 */
400int main(int argc, char *argv[])
401{
402 struct s_bkpinfo *bkpinfo = NULL;
403 struct stat stbuf;
404 char *tmp = NULL;
405 int res = 0;
406 int retval = 0;
407 char *say_at_end = NULL;
408 char *say_at_end2 = NULL;
409
410#ifdef ENABLE_NLS
411 setlocale(LC_ALL, "");
412 (void) textdomain("mondo");
413#endif
414 printf(_("Initializing...\n"));
415
416 /* Reference a dummy cleanup function for mr_exit temporarily */
417 mr_cleanup = &mr_ar_cleanup_empty;
418
419 /* initialize log file with time stamp */
420 /* We start with a loglevel of 4 - Adapted later on */
421 /* It's mandatory to set this up first as all mr_ functions rely on it */
422 unlink(MONDO_LOGFILE);
423 mr_msg_init(MONDO_LOGFILE,4);
424 mr_msg(0, _("Time started: %s"), mr_date());
425
426 /* Make sure I'm root; abort if not */
427 if (getuid() != 0) {
428 mr_log_exit(127, _("Please run as root."));
429 }
430
431 /* If -V, -v or --version then echo version no. and quit */
432 if (argc == 2
433 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
434 || !strcmp(argv[argc - 1], "--version"))) {
435 printf(_("mondoarchive v%s\nSee man page for help\n"), PACKAGE_VERSION);
436 mr_exit(0, NULL);
437 }
438
439 /* Conf file management */
440 mr_conf = mr_malloc(sizeof(struct mr_ar_conf));
441 mr_ar_reset_conf(mr_conf);
442 /* Check md5 sum before */
443 /* Get content */
444 if (mr_conf_open(MONDO_CONF_DIR"/mondo.conf.dist") != 0) {
445 mr_log_exit(-1, "Unable to open "MONDO_CONF_DIR"/mondo.conf.dist");
446 }
447 mr_ar_store_conf(mr_conf);
448 /* Reference the right cleanup function for mr_exit now it's allocated */
449 mr_cleanup = &mr_ar_cleanup;
450 mr_conf_close();
451
452 if (mr_conf_open(MONDO_CONF_DIR"/mondo.conf") == 0) {
453 mr_ar_store_conf(mr_conf);
454 mr_conf_close();
455 }
456
457 /* Check md5 sum before */
458 /* Get content of mindi conf file now to finish structure initialization */
459/* Tempo Hack */
460#define MINDI_CONF_DIR MONDO_CONF_DIR"/../mindi"
461 if (mr_conf_open(MINDI_CONF_DIR"/mindi.conf.dist") != 0) {
462 mr_log_exit(-1, "Unable to open "MINDI_CONF_DIR"/mindi.conf.dist");
463 }
464 mr_ar_store_conf_mindi(mr_conf);
465 mr_conf_close();
466
467 if (mr_conf_open(MINDI_CONF_DIR"/mindi.conf") == 0) {
468 mr_ar_store_conf_mindi(mr_conf);
469 mr_conf_close();
470 }
471 mr_msg(5, "Command for ISO images is %s", mr_conf->iso_creation_cmd);
472
473 /* Add MONDO_SHARE + other environment variables for mindi */
474 setenv_mondo_var();
475
476 /* Initialize variables */
477 malloc_libmondo_global_strings();
478 diffs = 0;
479 bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
480 if (stat(MONDO_CACHE, &stbuf) != 0) {
481 mr_mkdir(MONDO_CACHE,0x755);
482 }
483
484 /* BERLIOS: Hardcoded to be improved */
485 unlink(MONDO_CACHE"/mindi.conf");
486 unlink(MONDORESTORECFG);
487
488 /* Configure the bkpinfo structure, global file paths, etc. */
489 g_main_pid = getpid();
490 mr_msg(9, "This");
491
492 register_pid(g_main_pid, "mondo");
493 set_signals(TRUE); // catch SIGTERM, etc.
494 run_program_and_log_output("dmesg -n1", TRUE);
495
496 mr_msg(9, "Next");
497 welcome_to_mondoarchive();
498 distro_specific_kludges_at_start_of_mondoarchive();
499 g_kernel_version = get_kernel_version();
500
501 if (argc == 4 && !strcmp(argv[1], "getfattr")) {
502 mr_conf->log_level = 10;
503 g_text_mode = TRUE;
504 setup_newt_stuff();
505 if (!strstr(argv[2], "filelist")) {
506 mr_msg(1,_("Sorry - filelist goes first\n"));
507 finish(1);
508 } else {
509 finish(get_fattr_list(argv[2], argv[3]));
510 }
511 finish(0);
512 }
513 if (argc == 4 && !strcmp(argv[1], "setfattr")) {
514 mr_conf->log_level = 10;
515 g_text_mode = TRUE;
516 setup_newt_stuff();
517 finish(set_fattr_list(argv[2], argv[3]));
518 }
519
520 if (argc == 3 && !strcmp(argv[1], "wildcards")) {
521 mr_conf->log_level = 10;
522 g_text_mode = TRUE;
523 setup_newt_stuff();
524 tmp = mr_stresc(argv[2], WILDCHARS, BACKSLASH);
525 printf("in=%s; out=%s\n", argv[2], tmp);
526 mr_free(tmp);
527 finish(1);
528 }
529
530 if (argc == 4 && !strcmp(argv[1], "getfacl")) {
531 mr_conf->log_level = 10;
532 g_text_mode = TRUE;
533 setup_newt_stuff();
534 if (!strstr(argv[2], "filelist")) {
535 mr_msg(1,_("Sorry - filelist goes first\n"));
536 finish(1);
537 } else {
538 finish(get_acl_list(argv[2], argv[3]));
539 }
540 finish(0);
541 }
542 if (argc == 4 && !strcmp(argv[1], "setfacl")) {
543 mr_conf->log_level = 10;
544 g_text_mode = TRUE;
545 setup_newt_stuff();
546 finish(set_acl_list(argv[2], argv[3]));
547 }
548
549 if (argc > 2 && !strcmp(argv[1], "find-cd")) {
550 mr_conf->log_level = 10;
551 g_text_mode = TRUE;
552 setup_newt_stuff();
553 malloc_string(tmp);
554 if (find_cdrw_device(tmp)) {
555 mr_msg(1,_("Failed to find CDR-RW drive\n"));
556 } else {
557 mr_msg(1,_("CD-RW is at %s\n"), tmp);
558 }
559 tmp[0] = '\0';
560 if (find_cdrom_device(tmp, atoi(argv[2]))) {
561 mr_msg(1,_("Failed to find CD-ROM drive\n"));
562 } else {
563 mr_msg(1,_("CD-ROM is at %s\n"), tmp);
564 }
565 mr_free(tmp);
566 finish(0);
567 }
568
569 if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
570 mr_conf->log_level = 10;
571 g_text_mode = TRUE;
572 setup_newt_stuff();
573 malloc_string(tmp);
574 if (find_dvd_device(tmp, atoi(argv[2]))) {
575 mr_msg(1,_("Failed to find DVD drive\n"));
576 } else {
577 mr_msg(1,_("DVD is at %s\n"), tmp);
578 }
579 mr_free(tmp);
580 finish(0);
581 }
582
583 if (argc > 2 && !strcmp(argv[1], "disksize")) {
584 printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
585 finish(0);
586 }
587 if (argc > 2 && !strcmp(argv[1], "test-dev")) {
588 if (is_dev_an_NTFS_dev(argv[2])) {
589 mr_msg(1,_("%s is indeed an NTFS dev\n"), argv[2]);
590 } else {
591 mr_msg(1,_("%s is _not_ an NTFS dev\n"), argv[2]);
592 }
593 finish(0);
594 }
595
596 if (pre_param_configuration(bkpinfo)) {
597 fatal_error
598 ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
599 }
600 sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
601 bkpinfo->scratchdir);
602
603 /* Process command line, if there is one. If not, ask user for info. */
604 if (argc == 1) {
605 g_text_mode = FALSE;
606 setup_newt_stuff();
607 res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE); /* yes, archiving */
608 if (res) {
609 fatal_error
610 ("Syntax error. Please review the parameters you have supplied and try again.");
611 }
612 } else {
613 res = handle_incoming_parameters(argc, argv, bkpinfo);
614 if (res) {
615 mr_msg(1,
616 _("Errors were detected in the command line you supplied.\n"));
617 mr_msg(1,_("Please review the log file - %s \n"),MONDO_LOGFILE);
618 mr_msg(1, "Mondoarchive will now exit.");
619 finish(1);
620 }
621 setup_newt_stuff();
622 }
623
624/* Finish configuring global structures */
625 if (post_param_configuration(bkpinfo)) {
626 fatal_error
627 ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
628 }
629
630 log_to_screen
631 (_("BusyBox's sources are available from http://www.busybox.net"));
632
633 sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
634 bkpinfo->scratchdir);
635
636 /* If we're meant to backup then backup */
637 if (bkpinfo->backup_data) {
638 res = backup_data(bkpinfo);
639 retval += res;
640 if (res) {
641 mr_strcat(say_at_end,
642 _("Data archived. Please check the logs, just as a precaution. "));
643 } else {
644 mr_strcat(say_at_end, _("Data archived OK. "));
645 }
646 }
647
648 /* If we're meant to verify then verify */
649 if (bkpinfo->verify_data) {
650 res = verify_data(bkpinfo);
651 if (res < 0) {
652 mr_asprintf(&say_at_end2, _("%d difference%c found."), -res,
653 (-res != 1) ? 's' : ' ');
654 res = 0;
655 }
656 retval += res;
657 }
658
659 /* Report result of entire operation (success? errors?) */
660 if (!retval) {
661 mvaddstr_and_log_it(g_currentY++, 0,
662 _("Backup and/or verify ran to completion. Everything appears to be fine."));
663 } else {
664 mvaddstr_and_log_it(g_currentY++, 0,
665 _("Backup and/or verify ran to completion. However, errors did occur."));
666 }
667
668 if (does_file_exist(MINDI_CACHE"/mondorescue.iso")) {
669 log_to_screen
670 (_(MINDI_CACHE"/mondorescue.iso, a boot/utility CD, is available if you want it."));
671 }
672
673
674 if (length_of_file("/tmp/changed.files") > 2) {
675 if (g_text_mode) {
676 log_to_screen
677 (_("Type 'less /tmp/changed.files' to see which files don't match the archives"));
678 } else {
679 mr_msg(1,
680 _("Type 'less /tmp/changed.files' to see which files don't match the archives"));
681 mr_msg(2, "Calling popup_changelist_from_file()");
682 popup_changelist_from_file("/tmp/changed.files");
683 mr_msg(2, "Returned from popup_changelist_from_file()");
684 }
685 } else {
686 unlink("/tmp/changed.files");
687 }
688 log_to_screen(say_at_end);
689 mr_free(say_at_end);
690 if (say_at_end2 != NULL) {
691 log_to_screen(say_at_end2);
692 mr_free(say_at_end2);
693 }
694
695 mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
696 run_program_and_log_output(tmp, TRUE);
697 mr_free(tmp);
698 run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
699
700 run_program_and_log_output("mount", 2);
701
702 system("rm -f /var/cache/mondo-archive/last-backup.aborted");
703 system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
704 if (!retval) {
705 printf(_("Mondoarchive ran OK.\n"));
706 } else {
707 printf(_("Errors occurred during backup. Please check logfile.\n"));
708 }
709 distro_specific_kludges_at_end_of_mondoarchive();
710 register_pid(0, "mondo");
711 set_signals(FALSE);
712 chdir("/tmp"); // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
713 system(g_erase_tmpdir_and_scratchdir);
714 free_libmondo_global_strings();
715 mr_free(bkpinfo);
716
717 unlink("/tmp/filelist.full");
718 unlink("/tmp/filelist.full.gz");
719
720 if (!g_cdrom_drive_is_here) {
721 mr_msg(10, "FYI, g_cdrom_drive_is_here was never used");
722 }
723 if (!g_dvd_drive_is_here) {
724 mr_msg(10, "FYI, g_dvd_drive_is_here was never used");
725 }
726
727 /* finalize log file with time stamp */
728 mr_msg(1, "Time finished: %s", mr_date());
729 mr_msg_close();
730
731 if (!g_text_mode) {
732 popup_and_OK
733 (_("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt."));
734 log_to_screen(_("See %s for details of backup run."), MONDO_LOGFILE);
735 finish(retval);
736 } else {
737 printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
738 mr_exit(retval, NULL);
739 }
740
741 return EXIT_SUCCESS;
742}
Note: See TracBrowser for help on using the repository browser.