Changeset 3879 in MondoRescue for branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c
- Timestamp:
- Mar 9, 2024, 3:10:04 AM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c
r3876 r3879 10 10 #include "mr_file.h" 11 11 #include "mr_sys.h" 12 #include "../common/mondostructures.h" 13 #include "../common/libmondo.h" 14 #include "mr-externs.h" 15 #include "mondo-rstr-tools.h" 12 #include "mondostructures.h" 16 13 #include "libmondo-mountlist-EXT.h" 14 #include "libmondo-tools-EXT.h" 15 #include "libmondo-filelist-EXT.h" 16 #include "libmondo-files-EXT.h" 17 #include "libmondo-devices-EXT.h" 18 #include "libmondo-string-EXT.h" 19 #include "libmondo-raid-EXT.h" 20 #include "libmondo-fork-EXT.h" 17 21 #include "newt-specific-EXT.h" 22 // no include for now in mondo-rstr-newt.c 23 extern int edit_filelist(struct s_node *); 18 24 19 25 /** … … 74 80 extern char *g_mountlist_fname; // where mountlist.txt (the mountlist file) is stored 75 81 extern char *g_mondo_home; // homedir of Mondo; usually /usr/local/share/mondo 82 extern int g_currentY; 83 extern bool g_restoring_live_from_cd; 84 extern bool g_text_mode; 85 extern int g_current_media_number; 76 86 77 87 extern t_bkptype g_backup_media_type; … … 169 179 170 180 171 181 /** 182 * Extract mondorestore.cfg and the mountlist from the tape inserted 183 * to the ./tmp/ directory. 184 * @param dev The tape device to read from. 185 * @return 0 for success, nonzero for failure. 186 */ 187 int extract_cfg_file_and_mountlist_from_tape_dev(char *dev) 188 { 189 char *command = NULL; 190 int res = 0; 191 192 if (bkpinfo->use_obdr) { 193 skip_obdr(); 194 } else { 195 // TODO: below 32KB seems to block at least on RHAS 2.1 and MDK 10.0 196 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size); 197 } 198 199 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 200 log_msg(2, "command = '%s'", command); 201 res = run_program_and_log_output(command, -1); 202 mr_free(command); 203 204 if (res != 0) { 205 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 206 res = 0; 207 } else { 208 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 209 log_msg(2, "pre-2.2.4 compatible mode on"); 210 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); 211 log_msg(2, "command = '%s'", command); 212 res = run_program_and_log_output(command, -1); 213 mr_free(command); 214 if ((res != 0) && (does_file_exist(MONDO_CFG_FILE_STUB))) { 215 res = 0; 216 } 217 } 218 } 219 paranoid_free(command); 220 return (res); 221 } 222 223 224 225 226 227 /** 228 * Get the configuration file from the tape, or CD. 229 * @param bkpinfo The backup information structure. Fields used: 230 * - @c bkpinfo->backup_media_type 231 * - @c bkpinfo->media_device 232 * - @c bkpinfo->tmpdir 233 * @return 0 for success, nonzero for failure. 234 */ 235 int get_cfg_file_from_archive() 236 { 237 int retval = 0; 238 239 /** malloc *****/ 240 char *command = NULL; 241 char *cfg_file = NULL; 242 char *tmp = NULL; 243 char *tmp1 = NULL; 244 char *mountpt = NULL; 245 char *mountlist_file = NULL; 246 bool extract_mountlist_stub = FALSE; 247 bool extract_i_want_my_lvm = FALSE; 248 249 bool try_plan_B; 250 251 assert(bkpinfo != NULL); 252 log_msg(2, "gcffa --- starting"); 253 log_to_screen("I'm thinking..."); 254 mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir); 255 if (chdir(bkpinfo->tmpdir)) { 256 // FIXME 257 } 258 mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB); 259 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent 260 mr_free(cfg_file); 261 262 unlink(FILELIST_FULL_STUB); 263 unlink(BIGGIELIST_TXT_STUB); 264 mr_asprintf(command, "mkdir -p %s", mountpt); 265 run_program_and_log_output(command, FALSE); 266 mr_free(command); 267 268 mr_asprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB); 269 mr_asprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 270 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file); 271 mr_free(mountpt); 272 273 if (!does_file_exist(cfg_file)) { 274 log_msg(2, "gcffa --- we don't have cfg file yet."); 275 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) { 276 try_plan_B = TRUE; 277 } else { 278 log_msg(2, "gcffa --- calling mount_media now :)"); 279 if (!mount_media(MNT_CDROM)) { 280 log_msg(2, "gcffa --- managed to mount CD; so, no need for Plan B"); 281 try_plan_B = FALSE; 282 } else { 283 try_plan_B = TRUE; 284 } 285 if (what_number_cd_is_this() > 1) { 286 insist_on_this_cd_number((g_current_media_number = 1)); 287 } 288 } 289 if (try_plan_B) { 290 log_msg(2, "gcffa --- OK, switching to Plan B"); 291 if (chdir(bkpinfo->tmpdir)) { 292 // FIXME 293 } 294 run_program_and_log_output("mkdir -p tmp", FALSE); 295 296 if (bkpinfo->media_device == NULL) { 297 mr_asprintf(bkpinfo->media_device, "%s", "/dev/st0"); 298 log_msg(2, "media_device is blank; assuming %s", bkpinfo->media_device); 299 } 300 mr_asprintf(tmp, "%s", bkpinfo->media_device); 301 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 302 mr_free(bkpinfo->media_device); 303 mr_asprintf(bkpinfo->media_device, "%s", "/dev/st0"); 304 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 305 mr_free(bkpinfo->media_device); 306 mr_asprintf(bkpinfo->media_device, "%s", "/dev/osst0"); 307 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 308 mr_free(bkpinfo->media_device); 309 mr_asprintf(bkpinfo->media_device, "%s", "/dev/ht0"); 310 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 311 log_msg(3, "I tried lots of devices but none worked."); 312 mr_free(bkpinfo->media_device); 313 } 314 } 315 } 316 } 317 if (bkpinfo->media_device == NULL) { 318 bkpinfo->media_device = tmp; 319 } else { 320 mr_free(tmp); 321 } 322 323 if (!does_file_exist("tmp/mondorestore.cfg")) { 324 log_to_screen("Cannot find config info on media"); 325 return (1); 326 } 327 } else { 328 if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) { 329 extract_mountlist_stub = FALSE; 330 } else { 331 extract_mountlist_stub = TRUE; 332 } 333 if (does_file_exist("/"IWANTMYLVM_STUB)) { 334 extract_i_want_my_lvm = FALSE; 335 } else { 336 extract_i_want_my_lvm = TRUE; 337 } 338 339 log_msg(2, "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz"); 340 mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 341 run_program_and_log_output(command, TRUE); 342 mr_free(command); 343 344 if (!does_file_exist(MONDO_CFG_FILE_STUB)) { 345 /* Doing that allow us to remain compatible with pre-2.2.5 versions */ 346 log_msg(2, "pre-2.2.4 compatible mode on"); 347 mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary 348 run_program_and_log_output(command, TRUE); 349 mr_free(command); 350 if (!does_file_exist(MONDO_CFG_FILE_STUB)) { 351 fatal_error 352 ("Please reinsert the disk/CD and try again."); 353 } 354 } 355 } 356 } 357 if (does_file_exist(MONDO_CFG_FILE_STUB)) { 358 log_msg(1, "gcffa --- great! We've got the config file"); 359 tmp1 = call_program_and_get_last_line_of_output("pwd"); 360 mr_asprintf(tmp, "%s/%s", tmp1, MONDO_CFG_FILE_STUB); 361 mr_asprintf(command, "cp -f %s %s", tmp, cfg_file); 362 log_it("%s",command); 363 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) { 364 log_msg(1, 365 "... but an error occurred when I tried to move it to %s", 366 cfg_file); 367 } else { 368 log_msg(1, "... and I moved it successfully to %s", cfg_file); 369 } 370 mr_free(command); 371 372 mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file); 373 mr_free(tmp1); 374 log_it("%s",command); 375 if (extract_mountlist_stub) { 376 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) { 377 log_msg(1, "Failed to get mountlist"); 378 } else { 379 log_msg(1, "Got mountlist too"); 380 mr_free(command); 381 mr_asprintf(command, "cp -f %s %s", mountlist_file, g_mountlist_fname); 382 if (run_program_and_log_output(command, 1)) { 383 log_msg(1, "Failed to copy mountlist to /tmp"); 384 } else { 385 log_msg(1, "Copied mountlist to /tmp as well OK"); 386 mr_free(command); 387 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 388 run_program_and_log_output(command, 1); 389 } 390 } 391 } 392 mr_free(command); 393 mr_free(tmp); 394 } 395 396 run_program_and_log_output("umount -d " MNT_CDROM, FALSE); 397 if (!does_file_exist(cfg_file)) { 398 log_it("%s",cfg_file); 399 log_msg(1, "%s not found", cfg_file); 400 log_to_screen("Oh dear. Unable to recover configuration file from boot disk"); 401 return (1); 402 } 403 404 log_to_screen("Recovered mondorestore.cfg"); 405 if (!does_file_exist(MOUNTLIST_FNAME_STUB)) { 406 log_to_screen("...but not mountlist.txt - a pity, really..."); 407 } else { 408 /* Is this code really useful ??? */ 409 if (extract_mountlist_stub) { 410 mr_asprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB); 411 run_program_and_log_output(command, FALSE); 412 mr_free(command); 413 } 414 } 415 416 mr_asprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB); 417 mr_free(cfg_file); 418 419 run_program_and_log_output(command, FALSE); 420 mr_free(command); 421 422 if (extract_mountlist_stub) { 423 mr_asprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB); 424 run_program_and_log_output(command, FALSE); 425 mr_free(command); 426 } 427 mr_free(mountlist_file); 428 429 mr_asprintf(command, "cp -f etc/raidtab /etc/"); 430 run_program_and_log_output(command, FALSE); 431 mr_free(command); 432 433 if (extract_i_want_my_lvm) { 434 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB); 435 run_program_and_log_output(command, FALSE); 436 mr_free(command); 437 } 438 g_backup_media_type = bkpinfo->backup_media_type; 439 return (retval); 440 } 441 442 /************************************************************************** 443 *END_GET_CFG_FILE_FROM_ARCHIVE * 444 **************************************************************************/ 172 445 173 446 … … 642 915 /** add mallocs **/ 643 916 char value[MAX_STR_LEN]; 917 char *tmp = NULL; 644 918 char *tmp1 = NULL; 645 919 char *envtmp1 = NULL; … … 683 957 run_program_and_log_output("mount /dev/cdrom "MNT_CDROM, 1); 684 958 } 685 if (does_file_exist( MNT_CDROM"/archives/filelist.0")) {959 if (does_file_exist(ARCHIVES_PATH "/filelist.0")) { 686 960 bkpinfo->backup_media_type = cdr; 687 961 run_program_and_log_output("umount -d "MNT_CDROM, 1); … … 1284 1558 1285 1559 /** 1286 * Install the user's boot loader in the MBR.1287 * Currently LILO, ELILO, GRUB, RAW (dd of MBR), and the FreeBSD bootloader are supported.1288 * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them.1289 * @return 0 for success, nonzero for failure.1290 */1291 int run_boot_loader(bool offer_to_hack_scripts)1292 {1293 int res;1294 int retval = 0;1295 1296 /** malloc *******/1297 char *device = NULL;1298 char *disk = NULL;1299 char *name = NULL;1300 char *type = NULL;1301 char *cmd = NULL;1302 1303 malloc_string(device);1304 malloc_string(name);1305 malloc_string(type);1306 1307 /* In order to have a working bootloader, we need to have all devices1308 * ready in the chroot. If they are not there (udev) then copy them from1309 * the current /dev location1310 */1311 mr_asprintf(cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING);1312 run_program_and_log_output(cmd, 3);1313 mr_free(cmd);1314 1315 backup_crucial_file(MNT_RESTORING, "/etc/fstab");1316 backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst");1317 backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg");1318 backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg");1319 backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf");1320 backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf");1321 backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map");1322 backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map");1323 backup_crucial_file(MNT_RESTORING, "/etc/mtab");1324 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device);1325 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name);1326 read_cfg_var(g_mondo_cfg_file, "boot-type", type);1327 log_msg(2, "run_boot_loader: device='%s', name='%s', type='%s'", device, name, type);1328 sync();1329 1330 offer_to_make_initrd();1331 1332 disk = truncate_to_drive_name(device);1333 if (strcmp(type,"BIOS") == 0) {1334 // Force installation of a MBR bootloader brought by mindi on the disk1335 // in case none was available and we then start from a partition1336 log_msg(2, "Reinstalling mbr.bin on %s", disk);1337 mr_system("dd bs=440 count=1 conv=notrunc if=/tmp/mbr.bin of=%s &> /dev/null",disk);1338 } else {1339 // Same for GPT1340 log_msg(2, "Reinstalling gptmbr.bin on %s", disk);1341 mr_system("dd bs=440 count=1 conv=notrunc if=/tmp/gptmbr.bin of=%s &> /dev/null",disk);1342 }1343 1344 // Now reinstall bootloader1345 if (!strcmp(name, "LILO")) {1346 res = run_lilo(offer_to_hack_scripts);1347 } else if (!strcmp(name, "ELILO")) {1348 res = run_elilo(offer_to_hack_scripts);1349 } else if (!strcmp(name, "GRUB")) {1350 res = run_grub(offer_to_hack_scripts, device);1351 } else if (!strcmp(name, "RAW")) {1352 res = run_raw_mbr(offer_to_hack_scripts, device);1353 }1354 #ifdef __FreeBSD__1355 else if (!strcmp(name, "BOOT0")) {1356 mr_asprintf(tmp, "boot0cfg -B %s", device);1357 res = run_program_and_log_output(tmp, FALSE);1358 paranoid_free(tmp);1359 } else {1360 mr_asprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device);1361 if (!system(tmp)) {1362 mr_free(tmp);1363 mr_asprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device);1364 res = run_program_and_log_output(tmp, 3);1365 } else {1366 log_msg(1, "I'm not running any boot loader. You have a DD boot drive. It's already loaded up.");1367 }1368 mr_free(tmp);1369 }1370 #else1371 else {1372 log_to_screen1373 ("Unable to determine type of boot loader. Defaulting to LILO.");1374 res = run_lilo(offer_to_hack_scripts);1375 }1376 #endif1377 retval += res;1378 if (res) {1379 log_to_screen("Your boot loader returned an error");1380 } else {1381 log_to_screen("Your boot loader ran OK");1382 }1383 paranoid_free(device);1384 paranoid_free(name);1385 return (retval);1386 }1387 1388 /**************************************************************************1389 *END_ RUN_BOOT_LOADER *1390 **************************************************************************/1391 1392 1393 1394 /**1395 1560 * Attempt to find the user's editor. 1396 1561 * @return The editor found ("vi" if none could be found). … … 1417 1582 return (output); 1418 1583 } 1584 1585 1586 1587 1588 /** 1589 * Install LILO on the user's boot drive (determined by /etc/lilo.conf). 1590 * @param offer_to_run_stablilo If TRUE, then offer to hack the user's fstab for them. 1591 * @return 0 for success, nonzero for failure. 1592 */ 1593 int run_lilo(bool offer_to_run_stablilo) 1594 { 1595 /** malloc **/ 1596 char *command = NULL; 1597 char *tmp = NULL; 1598 char *editor = NULL; 1599 1600 int res; 1601 int done; 1602 bool run_lilo_M = FALSE; 1603 1604 if (!run_program_and_log_output 1605 ("grep \"boot.*=.*/dev/md\" " MNT_RESTORING "/etc/lilo.conf", 1)) { 1606 run_lilo_M = TRUE; 1607 } 1608 1609 if (offer_to_run_stablilo 1610 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) 1611 1612 /* interactive mode */ 1613 { 1614 mvaddstr_and_log_it(g_currentY, 1615 0, 1616 "Modifying fstab and lilo.conf, and running LILO... "); 1617 mr_asprintf(command, "mr-stablilo-me"); 1618 res = run_program_and_log_output(command, 3); 1619 mr_free(command); 1620 1621 if (res) { 1622 popup_and_OK 1623 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist."); 1624 for (done = FALSE; !done;) { 1625 editor = find_my_editor(); 1626 if (editor == NULL) { 1627 popup_and_OK("No editor found. You won't be able to edit conf files"); 1628 } else { 1629 if (!g_text_mode) { 1630 newtSuspend(); 1631 } 1632 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1633 paranoid_system(tmp); 1634 mr_free(tmp); 1635 1636 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1637 paranoid_system(tmp); 1638 mr_free(tmp); 1639 mr_free(editor); 1640 1641 if (!g_text_mode) { 1642 newtResume(); 1643 } 1644 // newtCls(); 1645 if (ask_me_yes_or_no("Edit them again?")) { 1646 continue; 1647 } 1648 } 1649 mr_free(editor); 1650 1651 res = run_program_and_log_output("chroot " MNT_RESTORING " lilo -L", 3); 1652 if (res) { 1653 res = run_program_and_log_output("chroot " MNT_RESTORING " lilo", 3); 1654 } 1655 if (res) { 1656 done = ask_me_yes_or_no("LILO failed. Re-edit system files?"); 1657 } else { 1658 done = TRUE; 1659 } 1660 } 1661 } else { 1662 log_to_screen("lilo.conf and fstab were modified OK"); 1663 } 1664 } else 1665 /* nuke mode */ 1666 { 1667 mvaddstr_and_log_it(g_currentY, 1668 0, 1669 "Running LILO... "); 1670 res = 1671 run_program_and_log_output("chroot " MNT_RESTORING " lilo -L", 1672 3); 1673 if (res) { 1674 res = 1675 run_program_and_log_output("chroot " MNT_RESTORING " lilo", 1676 3); 1677 } 1678 if (res) { 1679 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 1680 log_to_screen 1681 ("Failed to re-jig fstab and/or lilo. Edit/run manually, please."); 1682 } else { 1683 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1684 } 1685 } 1686 if (run_lilo_M) { 1687 run_program_and_log_output("chroot " MNT_RESTORING 1688 " lilo -M /dev/hda", 3); 1689 run_program_and_log_output("chroot " MNT_RESTORING 1690 " lilo -M /dev/sda", 3); 1691 } 1692 return (res); 1693 } 1694 1695 /************************************************************************** 1696 *END_RUN_LILO * 1697 **************************************************************************/ 1698 1699 1700 /** 1701 * Install a raw MBR onto @p bd. 1702 * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them. 1703 * @param bd The device to copy the stored MBR to. 1704 * @return 0 for success, nonzero for failure. 1705 */ 1706 int run_raw_mbr(bool offer_to_hack_scripts, char *bd) 1707 { 1708 /** malloc **/ 1709 char *command = NULL; 1710 char *boot_device = NULL; 1711 char *tmp = NULL; 1712 char *editor; 1713 int res; 1714 int done; 1715 1716 malloc_string(boot_device); 1717 assert_string_is_neither_NULL_nor_zerolength(bd); 1718 1719 strcpy(boot_device, bd); 1720 1721 if (offer_to_hack_scripts 1722 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) { 1723 /* interactive mode */ 1724 mvaddstr_and_log_it(g_currentY, 0, "Modifying fstab and restoring MBR... "); 1725 for (done = FALSE; !done;) { 1726 popup_and_OK("You will now edit fstab"); 1727 editor = find_my_editor(); 1728 if (editor == NULL) { 1729 popup_and_OK("No editor found. You won't be able to edit conf files"); 1730 } else { 1731 if (!g_text_mode) { 1732 newtSuspend(); 1733 } 1734 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1735 1736 paranoid_system(tmp); 1737 mr_free(tmp); 1738 if (!g_text_mode) { 1739 newtResume(); 1740 } 1741 } 1742 mr_free(editor); 1743 1744 popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device, MAX_STR_LEN / 4); 1745 mr_asprintf(command, "mr-stabraw-me %s", boot_device); 1746 res = run_program_and_log_output(command, 3); 1747 mr_free(command); 1748 1749 if (res) { 1750 done = ask_me_yes_or_no("Modifications failed. Re-try?"); 1751 } else { 1752 done = TRUE; 1753 } 1754 } 1755 } else { 1756 /* nuke mode */ 1757 mr_asprintf(command, "mr-raw %s /"MOUNTLIST_FNAME_STUB, boot_device); 1758 log_msg(2, "run_raw_mbr() --- command='%s'", command); 1759 1760 mvaddstr_and_log_it(g_currentY, 0, "Restoring MBR... "); 1761 res = run_program_and_log_output(command, 3); 1762 mr_free(command); 1763 } 1764 if (res) { 1765 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 1766 log_to_screen("MBR+fstab processed w/error(s). See %s for more info.", MONDO_LOGFILE); 1767 } else { 1768 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1769 } 1770 paranoid_free(boot_device); 1771 return (res); 1772 } 1773 1774 /************************************************************************** 1775 *END_RUN_RAW_MBR * 1776 **************************************************************************/ 1419 1777 1420 1778 … … 1465 1823 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"); 1466 1824 } 1467 editor = find_my_editor() );1825 editor = find_my_editor(); 1468 1826 if (editor == NULL) { 1469 1827 popup_and_OK("No editor found. You won't be able to edit conf files"); … … 1644 2002 1645 2003 1646 /** 1647 * Install LILO on the user's boot drive (determined by /etc/lilo.conf). 1648 * @param offer_to_run_stablilo If TRUE, then offer to hack the user's fstab for them. 2004 2005 /** 2006 * Install the user's boot loader in the MBR. 2007 * Currently LILO, ELILO, GRUB, RAW (dd of MBR), and the FreeBSD bootloader are supported. 2008 * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them. 1649 2009 * @return 0 for success, nonzero for failure. 1650 2010 */ 1651 int run_ lilo(bool offer_to_run_stablilo)2011 int run_boot_loader(bool offer_to_hack_scripts) 1652 2012 { 1653 /** malloc **/1654 char *command = NULL;1655 char *tmp = NULL;1656 char *editor = NULL;1657 1658 2013 int res; 1659 int done; 1660 bool run_lilo_M = FALSE; 1661 1662 if (!run_program_and_log_output 1663 ("grep \"boot.*=.*/dev/md\" " MNT_RESTORING "/etc/lilo.conf", 1)) { 1664 run_lilo_M = TRUE; 1665 } 1666 1667 if (offer_to_run_stablilo 1668 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) 1669 1670 /* interactive mode */ 1671 { 1672 mvaddstr_and_log_it(g_currentY, 1673 0, 1674 "Modifying fstab and lilo.conf, and running LILO... "); 1675 mr_asprintf(command, "mr-stablilo-me"); 1676 res = run_program_and_log_output(command, 3); 1677 mr_free(command); 1678 1679 if (res) { 1680 popup_and_OK 1681 ("You will now edit fstab and lilo.conf, to make sure they match your new mountlist."); 1682 for (done = FALSE; !done;) { 1683 editor = find_my_editor(); 1684 if (editor == NULL) { 1685 popup_and_OK("No editor found. You won't be able to edit conf files"); 1686 } else { 1687 if (!g_text_mode) { 1688 newtSuspend(); 1689 } 1690 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1691 paranoid_system(tmp); 1692 mr_free(tmp); 1693 1694 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/lilo.conf", editor); 1695 paranoid_system(tmp); 1696 mr_free(tmp); 1697 mr_free(editor); 1698 1699 if (!g_text_mode) { 1700 newtResume(); 1701 } 1702 // newtCls(); 1703 if (ask_me_yes_or_no("Edit them again?")) { 1704 continue; 1705 } 1706 } 1707 mr_free(editor); 1708 1709 res = run_program_and_log_output("chroot " MNT_RESTORING " lilo -L", 3); 1710 if (res) { 1711 res = run_program_and_log_output("chroot " MNT_RESTORING " lilo", 3); 1712 } 1713 if (res) { 1714 done = ask_me_yes_or_no("LILO failed. Re-edit system files?"); 1715 } else { 1716 done = TRUE; 1717 } 1718 } 2014 int retval = 0; 2015 2016 /** malloc *******/ 2017 char *device = NULL; 2018 char *disk = NULL; 2019 char *name = NULL; 2020 char *type = NULL; 2021 char *cmd = NULL; 2022 2023 malloc_string(device); 2024 malloc_string(name); 2025 malloc_string(type); 2026 2027 /* In order to have a working bootloader, we need to have all devices 2028 * ready in the chroot. If they are not there (udev) then copy them from 2029 * the current /dev location 2030 */ 2031 mr_asprintf(cmd,"tar cf - /dev | ( cd %s ; tar xf - )",MNT_RESTORING); 2032 run_program_and_log_output(cmd, 3); 2033 mr_free(cmd); 2034 2035 backup_crucial_file(MNT_RESTORING, "/etc/fstab"); 2036 backup_crucial_file(MNT_RESTORING, "/boot/grub/menu.lst"); 2037 backup_crucial_file(MNT_RESTORING, "/boot/grub/grub.cfg"); 2038 backup_crucial_file(MNT_RESTORING, "/boot/grub2/grub.cfg"); 2039 backup_crucial_file(MNT_RESTORING, "/etc/lilo.conf"); 2040 backup_crucial_file(MNT_RESTORING, "/etc/elilo.conf"); 2041 backup_crucial_file(MNT_RESTORING, "/boot/grub/device.map"); 2042 backup_crucial_file(MNT_RESTORING, "/boot/grub2/device.map"); 2043 backup_crucial_file(MNT_RESTORING, "/etc/mtab"); 2044 read_cfg_var(g_mondo_cfg_file, "bootloader.device", device); 2045 read_cfg_var(g_mondo_cfg_file, "bootloader.name", name); 2046 read_cfg_var(g_mondo_cfg_file, "boot-type", type); 2047 log_msg(2, "run_boot_loader: device='%s', name='%s', type='%s'", device, name, type); 2048 sync(); 2049 2050 offer_to_make_initrd(); 2051 2052 disk = truncate_to_drive_name(device); 2053 if (strcmp(type,"BIOS") == 0) { 2054 // Force installation of a MBR bootloader brought by mindi on the disk 2055 // in case none was available and we then start from a partition 2056 log_msg(2, "Reinstalling mbr.bin on %s", disk); 2057 mr_system("dd bs=440 count=1 conv=notrunc if=/tmp/mbr.bin of=%s &> /dev/null",disk); 2058 } else { 2059 // Same for GPT 2060 log_msg(2, "Reinstalling gptmbr.bin on %s", disk); 2061 mr_system("dd bs=440 count=1 conv=notrunc if=/tmp/gptmbr.bin of=%s &> /dev/null",disk); 2062 } 2063 2064 // Now reinstall bootloader 2065 if (!strcmp(name, "LILO")) { 2066 res = run_lilo(offer_to_hack_scripts); 2067 } else if (!strcmp(name, "ELILO")) { 2068 res = run_elilo(offer_to_hack_scripts); 2069 } else if (!strcmp(name, "GRUB")) { 2070 res = run_grub(offer_to_hack_scripts, device); 2071 } else if (!strcmp(name, "RAW")) { 2072 res = run_raw_mbr(offer_to_hack_scripts, device); 2073 } 2074 #ifdef __FreeBSD__ 2075 else if (!strcmp(name, "BOOT0")) { 2076 mr_asprintf(tmp, "boot0cfg -B %s", device); 2077 res = run_program_and_log_output(tmp, FALSE); 2078 paranoid_free(tmp); 2079 } else { 2080 mr_asprintf(tmp, "ls /dev | grep -Eq '^%ss[1-4].*'", device); 2081 if (!system(tmp)) { 2082 mr_free(tmp); 2083 mr_asprintf(tmp, MNT_RESTORING "/sbin/fdisk -B %s", device); 2084 res = run_program_and_log_output(tmp, 3); 1719 2085 } else { 1720 log_to_screen("lilo.conf and fstab were modified OK"); 1721 } 1722 } else 1723 /* nuke mode */ 1724 { 1725 mvaddstr_and_log_it(g_currentY, 1726 0, 1727 "Running LILO... "); 1728 res = 1729 run_program_and_log_output("chroot " MNT_RESTORING " lilo -L", 1730 3); 1731 if (res) { 1732 res = 1733 run_program_and_log_output("chroot " MNT_RESTORING " lilo", 1734 3); 1735 } 1736 if (res) { 1737 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 1738 log_to_screen 1739 ("Failed to re-jig fstab and/or lilo. Edit/run manually, please."); 1740 } else { 1741 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1742 } 1743 } 1744 if (run_lilo_M) { 1745 run_program_and_log_output("chroot " MNT_RESTORING 1746 " lilo -M /dev/hda", 3); 1747 run_program_and_log_output("chroot " MNT_RESTORING 1748 " lilo -M /dev/sda", 3); 1749 } 1750 return (res); 2086 log_msg(1, "I'm not running any boot loader. You have a DD boot drive. It's already loaded up."); 2087 } 2088 mr_free(tmp); 2089 } 2090 #else 2091 else { 2092 log_to_screen 2093 ("Unable to determine type of boot loader. Defaulting to LILO."); 2094 res = run_lilo(offer_to_hack_scripts); 2095 } 2096 #endif 2097 retval += res; 2098 if (res) { 2099 log_to_screen("Your boot loader returned an error"); 2100 } else { 2101 log_to_screen("Your boot loader ran OK"); 2102 } 2103 paranoid_free(device); 2104 paranoid_free(name); 2105 return (retval); 1751 2106 } 1752 2107 1753 2108 /************************************************************************** 1754 *END_RUN_LILO * 1755 **************************************************************************/ 1756 1757 1758 /** 1759 * Install a raw MBR onto @p bd. 1760 * @param offer_to_hack_scripts If TRUE, then offer to hack the user's fstab for them. 1761 * @param bd The device to copy the stored MBR to. 1762 * @return 0 for success, nonzero for failure. 1763 */ 1764 int run_raw_mbr(bool offer_to_hack_scripts, char *bd) 1765 { 1766 /** malloc **/ 1767 char *command = NULL; 1768 char *boot_device = NULL; 1769 char *tmp = NULL; 1770 char *editor; 1771 int res; 1772 int done; 1773 1774 malloc_string(boot_device); 1775 assert_string_is_neither_NULL_nor_zerolength(bd); 1776 1777 strcpy(boot_device, bd); 1778 1779 if (offer_to_hack_scripts 1780 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) { 1781 /* interactive mode */ 1782 mvaddstr_and_log_it(g_currentY, 0, "Modifying fstab and restoring MBR... "); 1783 for (done = FALSE; !done;) { 1784 popup_and_OK("You will now edit fstab"); 1785 editor = find_my_editor()); 1786 if (editor == NULL) { 1787 popup_and_OK("No editor found. You won't be able to edit conf files"); 1788 } else { 1789 if (!g_text_mode) { 1790 newtSuspend(); 1791 } 1792 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1793 1794 paranoid_system(tmp); 1795 mr_free(tmp); 1796 if (!g_text_mode) { 1797 newtResume(); 1798 } 1799 } 1800 mr_free(editor); 1801 1802 popup_and_get_string("Boot device", "Please confirm/enter the boot device. If in doubt, try /dev/hda", boot_device, MAX_STR_LEN / 4); 1803 mr_asprintf(command, "mr-stabraw-me %s", boot_device); 1804 res = run_program_and_log_output(command, 3); 1805 mr_free(command); 1806 1807 if (res) { 1808 done = ask_me_yes_or_no("Modifications failed. Re-try?"); 1809 } else { 1810 done = TRUE; 1811 } 1812 } 1813 } else { 1814 /* nuke mode */ 1815 mr_asprintf(command, "mr-raw %s /"MOUNTLIST_FNAME_STUB, boot_device); 1816 log_msg(2, "run_raw_mbr() --- command='%s'", command); 1817 1818 mvaddstr_and_log_it(g_currentY, 0, "Restoring MBR... "); 1819 res = run_program_and_log_output(command, 3); 1820 mr_free(command); 1821 } 1822 if (res) { 1823 mvaddstr_and_log_it(g_currentY++, 74, "Failed."); 1824 log_to_screen("MBR+fstab processed w/error(s). See %s for more info.", MONDO_LOGFILE); 1825 } else { 1826 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1827 } 1828 paranoid_free(boot_device); 1829 return (res); 1830 } 1831 1832 /************************************************************************** 1833 *END_RUN_RAW_MBR * 2109 *END_ RUN_BOOT_LOADER * 1834 2110 **************************************************************************/ 1835 2111 … … 2068 2344 *END_UNMOUNT_ALL_DEVICES * 2069 2345 **************************************************************************/ 2070 2071 /**2072 * Extract mondorestore.cfg and the mountlist from the tape inserted2073 * to the ./tmp/ directory.2074 * @param dev The tape device to read from.2075 * @return 0 for success, nonzero for failure.2076 */2077 int extract_cfg_file_and_mountlist_from_tape_dev(char *dev)2078 {2079 char *command = NULL;2080 int res = 0;2081 2082 if (bkpinfo->use_obdr) {2083 skip_obdr();2084 } else {2085 // TODO: below 32KB seems to block at least on RHAS 2.1 and MDK 10.02086 set_tape_block_size_with_mt(bkpinfo->internal_tape_block_size);2087 }2088 2089 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx ./%s ./%s ./%s ./%s ./%s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);2090 log_msg(2, "command = '%s'", command);2091 res = run_program_and_log_output(command, -1);2092 mr_free(command);2093 2094 if (res != 0) {2095 if (does_file_exist(MONDO_CFG_FILE_STUB)) {2096 res = 0;2097 } else {2098 /* Doing that allow us to remain compatible with pre-2.2.5 versions */2099 log_msg(2, "pre-2.2.4 compatible mode on");2100 mr_asprintf(command, "dd if=%s bs=%ld count=%ld 2> /dev/null | tar -zx %s %s %s %s %s", dev, bkpinfo->internal_tape_block_size, 1024L * 1024 * 32 / bkpinfo->internal_tape_block_size, MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB);2101 log_msg(2, "command = '%s'", command);2102 res = run_program_and_log_output(command, -1);2103 mr_free(command);2104 if ((res != 0) && (does_file_exist(MONDO_CFG_FILE_STUB))) {2105 res = 0;2106 }2107 }2108 }2109 paranoid_free(command);2110 return (res);2111 }2112 2113 2114 /**2115 * Get the configuration file from the tape, or CD.2116 * @param bkpinfo The backup information structure. Fields used:2117 * - @c bkpinfo->backup_media_type2118 * - @c bkpinfo->media_device2119 * - @c bkpinfo->tmpdir2120 * @return 0 for success, nonzero for failure.2121 */2122 int get_cfg_file_from_archive()2123 {2124 int retval = 0;2125 2126 /** malloc *****/2127 char *command = NULL;2128 char *cfg_file = NULL;2129 char *tmp = NULL;2130 char *tmp1 = NULL;2131 char *mountpt = NULL;2132 char *mountlist_file = NULL;2133 bool extract_mountlist_stub = FALSE;2134 bool extract_i_want_my_lvm = FALSE;2135 2136 bool try_plan_B;2137 2138 assert(bkpinfo != NULL);2139 log_msg(2, "gcffa --- starting");2140 log_to_screen("I'm thinking...");2141 mr_asprintf(mountpt, "%s/mount.bootdisk", bkpinfo->tmpdir);2142 if (chdir(bkpinfo->tmpdir)) {2143 // FIXME2144 }2145 mr_asprintf(cfg_file, "%s", MONDO_CFG_FILE_STUB);2146 unlink(cfg_file); // cfg_file[] is missing the '/' at the start, FYI, by intent2147 mr_free(cfg_file);2148 2149 unlink(FILELIST_FULL_STUB);2150 unlink(BIGGIELIST_TXT_STUB);2151 mr_asprintf(command, "mkdir -p %s", mountpt);2152 run_program_and_log_output(command, FALSE);2153 mr_free(command);2154 2155 mr_asprintf(cfg_file, "%s/%s", bkpinfo->tmpdir, MONDO_CFG_FILE_STUB);2156 mr_asprintf(mountlist_file, "%s/%s", bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);2157 log_msg(2, "mountpt = %s; cfg_file=%s", mountpt, cfg_file);2158 mr_free(mountpt);2159 2160 if (!does_file_exist(cfg_file)) {2161 log_msg(2, "gcffa --- we don't have cfg file yet.");2162 if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {2163 try_plan_B = TRUE;2164 } else {2165 log_msg(2, "gcffa --- calling mount_media now :)");2166 if (!mount_media(MNT_CDROM)) {2167 log_msg(2, "gcffa --- managed to mount CD; so, no need for Plan B");2168 try_plan_B = FALSE;2169 } else {2170 try_plan_B = TRUE;2171 }2172 if (what_number_cd_is_this() > 1) {2173 insist_on_this_cd_number((g_current_media_number = 1));2174 }2175 }2176 if (try_plan_B) {2177 log_msg(2, "gcffa --- OK, switching to Plan B");2178 if (chdir(bkpinfo->tmpdir)) {2179 // FIXME2180 }2181 run_program_and_log_output("mkdir -p tmp", FALSE);2182 2183 if (bkpinfo->media_device == NULL) {2184 mr_asprintf(bkpinfo->media_device, "%s", "/dev/st0");2185 log_msg(2, "media_device is blank; assuming %s", bkpinfo->media_device);2186 }2187 mr_asprintf(tmp, "%s", bkpinfo->media_device);2188 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) {2189 mr_free(bkpinfo->media_device);2190 mr_asprintf(bkpinfo->media_device, "%s", "/dev/st0");2191 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) {2192 mr_free(bkpinfo->media_device);2193 mr_asprintf(bkpinfo->media_device, "%s", "/dev/osst0");2194 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) {2195 mr_free(bkpinfo->media_device);2196 mr_asprintf(bkpinfo->media_device, "%s", "/dev/ht0");2197 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) {2198 log_msg(3, "I tried lots of devices but none worked.");2199 mr_free(bkpinfo->media_device);2200 }2201 }2202 }2203 }2204 if (bkpinfo->media_device == NULL) {2205 bkpinfo->media_device = tmp;2206 } else {2207 mr_free(tmp);2208 }2209 2210 if (!does_file_exist("tmp/mondorestore.cfg")) {2211 log_to_screen("Cannot find config info on media");2212 return (1);2213 }2214 } else {2215 if (does_file_exist("/"MOUNTLIST_FNAME_STUB)) {2216 extract_mountlist_stub = FALSE;2217 } else {2218 extract_mountlist_stub = TRUE;2219 }2220 if (does_file_exist("/"IWANTMYLVM_STUB)) {2221 extract_i_want_my_lvm = FALSE;2222 } else {2223 extract_i_want_my_lvm = TRUE;2224 }2225 2226 log_msg(2, "gcffa --- Plan B, a.k.a. untarring some file from all.tar.gz");2227 mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz ./%s ./%s ./%s ./%s ./%s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2228 run_program_and_log_output(command, TRUE);2229 mr_free(command);2230 2231 if (!does_file_exist(MONDO_CFG_FILE_STUB)) {2232 /* Doing that allow us to remain compatible with pre-2.2.5 versions */2233 log_msg(2, "pre-2.2.4 compatible mode on");2234 mr_asprintf(command, "tar -zxvf " MNT_CDROM "/images/all.tar.gz %s %s %s %s %s", MOUNTLIST_FNAME_STUB, MONDO_CFG_FILE_STUB, BIGGIELIST_TXT_STUB, FILELIST_FULL_STUB, IWANTMYLVM_STUB); // add -b TAPE_BLOCK_SIZE if you _really_ think it's necessary2235 run_program_and_log_output(command, TRUE);2236 mr_free(command);2237 if (!does_file_exist(MONDO_CFG_FILE_STUB)) {2238 fatal_error2239 ("Please reinsert the disk/CD and try again.");2240 }2241 }2242 }2243 }2244 if (does_file_exist(MONDO_CFG_FILE_STUB)) {2245 log_msg(1, "gcffa --- great! We've got the config file");2246 tmp1 = call_program_and_get_last_line_of_output("pwd");2247 mr_asprintf(tmp, "%s/%s", tmp1, MONDO_CFG_FILE_STUB);2248 mr_asprintf(command, "cp -f %s %s", tmp, cfg_file);2249 log_it("%s",command);2250 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {2251 log_msg(1,2252 "... but an error occurred when I tried to move it to %s",2253 cfg_file);2254 } else {2255 log_msg(1, "... and I moved it successfully to %s", cfg_file);2256 }2257 mr_free(command);2258 2259 mr_asprintf(command, "cp -f %s/%s %s", tmp1, MOUNTLIST_FNAME_STUB, mountlist_file);2260 mr_free(tmp1);2261 log_it("%s",command);2262 if (extract_mountlist_stub) {2263 if (strcmp(tmp, cfg_file) && run_program_and_log_output(command, 1)) {2264 log_msg(1, "Failed to get mountlist");2265 } else {2266 log_msg(1, "Got mountlist too");2267 mr_free(command);2268 mr_asprintf(command, "cp -f %s %s", mountlist_file, g_mountlist_fname);2269 if (run_program_and_log_output(command, 1)) {2270 log_msg(1, "Failed to copy mountlist to /tmp");2271 } else {2272 log_msg(1, "Copied mountlist to /tmp as well OK");2273 mr_free(command);2274 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);2275 run_program_and_log_output(command, 1);2276 }2277 }2278 }2279 mr_free(command);2280 mr_free(tmp);2281 }2282 2283 run_program_and_log_output("umount -d " MNT_CDROM, FALSE);2284 if (!does_file_exist(cfg_file)) {2285 log_it("%s",cfg_file);2286 log_msg(1, "%s not found", cfg_file);2287 log_to_screen("Oh dear. Unable to recover configuration file from boot disk");2288 return (1);2289 }2290 2291 log_to_screen("Recovered mondorestore.cfg");2292 if (!does_file_exist(MOUNTLIST_FNAME_STUB)) {2293 log_to_screen("...but not mountlist.txt - a pity, really...");2294 } else {2295 /* Is this code really useful ??? */2296 if (extract_mountlist_stub) {2297 mr_asprintf(command, "cp -f %s %s/%s", MOUNTLIST_FNAME_STUB, bkpinfo->tmpdir, MOUNTLIST_FNAME_STUB);2298 run_program_and_log_output(command, FALSE);2299 mr_free(command);2300 }2301 }2302 2303 mr_asprintf(command, "cp -f %s /%s", cfg_file, MONDO_CFG_FILE_STUB);2304 mr_free(cfg_file);2305 2306 run_program_and_log_output(command, FALSE);2307 mr_free(command);2308 2309 if (extract_mountlist_stub) {2310 mr_asprintf(command, "cp -f %s /%s", mountlist_file, MOUNTLIST_FNAME_STUB);2311 run_program_and_log_output(command, FALSE);2312 mr_free(command);2313 }2314 mr_free(mountlist_file);2315 2316 mr_asprintf(command, "cp -f etc/raidtab /etc/");2317 run_program_and_log_output(command, FALSE);2318 mr_free(command);2319 2320 if (extract_i_want_my_lvm) {2321 mr_asprintf(command, "cp -f %s /tmp/",IWANTMYLVM_STUB);2322 run_program_and_log_output(command, FALSE);2323 mr_free(command);2324 }2325 g_backup_media_type = bkpinfo->backup_media_type;2326 return (retval);2327 }2328 2329 /**************************************************************************2330 *END_GET_CFG_FILE_FROM_ARCHIVE *2331 **************************************************************************/2332 2333 2346 /* @} - end restoreUtilityGroup */ 2334 2347
Note:
See TracChangeset
for help on using the changeset viewer.