Changeset 3193 in MondoRescue for branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Sep 29, 2013, 9:31:34 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.1/mondo/src/mondorestore/mondo-rstr-tools.c
r3161 r3193 90 90 fatal_error("Cannot openin outfname"); 91 91 } 92 for (mr_getline(incoming, fin); !feof(fin) ; mr_getline(incoming, fin)) {92 for (mr_getline(incoming, fin); !feof(fin) && (incoming != NULL); mr_getline(incoming, fin)) { 93 93 mr_strip_spaces(incoming); 94 94 … … 140 140 } 141 141 if (file[0] == '/' && file[1] == '/') { 142 mr_asprintf(tmp, "%s", file); 143 mr_free(file); 142 tmp = file; 144 143 145 144 mr_asprintf(file, "%s", tmp + 1); … … 174 173 * @return 0 for success, nonzero for failure. 175 174 */ 176 int iso_fiddly_bits(bool nuke_me_please) 177 { 178 179 180 181 182 175 int iso_fiddly_bits(bool nuke_me_please) { 176 177 char *mount_isodir_command = NULL; 178 char *command = NULL; 179 char *mds = NULL; 180 int retval = 0, i; 181 char *isodir_format = NULL; 183 182 184 183 g_ISO_restore_mode = TRUE; … … 305 304 mr_strcat(additional_parameters, "-o ro"); 306 305 } 306 mr_free(tmp); 307 307 308 tmp = find_home_of_exe("setfattr"); 308 309 if (tmp) { … … 374 375 mr_free(mountpoint); 375 376 376 377 return (res); 377 378 } 378 379 /************************************************************************** … … 418 419 mr_free(tmp); 419 420 res = mount_device(mountlist->el[lino].device, mountlist->el[lino].mountpoint, mountlist->el[lino].format, writeable); 420 421 421 retval += res; 422 422 if (res) { … … 660 660 assert(bkpinfo != NULL); 661 661 assert(cfgf != NULL); 662 log_it("Entering read_cfg_file_into_bkpinfo"); 662 663 663 664 media_specified_by_user = bkpinfo->backup_media_type; // or 'none', if not specified … … 676 677 bkpinfo->please_dont_eject = TRUE; 677 678 } else if (!strcmp(value, "iso")) { 678 // Patch by Conor Daly - 2004/07/12679 679 bkpinfo->backup_media_type = iso; 680 680 if (am_I_in_disaster_recovery_mode()) { … … 687 687 bkpinfo->backup_media_type = cdr; 688 688 run_program_and_log_output("umount -d "MNT_CDROM, 1); 689 log_it 690 ("Re-jigging configuration AGAIN. CD-R, not ISO."); 689 log_it("Re-jigging configuration AGAIN. CD-R, not ISO."); 691 690 } 692 691 } … … 698 697 mr_asprintf(bkpinfo->prefix, "%s", STD_PREFIX); 699 698 } 699 log_it("Setting Prefix to %s", bkpinfo->prefix); 700 700 } else if ((!strcmp(value, "netfs")) || (!strcmp(value, "nfs"))) { 701 701 /* Stay compatible with previous versions by allowing nfs as an entry here */ … … 727 727 tmp = call_program_and_get_last_line_of_output("cat " CMDLINE,TRUE); 728 728 if (strstr(tmp, "pxe")) { 729 /* We need to override prefix value in PXE mode as it's 729 /* We need to override prefix value in PXE mode as it's 730 730 * already done in start-netfs */ 731 731 envtmp1 = getenv("imgname"); … … 754 754 mr_free(bkpinfo->media_device); 755 755 mr_asprintf(bkpinfo->media_device, "/dev/cdrom"); 756 bkpinfo->media_size[0] = 1999 * 1024; 757 bkpinfo->media_size[1] = 650; /* good guess */ 756 bkpinfo->media_size = 650; /* good guess */ 758 757 } else if (bkpinfo->backup_media_type == usb) { 759 758 envtmp1 = getenv("MRUSBDEV"); … … 778 777 value = read_cfg_var(cfg_file, "media-size"); 779 778 if (value != NULL) { 780 bkpinfo->media_size [1]= atol(value);779 bkpinfo->media_size = atol(value); 781 780 mr_free(value); 782 781 } else { 783 bkpinfo->media_size [1]= 0L;782 bkpinfo->media_size = 0L; 784 783 } 785 784 log_msg(2, "Backup medium is TAPE --- dev=%s", bkpinfo->media_device); … … 787 786 mr_free(bkpinfo->media_device); 788 787 mr_asprintf(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */ 789 bkpinfo->media_size[0] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 790 bkpinfo->media_size[1] = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 791 log_msg(2, "Backup medium is CD-R[W]"); 788 bkpinfo->media_size = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 789 log_msg(2, "Backup medium is similar to CD-R[W]"); 792 790 } 793 791 } else { … … 968 966 mr_free(tmp1); 969 967 } 970 971 968 } else if (bkpinfo->backup_media_type == iso) { 972 969 /* Patch by Conor Daly 23-june-2004 … … 1044 1041 if (! bkpinfo->disaster_recovery) { 1045 1042 if (bkpinfo->backup_media_type != media_specified_by_user) { 1046 log_msg(2, 1047 "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)"); 1043 log_msg(2, "bkpinfo->backup_media_type != media_specified_by_user, so I'd better ask :)"); 1048 1044 interactively_obtain_media_parameters_from_user(FALSE); 1049 1045 media_specified_by_user = bkpinfo->backup_media_type; … … 1086 1082 int res = 0; 1087 1083 pid_t pid; 1084 bool extract_mountlist_stub = FALSE; 1088 1085 1089 1086 assert(bkpinfo != NULL); … … 1234 1231 popup_and_OK("You'll now be chrooted under your future / partition.\nEdit /etc/mkinitcpio.conf if needed and rebuild your initrd with the kernel preset name e.g.\nmkinitcpio -p kernel26\nThen type exit to finish.\n"); 1235 1232 } else { 1236 popup_and_OK("You'll now be chrooted under your future / partition.\nGo under /boot and rebuild your init rd with\nmkinitrd -f -v initrd-2.x.y.img 2.x.y e.g.\nThen type exit to finish.");1233 popup_and_OK("You'll now be chrooted under your future / partition.\nGo under /boot and rebuild your init(rd|ramfs) with\nmkinitrd -f -v initrd-2.x.y.img 2.x.y e.g.\nor initramfs, dracut, ... Then type exit to finish."); 1237 1234 } 1238 1235 mvaddstr_and_log_it(g_currentY, 0, "Modifying initrd..."); … … 1435 1432 1436 1433 if ((res) || (mntlistchg)) { 1437 popup_and_OK("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install"); 1438 } else { 1439 popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install"); 1440 } 1441 if (!g_text_mode) { 1442 newtSuspend(); 1443 } 1444 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1445 paranoid_system(tmp); 1446 mr_free(tmp); 1447 1448 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1449 paranoid_system(tmp); 1450 mr_free(tmp); 1451 1452 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) { 1453 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1454 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) { 1455 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor); 1456 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) { 1457 mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor); 1458 } 1459 paranoid_system(tmp); 1460 mr_free(tmp); 1461 1462 if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) { 1434 if (res) { 1435 popup_and_OK("GRUB installation failed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install"); 1436 } else { 1437 popup_and_OK("The mountlist was changed. You will now edit fstab, mtab, device.map and menu.lst/grub.cfg in order to fix grub install"); 1438 } 1439 if (!g_text_mode) { 1440 newtSuspend(); 1441 } 1442 mr_asprintf(editor, "%s", find_my_editor()); 1443 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1444 paranoid_system(tmp); 1445 mr_free(tmp); 1446 1447 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1448 paranoid_system(tmp); 1449 mr_free(tmp); 1450 1451 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) { 1452 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1453 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) { 1454 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor); 1455 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/grub.cfg")) { 1456 mr_asprintf(tmp, "chroot %s %s /boot/grub2/grub.cfg", MNT_RESTORING, editor); 1457 } 1458 paranoid_system(tmp); 1459 mr_free(tmp); 1460 1461 if (does_file_exist(MNT_RESTORING"/boot/grub/device.map")) { 1462 mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1463 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) { 1464 mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor); 1465 } 1466 paranoid_system(tmp); 1467 mr_free(tmp); 1468 1469 if (!g_text_mode) { 1470 newtResume(); 1471 } 1472 mr_asprintf(command, "stabgrub-me %s", boot_device); 1473 res = run_program_and_log_output(command, 1); 1474 mr_free(command); 1475 1476 if (res) { 1477 popup_and_OK("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done."); 1478 newtSuspend(); 1479 paranoid_system("chroot " MNT_RESTORING); 1480 newtResume(); 1481 popup_and_OK("Thank you."); 1482 } else { 1483 popup_and_OK("GRUB is now installed correctly"); 1484 done = TRUE; 1485 } 1486 popup_and_OK("You will now edit fstab, mtab, device.map and menu.lst/grub.cfg"); 1487 if (!g_text_mode) { 1488 newtSuspend(); 1489 } 1490 1491 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1492 paranoid_system(tmp); 1493 mr_free(tmp); 1494 1495 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1496 paranoid_system(tmp); 1497 mr_free(tmp); 1498 1499 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) { 1500 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1501 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) { 1502 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor); 1503 } 1504 paranoid_system(tmp); 1505 mr_free(tmp); 1506 1463 1507 mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1464 } else if (does_file_exist(MNT_RESTORING"/boot/grub2/device.map")) { 1465 mr_asprintf(tmp, "chroot %s %s /boot/grub2/device.map", MNT_RESTORING, editor); 1466 } 1467 paranoid_system(tmp); 1468 mr_free(tmp); 1469 1470 if (!g_text_mode) { 1471 newtResume(); 1472 } 1473 mr_asprintf(command, "stabgrub-me %s", boot_device); 1474 res = run_program_and_log_output(command, 1); 1475 mr_free(command); 1476 if (res) { 1477 popup_and_OK("GRUB installation failed. Please fix the conf files so that a manual install using 'grub-install' or similar command works. You are now chroot()'ed to your restored system. Please type 'exit' when you are done."); 1478 newtSuspend(); 1479 paranoid_system("chroot " MNT_RESTORING); 1480 newtResume(); 1481 popup_and_OK("Thank you."); 1482 } else { 1483 popup_and_OK("GRUB is now installed correctly"); 1484 done = TRUE; 1485 } 1486 popup_and_OK("You will now edit fstab, mtab, device.map and menu.lst/grub.cfg"); 1487 if (!g_text_mode) { 1488 newtSuspend(); 1489 } 1490 mr_asprintf(editor, "%s", find_my_editor()); 1491 1492 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1493 paranoid_system(tmp); 1494 mr_free(tmp); 1495 1496 mr_asprintf(tmp, "chroot %s %s /etc/mtab", MNT_RESTORING, editor); 1497 paranoid_system(tmp); 1498 mr_free(tmp); 1499 1500 if (does_file_exist(MNT_RESTORING"/boot/grub/menu.lst")) { 1501 mr_asprintf(tmp, "chroot %s %s /boot/grub/menu.lst", MNT_RESTORING, editor); 1502 } else if (does_file_exist(MNT_RESTORING"/boot/grub/grub.cfg")) { 1503 mr_asprintf(tmp, "chroot %s %s /boot/grub/grub.cfg", MNT_RESTORING, editor); 1504 } 1505 paranoid_system(tmp); 1506 mr_free(tmp); 1507 1508 mr_asprintf(tmp, "chroot %s %s /boot/grub/device.map", MNT_RESTORING, editor); 1509 paranoid_system(tmp); 1510 mr_free(tmp); 1511 mr_free(editor); 1512 1513 if (!g_text_mode) { 1514 newtResume(); 1508 paranoid_system(tmp); 1509 mr_free(tmp); 1510 mr_free(editor); 1511 1512 if (!g_text_mode) { 1513 newtResume(); 1514 } 1515 1515 } 1516 1516 } … … 1525 1525 log_msg(1, "WARNING - grub-MR not found; using grub-install"); 1526 1526 } 1527 mvaddstr_and_log_it(g_currentY, 1528 0, 1529 "Running GRUB... "); 1527 mvaddstr_and_log_it(g_currentY, 0, "Running GRUB... "); 1530 1528 log_it("%s",command); 1531 1529 res = run_program_and_log_output(command, 1); … … 1611 1609 paranoid_system(tmp); 1612 1610 mr_free(tmp); 1613 1614 1611 mr_free(editor); 1615 1612 … … 1688 1685 paranoid_system(tmp); 1689 1686 mr_free(tmp); 1690 1691 1687 mr_free(editor); 1692 1688 … … 2114 2110 paranoid_free(raidlist); 2115 2111 } 2116 2117
Note:
See TracChangeset
for help on using the changeset viewer.