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

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