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

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

More conf file items handled

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