Changeset 818


Ignore:
Timestamp:
Sep 23, 2006, 11:10:46 AM (13 years ago)
Author:
andree
Message:

Enhance the way we deal with post-nuke:

  • ask whether post-nuke should be executed if it exists even if we are not in nuke mode;
  • log the fact that no post-nuke script was found during restore;
  • perform after nuke steps even if we dropped back to interacive mode because of issue with mount list;
  • ask user after nuke to wait until s/he is returned to command prompt before rebooting;
  • use run_program_and_log_output() instead of system() to get output of post-nuke logged;
  • output screen messages about post-nuke.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/mondo/mondorestore/mondo-restore.c

    r812 r818  
    11191119        if (ask_me_yes_or_no(tmp)) {
    11201120            retval = interactive_mode(bkpinfo, mountlist, raidlist);
    1121             finish(retval);
     1121            goto after_the_nuke;
    11221122        } else {
    11231123            fatal_error("Nuke Mode aborted. ");
     
    12271227            ("Please visit our website at http://www.mondorescue.org for more information.");
    12281228    } else {
    1229         strcpy(tmp," Mondo has restored your system. Please remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
     1229        strcpy(tmp,"Mondo has restored your system.\n\nPlease wait for the command prompt. Then remove the backup media and reboot.\n\nPlease visit our website at http://www.mondorescue.org for more information.");
    12301230        if (strstr(call_program_and_get_last_line_of_output("cat /proc/cmdline"), "restore") == NULL) {
    12311231            popup_and_OK(tmp);
    12321232        }
    12331233        log_to_screen
    1234             ("Mondo has restored your system. Please remove the backup media and reboot.");
     1234          ("Mondo has restored your system. Please wait for the command prompt.");
     1235        log_to_screen
     1236            ("Then remove the backup media and reboot.");
    12351237        log_to_screen
    12361238            ("Please visit our website at http://www.mondorescue.org for more information.");
     
    31983200    struct s_node *filelist;
    31993201    char *a, *b;
     3202    bool run_postnuke = FALSE;
    32003203
    32013204  /**************************************************************************
     
    36063609
    36073610// g_I_have_just_nuked is set true by nuke_mode() just before it returns
    3608     if (g_I_have_just_nuked || does_file_exist("/POST-NUKE-ANYWAY")) {
    3609         if (!system("which post-nuke > /dev/null 2> /dev/null")) {
    3610             log_msg(1, "post-nuke found; running...");
    3611             if (mount_all_devices(mountlist, TRUE)) {
    3612                 log_to_screen
    3613                     ("Unable to re-mount partitions for post-nuke stuff");
    3614             } else {
    3615                 log_msg(1, "Re-mounted partitions for post-nuke stuff");
    3616                 sprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path,
    3617                         retval);
    3618                 if (!g_text_mode) {
    3619                     newtSuspend();
    3620                 }
    3621                 log_msg(2, "Calling '%s'", tmp);
    3622                 if ((res = system(tmp))) {
    3623                     log_OS_error(tmp);
    3624                 }
    3625                 if (!g_text_mode) {
    3626                     newtResume();
    3627                 }
    3628 //              newtCls();
    3629                 log_msg(1, "post-nuke returned w/ res=%d", res);
    3630             }
    3631             unmount_all_devices(mountlist);
    3632             log_msg(1, "I've finished post-nuking.");
    3633         }
    3634     }
     3611    if (!system("which post-nuke > /dev/null 2> /dev/null")) {
     3612      log_msg(1, "post-nuke found; find out whether we should run it...");
     3613      if (g_I_have_just_nuked || does_file_exist("/POST-NUKE-ANYWAY")) {
     3614        run_postnuke = TRUE;
     3615        log_msg(1, "Yes, will run post-nuke because in nuke mode or file /POST-NUKE-ANYWAY exists.");
     3616      } else if (ask_me_yes_or_no("post-nuke script found. Do you want to run it?")) {
     3617        run_postnuke = TRUE;
     3618        log_msg(1, "Yes, will run post-nuke because user interactively asked for it.");
     3619      } else {
     3620        run_postnuke = FALSE;
     3621        log_msg(1, "No, will not run post-nuke.");
     3622      }
     3623    } else {
     3624      log_msg(1, "No post-nuke found.");
     3625    }
     3626    if (run_postnuke) {
     3627      log_to_screen("Running post-nuke...");
     3628      if (mount_all_devices(mountlist, TRUE)) {
     3629        log_to_screen
     3630          ("Unable to re-mount partitions for post-nuke stuff");
     3631      } else {
     3632        log_msg(1, "Re-mounted partitions for post-nuke stuff");
     3633        sprintf(tmp, "post-nuke %s %d", bkpinfo->restore_path,
     3634            retval);
     3635        log_msg(2, "Calling '%s'", tmp);
     3636        if ((res = run_program_and_log_output(tmp, 0))) {
     3637          log_OS_error(tmp);
     3638        }
     3639        log_msg(1, "post-nuke returned w/ res=%d", res);
     3640      }
     3641      unmount_all_devices(mountlist);
     3642      log_to_screen("I've finished post-nuking.");
     3643    }
     3644
    36353645/* 
    36363646  log_to_screen("If you are REALLY in a hurry, hit Ctrl-Alt-Del now.");
Note: See TracChangeset for help on using the changeset viewer.