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

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

Continue on configuration file items (compression)

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