Changeset 128 in MondoRescue for branches/2.05/mondo/mondo/mondoarchive/main.c


Ignore:
Timestamp:
Nov 19, 2005, 2:27:41 AM (18 years ago)
Author:
bcornec
Message:

indent on all the C code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.05/mondo/mondo/mondoarchive/main.c

    r30 r128  
    55    copyright            : (C) 2002 by Stan Benoit
    66    email                : troff@nakedsoul.org
    7     cvsid                : $Id: main.c,v 1.14 2004/06/21 20:20:36 hugo Exp $
     7    cvsid                : $Id$
    88 ***************************************************************************/
    99
     
    127127
    128128// for CVS
    129 //static char cvsid[] = "$Id: main.c,v 1.14 2004/06/21 20:20:36 hugo Exp $";
     129//static char cvsid[] = "$Id$";
    130130
    131131/************************* external variables *************************/
    132132extern void set_signals(int);
    133133extern int g_current_media_number;
    134 extern void register_pid(pid_t, char*);
     134extern void register_pid(pid_t, char *);
    135135extern int g_currentY;
    136136extern bool g_text_mode;
     
    141141extern char *g_erase_tmpdir_and_scratchdir;
    142142extern char *g_cdrw_drive_is_here;
    143 static char *g_cdrom_drive_is_here=NULL;
    144 static char *g_dvd_drive_is_here=NULL;
     143static char *g_cdrom_drive_is_here = NULL;
     144static char *g_dvd_drive_is_here = NULL;
    145145extern double g_kernel_version;
    146146
     
    160160void welcome_to_mondoarchive()
    161161{
    162   log_msg (0, "Mondo Archive v%s --- http://www.mondorescue.org", VERSION);
    163   log_msg (0, "running on %s architecture",get_architecture());
    164   log_msg (0,"-----------------------------------------------------------");
    165   log_msg (0, "NB: Mondo logs almost everything, so don't panic if you see");
    166   log_msg (0, "some error messages.  Please read them carefully before you");
    167   log_msg (0, "decide to break out in a cold sweat.    Despite (or perhaps");
    168   log_msg (0, "because of) the wealth of messages. some users are inclined");
    169   log_msg (0, "to stop reading this log. If Mondo stopped for some reason,");
    170   log_msg (0, "chances are it's detailed here.  More than likely there's a");
    171   log_msg (0, "message at the very end of this log that will tell you what");
    172   log_msg (0, "is wrong. Please read it!                          -Devteam");
    173   log_msg (0,"-----------------------------------------------------------");
    174 
    175   log_msg (0, "Zero...");
    176   log_msg (1, "One...");
    177   log_msg (2, "Two...");
    178   log_msg (3, "Three...");
    179   log_msg (4, "Four...");
    180   log_msg (5, "Five...");
    181   log_msg (6, "Six...");
    182   log_msg (7, "Seven...");
    183   log_msg (8, "Eight...");
    184   printf ("See %s for details of backup run.\n", MONDO_LOGFILE);
     162    log_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org",
     163            VERSION);
     164    log_msg(0, "running on %s architecture", get_architecture());
     165    log_msg(0,
     166            "-----------------------------------------------------------");
     167    log_msg(0,
     168            "NB: Mondo logs almost everything, so don't panic if you see");
     169    log_msg(0,
     170            "some error messages.  Please read them carefully before you");
     171    log_msg(0,
     172            "decide to break out in a cold sweat.    Despite (or perhaps");
     173    log_msg(0,
     174            "because of) the wealth of messages. some users are inclined");
     175    log_msg(0,
     176            "to stop reading this log. If Mondo stopped for some reason,");
     177    log_msg(0,
     178            "chances are it's detailed here.  More than likely there's a");
     179    log_msg(0,
     180            "message at the very end of this log that will tell you what");
     181    log_msg(0,
     182            "is wrong. Please read it!                          -Devteam");
     183    log_msg(0,
     184            "-----------------------------------------------------------");
     185
     186    log_msg(0, "Zero...");
     187    log_msg(1, "One...");
     188    log_msg(2, "Two...");
     189    log_msg(3, "Three...");
     190    log_msg(4, "Four...");
     191    log_msg(5, "Five...");
     192    log_msg(6, "Six...");
     193    log_msg(7, "Seven...");
     194    log_msg(8, "Eight...");
     195    printf("See %s for details of backup run.\n", MONDO_LOGFILE);
    185196}
    186197
     
    194205void distro_specific_kludges_at_start_of_mondoarchive()
    195206{
    196   log_msg (2, "Unmounting old ramdisks if necessary");
    197   stop_magicdev_if_necessary(); // for RH+Gnome users
    198   run_program_and_log_output("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
    199   unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
    200   //  stop_autofs_if_necessary(); // for Xandros users
    201   mount_boot_if_necessary(); // for Gentoo users with non-mounted /boot partitions
    202   clean_up_KDE_desktop_if_necessary(); // delete various misc ~/.* files that get in the way
     207    log_msg(2, "Unmounting old ramdisks if necessary");
     208    stop_magicdev_if_necessary();   // for RH+Gnome users
     209    run_program_and_log_output
     210        ("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
     211    unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
     212    //  stop_autofs_if_necessary(); // for Xandros users
     213    mount_boot_if_necessary();  // for Gentoo users with non-mounted /boot partitions
     214    clean_up_KDE_desktop_if_necessary();    // delete various misc ~/.* files that get in the way
    203215}
    204216
     
    211223{
    212224//  char tmp[500];
    213   log_msg( 2, "Restarting magicdev if necessary");
    214   sync();
    215   restart_magicdev_if_necessary(); // for RH+Gnome users
    216 
    217   log_msg( 2, "Restarting autofs if necessary");
    218   sync();
    219   //  restart_autofs_if_necessary(); // for Xandros users
    220 
    221   log_msg( 2, "Restarting supermounts if necessary");
    222   sync();
    223   remount_supermounts_if_necessary(); // for Mandrake users
    224 
    225   log_msg( 2, "Unmounting /boot if necessary");
    226   sync();
    227   unmount_boot_if_necessary(); // for Gentoo users
     225    log_msg(2, "Restarting magicdev if necessary");
     226    sync();
     227    restart_magicdev_if_necessary();    // for RH+Gnome users
     228
     229    log_msg(2, "Restarting autofs if necessary");
     230    sync();
     231    //  restart_autofs_if_necessary(); // for Xandros users
     232
     233    log_msg(2, "Restarting supermounts if necessary");
     234    sync();
     235    remount_supermounts_if_necessary(); // for Mandrake users
     236
     237    log_msg(2, "Unmounting /boot if necessary");
     238    sync();
     239    unmount_boot_if_necessary();    // for Gentoo users
    228240
    229241//  log_msg( 2, "Cleaning up KDE desktop");
     
    240252 * What did you think it did, anyway? :-)
    241253 */
    242 int
    243 main (int argc, char *argv[])
     254int main(int argc, char *argv[])
    244255{
    245   struct s_bkpinfo *bkpinfo;
    246   char *tmp;
    247   int res, retval;
    248   char *say_at_end;
     256    struct s_bkpinfo *bkpinfo;
     257    char *tmp;
     258    int res, retval;
     259    char *say_at_end;
    249260
    250261/* Make sure I'm root; abort if not */
    251   if (getuid () != 0)
    252     {
    253       fprintf (stderr, "Please run as root.\r\n");
    254       exit (127);
    255     }
     262    if (getuid() != 0) {
     263        fprintf(stderr, "Please run as root.\r\n");
     264        exit(127);
     265    }
    256266
    257267/* If -V, -v or --version then echo version no. and quit */
    258   if (argc==2 && (!strcmp(argv[argc-1], "-v") || !strcmp(argv[argc-1], "-V") || !strcmp(argv[argc-1], "--version")))
    259     { printf("mondoarchive v%s\nSee man page for help\n", VERSION); exit(0); }
     268    if (argc == 2
     269        && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
     270            || !strcmp(argv[argc - 1], "--version"))) {
     271        printf("mondoarchive v%s\nSee man page for help\n", VERSION);
     272        exit(0);
     273    }
    260274
    261275/* Initialize variables */
    262276
    263   malloc_libmondo_global_strings();
    264   malloc_string(tmp);
    265   malloc_string(say_at_end);
    266 
    267   res = 0;
    268   retval = 0;
    269   diffs = 0;
    270   say_at_end[0] = '\0';
    271   unlink("/var/log/partimagehack-debug.log");
    272   printf ("Initializing...\n");
    273   if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) { fatal_error("Cannot malloc bkpinfo"); }
     277    malloc_libmondo_global_strings();
     278    malloc_string(tmp);
     279    malloc_string(say_at_end);
     280
     281    res = 0;
     282    retval = 0;
     283    diffs = 0;
     284    say_at_end[0] = '\0';
     285    unlink("/var/log/partimagehack-debug.log");
     286    printf("Initializing...\n");
     287    if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
     288        fatal_error("Cannot malloc bkpinfo");
     289    }
    274290
    275291
    276292/* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
    277   strncpy(tmp, getenv("PATH"), MAX_STR_LEN-1);
    278   tmp[MAX_STR_LEN-1] = '\0';
    279   if (strlen(tmp)>=MAX_STR_LEN-33)
    280     { fatal_error("Your PATH environmental variable is too long. Please shorten it."); }
    281   strcat(tmp, ":/sbin:/usr/sbin:/usr/local/sbin");
    282   setenv("PATH", tmp, 1);
     293    strncpy(tmp, getenv("PATH"), MAX_STR_LEN - 1);
     294    tmp[MAX_STR_LEN - 1] = '\0';
     295    if (strlen(tmp) >= MAX_STR_LEN - 33) {
     296        fatal_error
     297            ("Your PATH environmental variable is too long. Please shorten it.");
     298    }
     299    strcat(tmp, ":/sbin:/usr/sbin:/usr/local/sbin");
     300    setenv("PATH", tmp, 1);
    283301
    284302/* Add the ARCH environment variable for ia64 purposes */
    285   strncpy(tmp, get_architecture(), MAX_STR_LEN-1);
    286   tmp[MAX_STR_LEN-1] = '\0';
    287   setenv("ARCH", tmp, 1);
    288 
    289   unlink(MONDO_LOGFILE);
     303    strncpy(tmp, get_architecture(), MAX_STR_LEN - 1);
     304    tmp[MAX_STR_LEN - 1] = '\0';
     305    setenv("ARCH", tmp, 1);
     306
     307    unlink(MONDO_LOGFILE);
    290308
    291309/* Configure the bkpinfo structure, global file paths, etc. */
    292   g_main_pid = getpid();
    293   log_msg(9, "This");
    294 
    295   register_pid(g_main_pid, "mondo");
    296   set_signals(TRUE); // catch SIGTERM, etc.
    297   nice(10);
    298   run_program_and_log_output("dmesg -n1", TRUE);
    299 
    300   log_msg(9, "Next");
    301   welcome_to_mondoarchive();
    302   distro_specific_kludges_at_start_of_mondoarchive();
    303   sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    304   g_kernel_version = get_kernel_version();
    305 
    306   if (argc==4 && !strcmp(argv[1], "getfattr"))
    307     {
    308       g_loglevel = 10;
    309       g_text_mode = TRUE;
    310       setup_newt_stuff();
    311       if (!strstr(argv[2], "filelist"))
    312         {
    313       printf("Sorry - filelist goes first\n");
    314       finish(1);
    315     }
    316       else
    317         {
    318           finish(get_fattr_list(argv[2], argv[3]));
    319     }
    320       finish(0);
    321     }
    322   if (argc==4 && !strcmp(argv[1], "setfattr"))
    323     {
    324       g_loglevel = 10;
     310    g_main_pid = getpid();
     311    log_msg(9, "This");
     312
     313    register_pid(g_main_pid, "mondo");
     314    set_signals(TRUE);          // catch SIGTERM, etc.
     315    nice(10);
     316    run_program_and_log_output("dmesg -n1", TRUE);
     317
     318    log_msg(9, "Next");
     319    welcome_to_mondoarchive();
     320    distro_specific_kludges_at_start_of_mondoarchive();
     321    sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
     322            bkpinfo->scratchdir);
     323    g_kernel_version = get_kernel_version();
     324
     325    if (argc == 4 && !strcmp(argv[1], "getfattr")) {
     326        g_loglevel = 10;
     327        g_text_mode = TRUE;
     328        setup_newt_stuff();
     329        if (!strstr(argv[2], "filelist")) {
     330            printf("Sorry - filelist goes first\n");
     331            finish(1);
     332        } else {
     333            finish(get_fattr_list(argv[2], argv[3]));
     334        }
     335        finish(0);
     336    }
     337    if (argc == 4 && !strcmp(argv[1], "setfattr")) {
     338        g_loglevel = 10;
    325339//      chdir("/tmp");
    326       g_text_mode = TRUE;
    327       setup_newt_stuff();
    328       finish(set_fattr_list(argv[2], argv[3]));
    329     }
    330    
    331   if (argc==3 && !strcmp(argv[1], "wildcards"))
    332     {
    333       g_loglevel = 10;
    334       g_text_mode = TRUE;
    335       setup_newt_stuff();
    336       turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
    337       printf("in=%s; out=%s\n", argv[2], tmp);
    338       finish(1);
    339     }
    340    
    341   if (argc==4 && !strcmp(argv[1], "getfacl"))
    342     {
    343       g_loglevel = 10;
    344       g_text_mode = TRUE;
    345       setup_newt_stuff();
    346       if (!strstr(argv[2], "filelist"))
    347         {
    348       printf("Sorry - filelist goes first\n");
    349       finish(1);
    350     }
    351       else
    352         {
    353           finish(get_acl_list(argv[2], argv[3]));
    354     }
    355       finish(0);
    356     }
    357   if (argc==4 && !strcmp(argv[1], "setfacl"))
    358     {
    359       g_loglevel = 10;
     340        g_text_mode = TRUE;
     341        setup_newt_stuff();
     342        finish(set_fattr_list(argv[2], argv[3]));
     343    }
     344
     345    if (argc == 3 && !strcmp(argv[1], "wildcards")) {
     346        g_loglevel = 10;
     347        g_text_mode = TRUE;
     348        setup_newt_stuff();
     349        turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
     350        printf("in=%s; out=%s\n", argv[2], tmp);
     351        finish(1);
     352    }
     353
     354    if (argc == 4 && !strcmp(argv[1], "getfacl")) {
     355        g_loglevel = 10;
     356        g_text_mode = TRUE;
     357        setup_newt_stuff();
     358        if (!strstr(argv[2], "filelist")) {
     359            printf("Sorry - filelist goes first\n");
     360            finish(1);
     361        } else {
     362            finish(get_acl_list(argv[2], argv[3]));
     363        }
     364        finish(0);
     365    }
     366    if (argc == 4 && !strcmp(argv[1], "setfacl")) {
     367        g_loglevel = 10;
    360368//      chdir("/tmp");
    361       g_text_mode = TRUE;
    362       setup_newt_stuff();
    363           finish(set_acl_list(argv[2], argv[3]));
    364     }
    365    
    366   if (argc>2 && !strcmp(argv[1], "find-cd"))
    367     {
    368       g_loglevel = 10;
    369       g_text_mode = TRUE;
    370       setup_newt_stuff();
    371       if (find_cdrw_device(tmp))
    372         { printf("Failed to find CDR-RW drive\n"); }
    373       else
    374         { printf("CD-RW is at %s\n", tmp); }
    375       tmp[0] = '\0';
    376       if (find_cdrom_device(tmp, atoi(argv[2])))
    377         { printf("Failed to find CD-ROM drive\n"); }
    378       else
    379         { printf("CD-ROM is at %s\n", tmp); }
    380       finish(0);
    381     }
    382 
    383   if (argc>2 && !strcmp(argv[1], "find-dvd"))
    384     {
    385       g_loglevel = 10;
    386       g_text_mode = TRUE;
    387       setup_newt_stuff();
    388       if (find_dvd_device(tmp, atoi(argv[2])))
    389         { printf("Failed to find DVD drive\n"); }
    390       else
    391         { printf("DVD is at %s\n", tmp); }
    392       finish(0);
    393     }
    394 
    395   if (argc>2 && !strcmp(argv[1], "disksize"))
    396     {
    397       printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
    398       finish(0);
    399     }
    400   if (argc>2 && !strcmp(argv[1], "test-dev"))
    401     {
    402       if (is_dev_an_NTFS_dev(argv[2]))
    403         { printf("%s is indeed an NTFS dev\n", argv[2]); }
    404       else
    405         { printf("%s is _not_ an NTFS dev\n", argv[2]); }
    406       finish(0);
    407     }
    408 
    409   if (pre_param_configuration(bkpinfo)) { fatal_error("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting..."); }
    410    
     369        g_text_mode = TRUE;
     370        setup_newt_stuff();
     371        finish(set_acl_list(argv[2], argv[3]));
     372    }
     373
     374    if (argc > 2 && !strcmp(argv[1], "find-cd")) {
     375        g_loglevel = 10;
     376        g_text_mode = TRUE;
     377        setup_newt_stuff();
     378        if (find_cdrw_device(tmp)) {
     379            printf("Failed to find CDR-RW drive\n");
     380        } else {
     381            printf("CD-RW is at %s\n", tmp);
     382        }
     383        tmp[0] = '\0';
     384        if (find_cdrom_device(tmp, atoi(argv[2]))) {
     385            printf("Failed to find CD-ROM drive\n");
     386        } else {
     387            printf("CD-ROM is at %s\n", tmp);
     388        }
     389        finish(0);
     390    }
     391
     392    if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
     393        g_loglevel = 10;
     394        g_text_mode = TRUE;
     395        setup_newt_stuff();
     396        if (find_dvd_device(tmp, atoi(argv[2]))) {
     397            printf("Failed to find DVD drive\n");
     398        } else {
     399            printf("DVD is at %s\n", tmp);
     400        }
     401        finish(0);
     402    }
     403
     404    if (argc > 2 && !strcmp(argv[1], "disksize")) {
     405        printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
     406        finish(0);
     407    }
     408    if (argc > 2 && !strcmp(argv[1], "test-dev")) {
     409        if (is_dev_an_NTFS_dev(argv[2])) {
     410            printf("%s is indeed an NTFS dev\n", argv[2]);
     411        } else {
     412            printf("%s is _not_ an NTFS dev\n", argv[2]);
     413        }
     414        finish(0);
     415    }
     416
     417    if (pre_param_configuration(bkpinfo)) {
     418        fatal_error
     419            ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
     420    }
     421
    411422/* Process command line, if there is one. If not, ask user for info. */
    412   if (argc==1)
    413     {
    414       g_text_mode = FALSE;
    415       setup_newt_stuff ();
    416       res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE); /* yes, archiving */
    417       if (res) { fatal_error("Syntax error. Please review the parameters you have supplied and try again."); }
    418     }
    419   else
    420     {
    421       res = handle_incoming_parameters (argc, argv, bkpinfo);
    422       if (res) {
    423         printf("Errors were detected in the command line you supplied.\n");
    424     printf("Please review the log file - " MONDO_LOGFILE "\n");
    425         log_msg(1, "Mondoarchive will now exit.");
    426     finish(1);
    427     }
    428       setup_newt_stuff ();
    429     } 
     423    if (argc == 1) {
     424        g_text_mode = FALSE;
     425        setup_newt_stuff();
     426        res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE);   /* yes, archiving */
     427        if (res) {
     428            fatal_error
     429                ("Syntax error. Please review the parameters you have supplied and try again.");
     430        }
     431    } else {
     432        res = handle_incoming_parameters(argc, argv, bkpinfo);
     433        if (res) {
     434            printf
     435                ("Errors were detected in the command line you supplied.\n");
     436            printf("Please review the log file - " MONDO_LOGFILE "\n");
     437            log_msg(1, "Mondoarchive will now exit.");
     438            finish(1);
     439        }
     440        setup_newt_stuff();
     441    }
    430442
    431443/* Finish configuring global structures */
    432   if (post_param_configuration (bkpinfo)) { fatal_error("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting..."); }
    433 
    434   log_to_screen("BusyBox's sources are available from http://www.busybox.net");
    435   sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    436 
    437   /* If we're meant to backup then backup */
    438   if (bkpinfo->backup_data)
    439     {
     444    if (post_param_configuration(bkpinfo)) {
     445        fatal_error
     446            ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
     447    }
     448
     449    log_to_screen
     450        ("BusyBox's sources are available from http://www.busybox.net");
     451    sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
     452            bkpinfo->scratchdir);
     453
     454    /* If we're meant to backup then backup */
     455    if (bkpinfo->backup_data) {
    440456/*
    441457      log_to_screen("INFERNAL PORPOISES");
     
    444460      finish(0);
    445461*/
    446       res = backup_data(bkpinfo);
    447       retval += res;
    448       if (res)
    449     { strcat (say_at_end, "Data archived. Please check the logs, just as a precaution. "); }
    450       else
    451     { strcat (say_at_end, "Data archived OK. "); }
    452     }
     462        res = backup_data(bkpinfo);
     463        retval += res;
     464        if (res) {
     465            strcat(say_at_end,
     466                   "Data archived. Please check the logs, just as a precaution. ");
     467        } else {
     468            strcat(say_at_end, "Data archived OK. ");
     469        }
     470    }
    453471
    454472/* If we're meant to verify then verify */
    455   if (bkpinfo->verify_data)
    456     {
    457       res = verify_data(bkpinfo);
    458       if (res<0)
    459         {
    460           sprintf(tmp, "%d difference%c found.", -res, (-res != 1) ? 's' : ' ');
    461       strcat(say_at_end, tmp);
    462           log_to_screen(tmp);
    463           res=0;
    464         }
    465       retval += res;
    466     }
     473    if (bkpinfo->verify_data) {
     474        res = verify_data(bkpinfo);
     475        if (res < 0) {
     476            sprintf(tmp, "%d difference%c found.", -res,
     477                    (-res != 1) ? 's' : ' ');
     478            strcat(say_at_end, tmp);
     479            log_to_screen(tmp);
     480            res = 0;
     481        }
     482        retval += res;
     483    }
    467484
    468485/* Offer to write floppy disk images to physical disks */
    469   if (bkpinfo->backup_data && !g_skip_floppies)
    470     {
    471       res = offer_to_write_boot_floppies_to_physical_disks(bkpinfo);
    472       retval += res;
     486    if (bkpinfo->backup_data && !g_skip_floppies) {
     487        res = offer_to_write_boot_floppies_to_physical_disks(bkpinfo);
     488        retval += res;
    473489//      res = offer_to_write_boot_ISO_to_physical_CD(bkpinfo);
    474490//      retval += res;
    475     }
     491    }
    476492
    477493/* Report result of entire operation (success? errors?) */
    478   if (!retval)
    479     {
    480       mvaddstr_and_log_it (g_currentY++, 0,
    481                "Backup and/or verify ran to completion. Everything appears to be fine.");
    482     }
    483   else
    484     {
    485       mvaddstr_and_log_it (g_currentY++, 0,
    486              "Backup and/or verify ran to completion. However, errors did occur.");
    487     }
    488 
    489   if (does_file_exist ("/root/images/mindi/mondorescue.iso"))
    490     {
    491       log_to_screen ("/root/images/mindi/mondorescue.iso, a boot/utility CD, is available if you want it.");
    492     }
    493 
    494 
    495   if (length_of_file ("/tmp/changed.files") > 2)
    496     {
    497       if (g_text_mode) { log_to_screen("Type 'less /tmp/changed.files' to see which files don't match the archives"); }
    498       else
    499         {
    500           log_msg (1, "Type 'less /tmp/changed.files' to see which files don't match the archives");
    501           log_msg (2, "Calling popup_changelist_from_file()");
    502           popup_changelist_from_file("/tmp/changed.files");
    503           log_msg (2, "Returned from popup_changelist_from_file()");
    504         }
    505     }
    506   else
    507     {
    508       unlink ("/tmp/changed.files");
    509     }
    510   log_to_screen (say_at_end);
    511   sprintf (tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
    512   run_program_and_log_output (tmp, TRUE);
    513   run_program_and_log_output (g_erase_tmpdir_and_scratchdir, TRUE);
    514 
    515   run_program_and_log_output("mount", 2);
    516 
    517   if (bkpinfo->please_dont_eject)
    518     {
    519       log_msg(5, "Not ejecting at end. Fair enough.");
    520     }
    521   else
    522     {
    523       log_msg(5, "Ejecting at end.");
    524       if (!find_cdrom_device(tmp, FALSE) || !find_dvd_device(tmp, FALSE))
    525     {
    526       log_msg(1, "Ejecting %s", tmp);
    527       eject_device(tmp);
    528     }
    529     }
    530 
    531   system("rm -f /var/cache/mondo-archive/last-backup.aborted");
    532   system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
    533   if (!retval) { printf("Mondoarchive ran OK.\n"); }
    534   else { printf("Errors occurred during backup. Please check logfile.\n"); }
    535   distro_specific_kludges_at_end_of_mondoarchive();
    536   register_pid(0,"mondo");
    537   set_signals(FALSE);
    538   chdir("/tmp"); // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
    539   system(g_erase_tmpdir_and_scratchdir);
    540   free_libmondo_global_strings();
    541   paranoid_free(say_at_end);
    542   paranoid_free(tmp);
    543   paranoid_free(bkpinfo);
    544 
    545   unlink("/tmp/filelist.full");
    546   unlink("/tmp/filelist.full.gz");
    547  
    548   if (!g_cdrom_drive_is_here) { log_msg(10, "FYI, g_cdrom_drive_is_here was never used"); }
    549   if (!g_dvd_drive_is_here) { log_msg(10, "FYI, g_dvd_drive_is_here was never used"); }
    550 
    551   if (!g_text_mode)
    552     {
    553       popup_and_OK
    554     ("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt.");
    555       log_to_screen("See %s for details of backup run.", MONDO_LOGFILE);
    556       finish(retval);
    557     }
    558   else
    559     {
    560       printf ("See %s for details of backup run.\n", MONDO_LOGFILE);
    561       exit(retval);
    562     }
    563 
    564   return EXIT_SUCCESS;
     494    if (!retval) {
     495        mvaddstr_and_log_it(g_currentY++, 0,
     496                            "Backup and/or verify ran to completion. Everything appears to be fine.");
     497    } else {
     498        mvaddstr_and_log_it(g_currentY++, 0,
     499                            "Backup and/or verify ran to completion. However, errors did occur.");
     500    }
     501
     502    if (does_file_exist("/root/images/mindi/mondorescue.iso")) {
     503        log_to_screen
     504            ("/root/images/mindi/mondorescue.iso, a boot/utility CD, is available if you want it.");
     505    }
     506
     507
     508    if (length_of_file("/tmp/changed.files") > 2) {
     509        if (g_text_mode) {
     510            log_to_screen
     511                ("Type 'less /tmp/changed.files' to see which files don't match the archives");
     512        } else {
     513            log_msg(1,
     514                    "Type 'less /tmp/changed.files' to see which files don't match the archives");
     515            log_msg(2, "Calling popup_changelist_from_file()");
     516            popup_changelist_from_file("/tmp/changed.files");
     517            log_msg(2, "Returned from popup_changelist_from_file()");
     518        }
     519    } else {
     520        unlink("/tmp/changed.files");
     521    }
     522    log_to_screen(say_at_end);
     523    sprintf(tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
     524    run_program_and_log_output(tmp, TRUE);
     525    run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
     526
     527    run_program_and_log_output("mount", 2);
     528
     529    if (bkpinfo->please_dont_eject) {
     530        log_msg(5, "Not ejecting at end. Fair enough.");
     531    } else {
     532        log_msg(5, "Ejecting at end.");
     533        if (!find_cdrom_device(tmp, FALSE) || !find_dvd_device(tmp, FALSE)) {
     534            log_msg(1, "Ejecting %s", tmp);
     535            eject_device(tmp);
     536        }
     537    }
     538
     539    system("rm -f /var/cache/mondo-archive/last-backup.aborted");
     540    system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
     541    if (!retval) {
     542        printf("Mondoarchive ran OK.\n");
     543    } else {
     544        printf("Errors occurred during backup. Please check logfile.\n");
     545    }
     546    distro_specific_kludges_at_end_of_mondoarchive();
     547    register_pid(0, "mondo");
     548    set_signals(FALSE);
     549    chdir("/tmp");              // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
     550    system(g_erase_tmpdir_and_scratchdir);
     551    free_libmondo_global_strings();
     552    paranoid_free(say_at_end);
     553    paranoid_free(tmp);
     554    paranoid_free(bkpinfo);
     555
     556    unlink("/tmp/filelist.full");
     557    unlink("/tmp/filelist.full.gz");
     558
     559    if (!g_cdrom_drive_is_here) {
     560        log_msg(10, "FYI, g_cdrom_drive_is_here was never used");
     561    }
     562    if (!g_dvd_drive_is_here) {
     563        log_msg(10, "FYI, g_dvd_drive_is_here was never used");
     564    }
     565
     566    if (!g_text_mode) {
     567        popup_and_OK
     568            ("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt.");
     569        log_to_screen("See %s for details of backup run.", MONDO_LOGFILE);
     570        finish(retval);
     571    } else {
     572        printf("See %s for details of backup run.\n", MONDO_LOGFILE);
     573        exit(retval);
     574    }
     575
     576    return EXIT_SUCCESS;
    565577}
    566 
    567 
Note: See TracChangeset for help on using the changeset viewer.