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

Last change on this file since 1924 was 1924, checked in by Bruno Cornec, 16 years ago

svn merge -r 1902:1923 $SVN_M/branches/2.2.6

  • Property svn:keywords set to Id
File size: 19.6 KB
Line 
1/***************************************************************************
2* $Id: mondoarchive.c 1924 2008-04-17 23:41:41Z 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 1924 2008-04-17 23:41:41Z 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_cdrw_drive_is_here;
46extern double g_kernel_version;
47extern char *g_magicdev_command;
48extern t_bkptype g_backup_media_type;
49
50extern char *get_uname_m(void);
51
52static char *g_cdrom_drive_is_here = NULL;
53static char *g_dvd_drive_is_here = NULL;
54
55struct mr_ar_conf *mr_conf = NULL;
56
57/***************** global vars ******************/
58long diffs;
59
60/****************** subroutines used only here ******************/
61
62/**
63 * Whether we're restoring from ISOs. Obviously not, since this is the
64 * backup program.
65 * @note You @b MUST declare this variable somewhere in your program if
66 * you use libmondo. Otherwise the link will fail.
67 * @ingroup globalGroup
68 */
69bool g_ISO_restore_mode = FALSE;
70
71/* Do we use extended attributes and acl ?
72 * * By default no, use --acl & --attr options to force their usage */
73char *g_getfacl = NULL;
74char *g_getfattr = NULL;
75
76/* Reference to global bkpinfo */
77struct s_bkpinfo *bkpinfo;
78
79/****************** subroutines used only by main.c ******************/
80
81/**
82 * Print a "don't panic" message to the log and a message about the logfile to the screen.
83 */
84static void welcome_to_mondoarchive(void)
85{
86 char *tmp = NULL;
87
88 mr_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org", PACKAGE_VERSION);
89 mr_msg(0, "running %s binaries", get_architecture());
90 tmp = get_uname_m();
91 mr_msg(0, "running on %s architecture", tmp);
92 mr_free(tmp);
93 mr_msg(0, "-----------------------------------------------------------");
94 mr_msg(0, "NB: Mondo logs almost everything, so don't panic if you see");
95 mr_msg(0, "some error messages. Please read them carefully before you");
96 mr_msg(0, "decide to break out in a cold sweat. Despite (or perhaps");
97 mr_msg(0, "because of) the wealth of messages. some users are inclined");
98 mr_msg(0, "to stop reading this log. If Mondo stopped for some reason,");
99 mr_msg(0, "chances are it's detailed here. More than likely there's a");
100 mr_msg(0, "message at the very end of this log that will tell you what");
101 mr_msg(0, "is wrong. Please read it! -Devteam");
102 mr_msg(0, "-----------------------------------------------------------");
103
104 mr_msg(0, "Zero...");
105 mr_msg(1, "One...");
106 mr_msg(2, "Two...");
107 mr_msg(3, "Three...");
108 mr_msg(4, "Four...");
109 mr_msg(5, "Five...");
110 mr_msg(6, "Six...");
111 mr_msg(7, "Seven...");
112 mr_msg(8, "Eight...");
113 printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
114}
115
116/**
117 * Do whatever is necessary to insure a successful backup on the Linux distribution
118 * of the day.
119 */
120static void distro_specific_kludges_at_start_of_mondoarchive(void)
121{
122 mr_msg(2, "Unmounting old ramdisks if necessary");
123 stop_magicdev_if_necessary(); // for RH+Gnome users
124 run_program_and_log_output
125 ("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
126 unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
127 mount_boot_if_necessary(); // for Gentoo users with non-mounted /boot partitions
128 clean_up_KDE_desktop_if_necessary(); // delete various misc ~/.* files that get in the way
129}
130
131
132/**
133 * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive().
134 */
135static void distro_specific_kludges_at_end_of_mondoarchive(void)
136{
137 mr_msg(2, "Restarting magicdev if necessary");
138 sync();
139 restart_magicdev_if_necessary(); // for RH+Gnome users
140
141 mr_msg(2, "Restarting supermounts if necessary");
142 sync();
143 remount_supermounts_if_necessary(); // for Mandrake users
144
145 mr_msg(2, "Unmounting /boot if necessary");
146 sync();
147 unmount_boot_if_necessary(); // for Gentoo users
148}
149
150/* reset/empty the mr_ar_conf structure from mondo's conf file */
151static void mr_ar_reset_conf(struct mr_ar_conf *mr_cnf) {
152
153 /* This should correspond to the default conf file */
154 /* Especially for boolean values */
155 mr_cnf->iso_creation_cmd = NULL;
156 mr_cnf->iso_creation_opt = NULL;
157 mr_cnf->iso_burning_cmd = NULL;
158 mr_cnf->iso_burning_opt = NULL;
159 mr_cnf->iso_burning_dev = NULL;
160 mr_cnf->iso_burning_speed = 0;
161 mr_cnf->media_size = 0;
162 mr_cnf->media_device = NULL;
163 mr_cnf->iso_burning_dev = NULL;
164 mr_cnf->manual_tray = FALSE;
165 mr_cnf->log_level = 0;
166 mr_cnf->prefix = NULL;
167 mr_cnf->external_tape_blocksize = 0;
168 mr_cnf->internal_tape_blocksize = 0;
169 mr_cnf->kernel = NULL;
170 mr_cnf->additional_modules = NULL;
171 mr_cnf->boot_loader = NULL;
172 mr_cnf->differential = FALSE;
173 mr_cnf->compression_tool = NULL;
174 mr_cnf->compression_level = 0;
175 mr_cnf->exclude_paths = NULL;
176 mr_cnf->include_paths = NULL;
177 mr_cnf->ui_mode = NULL;
178 mr_cnf->automatic_restore = FALSE;
179 mr_cnf->scratch_dir = NULL;
180 mr_cnf->tmp_dir = NULL;
181 mr_cnf->images_dir = NULL;
182}
183
184/* fill the mr_ar_conf structure from mindi's conf file */
185static void mr_ar_store_conf_mindi(struct mr_ar_conf *mr_cnf) {
186
187 char *p = NULL;
188
189 p = mr_conf_sread("mr_iso_creation_cmd");
190 if (p != NULL) {
191 mr_cnf->iso_creation_cmd = p;
192 }
193 p = mr_conf_sread("mr_iso_creation_opt");
194 if (p != NULL) {
195 mr_cnf->iso_creation_opt = p;
196 }
197}
198
199/* create the mr_ar_conf structure from mondo's conf file */
200static void mr_ar_store_conf(struct mr_ar_conf *mr_cnf) {
201
202 char *p = NULL;
203
204 p = mr_conf_sread("mondo_iso_burning_cmd");
205 if (p != NULL) {
206 mr_cnf->iso_burning_cmd = p;
207 }
208
209 p = mr_conf_sread("mondo_iso_burning_opt");
210 if (p != NULL) {
211 mr_cnf->iso_burning_opt = p;
212 }
213
214 p = mr_conf_sread("mondo_iso_burning_dev");
215 if (p != NULL) {
216 mr_cnf->iso_burning_dev = p;
217 }
218
219 p = mr_conf_iread("mondo_iso_burning_speed");
220 if (p != NULL ) {
221 mr_cnf->iso_burning_speed = atoi(p);
222 mr_free(p);
223 }
224
225 p = mr_conf_iread("mondo_media_size");
226 if (p != NULL ) {
227 mr_cnf->media_size = atoi(p);
228 mr_free(p);
229 }
230
231 p = mr_conf_sread("mondo_media_device");
232 if (p != NULL) {
233 mr_cnf->media_device = p;
234 }
235 /* If no specific device name for the burning command (a la ATAPI:0,0,0),
236 * then use the normal device name (a la /dev/hda) */
237 if ((mr_cnf->iso_burning_dev == NULL) && (mr_cnf->media_device != NULL)) {
238 mr_asprintf(&p, mr_cnf->media_device);
239 mr_cnf->iso_burning_dev = p;
240 }
241
242 p = mr_conf_bread("mondo_manual_tray");
243 if (p != NULL) {
244 mr_cnf->manual_tray = mr_atob(p);
245 mr_free(p);
246 }
247
248 p = mr_conf_iread("mondo_log_level");
249 if (p != NULL) {
250 mr_cnf->log_level = atoi(p);
251 mr_free(p);
252 }
253
254 p = mr_conf_sread("mondo_prefix");
255 if (p != NULL) {
256 mr_cnf->prefix = p;
257 }
258
259 p = mr_conf_iread("mondo_external_tape_blocksize");
260 if (p != NULL) {
261 mr_cnf->external_tape_blocksize = atoi(p);
262 mr_free(p);
263 }
264
265 p = mr_conf_iread("mondo_internal_tape_blocksize");
266 if (p != NULL) {
267 mr_cnf->internal_tape_blocksize = atoi(p);
268 mr_free(p);
269 }
270
271 p = mr_conf_sread("mondo_kernel");
272 if (p != NULL) {
273 mr_cnf->kernel = p;
274 }
275
276 p = mr_conf_sread("mondo_additional_modules");
277 if (p != NULL) {
278 mr_cnf->additional_modules = p;
279 }
280
281 p = mr_conf_sread("mondo_boot_loader");
282 if (p != NULL) {
283 mr_cnf->boot_loader = p;
284 }
285
286 p = mr_conf_bread("mondo_differential");
287 if (p != NULL) {
288 mr_cnf->differential = mr_atob(p);
289 mr_free(p);
290 }
291
292 p = mr_conf_sread("mondo_compression_tool");
293 if (p != NULL) {
294 mr_cnf->compression_tool = p;
295 }
296
297 p = mr_conf_sread("mondo_compression_suffix");
298 if (p != NULL) {
299 mr_cnf->compression_suffix = 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->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 stat stbuf;
403 char *tmp = NULL;
404 int res = 0;
405 int retval = 0;
406 char *say_at_end = NULL;
407 char *say_at_end2 = NULL;
408
409#ifdef ENABLE_NLS
410 setlocale(LC_ALL, "");
411 (void) textdomain("mondo");
412#endif
413 printf(_("Initializing...\n"));
414
415 bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
416 reset_bkpinfo();
417
418 /* Reference a dummy cleanup function for mr_exit temporarily */
419 mr_cleanup = &mr_ar_cleanup_empty;
420
421 /* initialize log file with time stamp */
422 /* We start with a loglevel of 4 - Adapted later on */
423 /* It's mandatory to set this up first as all mr_ functions rely on it */
424 unlink(MONDO_LOGFILE);
425 mr_msg_init(MONDO_LOGFILE,4);
426 mr_msg(0, _("Time started: %s"), mr_date());
427
428 /* Make sure I'm root; abort if not */
429 if (getuid() != 0) {
430 mr_log_exit(127, _("Please run as root."));
431 }
432
433 /* If -V, -v or --version then echo version no. and quit */
434 if (argc == 2
435 && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
436 || !strcmp(argv[argc - 1], "--version"))) {
437 printf(_("mondoarchive v%s\nSee man page for help\n"), PACKAGE_VERSION);
438 mr_exit(0, NULL);
439 }
440
441 /* Conf file management */
442 mr_conf = mr_malloc(sizeof(struct mr_ar_conf));
443 mr_ar_reset_conf(mr_conf);
444 /* Check md5 sum before */
445 /* Get content */
446 if (mr_conf_open(MONDO_CONF_DIR"/mondo.conf.dist") != 0) {
447 mr_log_exit(-1, "Unable to open "MONDO_CONF_DIR"/mondo.conf.dist");
448 }
449 mr_ar_store_conf(mr_conf);
450 /* Reference the right cleanup function for mr_exit now it's allocated */
451 mr_cleanup = &mr_ar_cleanup;
452 mr_conf_close();
453
454 if (mr_conf_open(MONDO_CONF_DIR"/mondo.conf") == 0) {
455 mr_ar_store_conf(mr_conf);
456 mr_conf_close();
457 }
458
459 /* Check md5 sum before */
460 /* Get content of mindi conf file now to finish structure initialization */
461/* Tempo Hack */
462#define MINDI_CONF_DIR MONDO_CONF_DIR"/../mindi"
463 if (mr_conf_open(MINDI_CONF_DIR"/mindi.conf.dist") != 0) {
464 mr_log_exit(-1, "Unable to open "MINDI_CONF_DIR"/mindi.conf.dist");
465 }
466 mr_ar_store_conf_mindi(mr_conf);
467 mr_conf_close();
468
469 if (mr_conf_open(MINDI_CONF_DIR"/mindi.conf") == 0) {
470 mr_ar_store_conf_mindi(mr_conf);
471 mr_conf_close();
472 }
473 mr_msg(5, "Command for ISO images is %s", mr_conf->iso_creation_cmd);
474
475 /* Add MONDO_SHARE + other environment variables for mindi */
476 setenv_mondo_var();
477
478 /* Initialize variables */
479 malloc_libmondo_global_strings();
480 diffs = 0;
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 make_hole_for_dir(MONDO_CACHE);
499
500 welcome_to_mondoarchive();
501 distro_specific_kludges_at_start_of_mondoarchive();
502 g_kernel_version = get_kernel_version();
503
504 if (argc == 4 && !strcmp(argv[1], "getfattr")) {
505 mr_conf->log_level = 10;
506 g_text_mode = TRUE;
507 setup_newt_stuff();
508 if (!strstr(argv[2], "filelist")) {
509 mr_msg(1,_("Sorry - filelist goes first\n"));
510 finish(1);
511 } else {
512 finish(get_fattr_list(argv[2], argv[3]));
513 }
514 finish(0);
515 }
516 if (argc == 4 && !strcmp(argv[1], "setfattr")) {
517 mr_conf->log_level = 10;
518 g_text_mode = TRUE;
519 setup_newt_stuff();
520 finish(set_fattr_list(argv[2], argv[3]));
521 }
522
523 if (argc == 3 && !strcmp(argv[1], "wildcards")) {
524 mr_conf->log_level = 10;
525 g_text_mode = TRUE;
526 setup_newt_stuff();
527 tmp = mr_stresc(argv[2], WILDCHARS, BACKSLASH);
528 printf("in=%s; out=%s\n", argv[2], tmp);
529 mr_free(tmp);
530 finish(1);
531 }
532
533 if (argc == 4 && !strcmp(argv[1], "getfacl")) {
534 mr_conf->log_level = 10;
535 g_text_mode = TRUE;
536 setup_newt_stuff();
537 if (!strstr(argv[2], "filelist")) {
538 mr_msg(1,_("Sorry - filelist goes first\n"));
539 finish(1);
540 } else {
541 finish(get_acl_list(argv[2], argv[3]));
542 }
543 finish(0);
544 }
545 if (argc == 4 && !strcmp(argv[1], "setfacl")) {
546 mr_conf->log_level = 10;
547 g_text_mode = TRUE;
548 setup_newt_stuff();
549 finish(set_acl_list(argv[2], argv[3]));
550 }
551
552 if (argc > 2 && !strcmp(argv[1], "find-cd")) {
553 mr_conf->log_level = 10;
554 g_text_mode = TRUE;
555 setup_newt_stuff();
556 malloc_string(tmp);
557 if (find_cdrw_device(tmp)) {
558 mr_msg(1,_("Failed to find CDR-RW drive\n"));
559 } else {
560 mr_msg(1,_("CD-RW is at %s\n"), tmp);
561 }
562 tmp[0] = '\0';
563 if (find_cdrom_device(tmp, atoi(argv[2]))) {
564 mr_msg(1,_("Failed to find CD-ROM drive\n"));
565 } else {
566 mr_msg(1,_("CD-ROM is at %s\n"), tmp);
567 }
568 mr_free(tmp);
569 finish(0);
570 }
571
572 if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
573 mr_conf->log_level = 10;
574 g_text_mode = TRUE;
575 setup_newt_stuff();
576 malloc_string(tmp);
577 if (find_dvd_device(tmp, atoi(argv[2]))) {
578 mr_msg(1,_("Failed to find DVD drive\n"));
579 } else {
580 mr_msg(1,_("DVD is at %s\n"), tmp);
581 }
582 mr_free(tmp);
583 finish(0);
584 }
585
586 if (argc > 2 && !strcmp(argv[1], "disksize")) {
587 printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
588 finish(0);
589 }
590 if (argc > 2 && !strcmp(argv[1], "test-dev")) {
591 if (is_dev_an_NTFS_dev(argv[2])) {
592 mr_msg(1,_("%s is indeed an NTFS dev\n"), argv[2]);
593 } else {
594 mr_msg(1,_("%s is _not_ an NTFS dev\n"), argv[2]);
595 }
596 finish(0);
597 }
598
599 if (pre_param_configuration()) {
600 fatal_error
601 ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
602 }
603 sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
604 bkpinfo->scratchdir);
605
606 /* Process command line, if there is one. If not, ask user for info. */
607 if (argc == 1) {
608 g_text_mode = FALSE;
609 setup_newt_stuff();
610 res = interactively_obtain_media_parameters_from_user(TRUE); /* yes, archiving */
611 if (res) {
612 fatal_error
613 ("Syntax error. Please review the parameters you have supplied and try again.");
614 }
615 } else {
616 res = handle_incoming_parameters(argc, argv);
617 if (res) {
618 mr_msg(1,
619 _("Errors were detected in the command line you supplied.\n"));
620 mr_msg(1,_("Please review the log file - %s \n"),MONDO_LOGFILE);
621 mr_msg(1, "Mondoarchive will now exit.");
622 finish(1);
623 }
624 setup_newt_stuff();
625 }
626
627/* Finish configuring global structures */
628 if (post_param_configuration()) {
629 fatal_error
630 ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
631 }
632
633 log_to_screen
634 (_("BusyBox's sources are available from http://www.busybox.net"));
635
636
637 /* If we're meant to backup then backup */
638 if (bkpinfo->backup_data) {
639 res = backup_data();
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();
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 if (length_of_file(MONDO_CACHE"/changed.files") > 2) {
675 if (g_text_mode) {
676 log_to_screen
677 (_("Type 'less "MONDO_CACHE"/changed.files' to see which files don't match the archives"));
678 } else {
679 mr_msg(1,
680 _("Type 'less "MONDO_CACHE"/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(MONDO_CACHE"/changed.files");
683 mr_msg(2, "Returned from popup_changelist_from_file()");
684 }
685 } else {
686 unlink(MONDO_CACHE"/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 if (bkpinfo->backup_media_type == usb) {
699 log_msg(1, "Unmounting USB device.");
700 mr_asprintf(&tmp, "umount %s1", bkpinfo->media_device);
701 run_program_and_log_output(tmp, TRUE);
702 mr_free(tmp);
703 }
704
705 run_program_and_log_output("mount", 2);
706
707 system("rm -f "MONDO_CACHE"/last-backup.aborted");
708 if (!retval) {
709 printf(_("Mondoarchive ran OK.\n"));
710 } else {
711 printf(_("Errors occurred during backup. Please check logfile.\n"));
712 }
713 distro_specific_kludges_at_end_of_mondoarchive();
714 register_pid(0, "mondo");
715 set_signals(FALSE);
716
717 free_libmondo_global_strings();
718 mr_free(bkpinfo);
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 chdir("/tmp");
732
733 if (!g_text_mode) {
734 popup_and_OK
735 (_("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt."));
736 log_to_screen(_("See %s for details of backup run."), MONDO_LOGFILE);
737 } else {
738 printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
739 mr_exit(retval, NULL);
740 }
741 finish(retval);
742
743 return EXIT_SUCCESS;
744}
Note: See TracBrowser for help on using the repository browser.