[1] | 1 | /***************************************************************************
|
---|
| 2 | main.c - description
|
---|
| 3 | -------------------
|
---|
| 4 | begin : Fri Apr 19 16:40:35 EDT 2002
|
---|
| 5 | copyright : (C) 2002 by Stan Benoit
|
---|
| 6 | email : troff@nakedsoul.org
|
---|
[128] | 7 | cvsid : $Id: main.c 538 2006-05-13 16:39:55Z bcornec $
|
---|
[1] | 8 | ***************************************************************************/
|
---|
| 9 |
|
---|
| 10 | /***************************************************************************
|
---|
| 11 | * *
|
---|
| 12 | * This program is free software; you can redistribute it and/or modify *
|
---|
| 13 | * it under the terms of the GNU General Public License as published by *
|
---|
| 14 | * the Free Software Foundation; either version 2 of the License, or *
|
---|
| 15 | * (at your option) any later version. *
|
---|
| 16 | * *
|
---|
| 17 | ***************************************************************************/
|
---|
| 18 |
|
---|
| 19 | /** change log ****** MONDO-DEVEL
|
---|
| 20 |
|
---|
| 21 |
|
---|
| 22 | 12/10
|
---|
| 23 | - disable stopping/starting of autofs
|
---|
| 24 |
|
---|
| 25 | 10/01
|
---|
| 26 | - update g_erase_tmpdir_and_scratchdir to delete user-specified tmpdir, scratchdir
|
---|
| 27 |
|
---|
| 28 | 06/19
|
---|
| 29 | - added AUX_VER
|
---|
| 30 |
|
---|
| 31 | 06/14/2004
|
---|
| 32 | - use mondorescue.iso, not mindi.iso
|
---|
| 33 |
|
---|
| 34 | 02/10/2004
|
---|
| 35 | - tell users where BusyBox's sources are
|
---|
| 36 |
|
---|
| 37 | 11/14/2003
|
---|
| 38 | - cleaned up logging at end#
|
---|
| 39 |
|
---|
| 40 | 10/23
|
---|
| 41 | - don't try to test-read tape ... That's already
|
---|
| 42 | handled by post_param_configuration()
|
---|
| 43 |
|
---|
| 44 | 10/19
|
---|
| 45 | - if your PATH var is too long, abort
|
---|
| 46 |
|
---|
| 47 | 09/23
|
---|
| 48 | - added some comments
|
---|
| 49 | - malloc/free global strings in new subroutines - malloc_libmondo_global_strings()
|
---|
| 50 | and free_libmondo_global_strings() - which are in libmondo-tools.c
|
---|
| 51 | - better magicdev support
|
---|
| 52 |
|
---|
| 53 |
|
---|
| 54 | 09/16
|
---|
| 55 | - delete /var/log/partimagehack-debug.log at start of main()
|
---|
| 56 |
|
---|
| 57 | 09/15
|
---|
| 58 | - added askbootloader
|
---|
| 59 |
|
---|
| 60 | 09/09
|
---|
| 61 | - if your tape is weird, I'll pause between backup and verify
|
---|
| 62 | - fixed silly bug in main() - re: say_at_end
|
---|
| 63 |
|
---|
| 64 | 01/01 - 08/31
|
---|
| 65 | - call 'dmesg -n1' at start, to shut the kernel logger up
|
---|
| 66 | - moved g_erase_tmpdir_and_scratchdir to common/newt-specific.c
|
---|
| 67 | - added 'don't panic' msg to start of logfile
|
---|
| 68 | - added 'nice(20)' to main()
|
---|
| 69 | - added lots of assert()'s and log_OS_error()'s
|
---|
| 70 | - clean-up (Hugo)
|
---|
| 71 | - make post_param_configuration() setup g_erase_tmpdir_and_scratchdir
|
---|
| 72 | - if --version then print & exit quickly
|
---|
| 73 | - re-run g_erase_tmpdir_and_scratchdir via system() at very end
|
---|
| 74 |
|
---|
| 75 | Year: 2002
|
---|
| 76 | - if user goes root with 'su' instead of 'su -' then
|
---|
| 77 | workaround it by setting PATH correctly
|
---|
| 78 | - wipe mondoarchive.log at very beginning
|
---|
| 79 | - cleaned up code
|
---|
| 80 | - if changed.files.N exists then copy to changes.files for display
|
---|
| 81 | - run_program_and_log_output() now takes boolean operator to specify
|
---|
| 82 | whether it will log its activities in the event of _success_
|
---|
| 83 | - added popup list of changed files
|
---|
| 84 | - removed 'beta-quality' warnings
|
---|
| 85 | - if kernel not found and mondo in graphics mode then popup and ask
|
---|
| 86 | for kernel path+filename
|
---|
| 87 | - fixed tmp[] 'too small' bug
|
---|
| 88 | - unmount and eject CD at end of verify cycle
|
---|
| 89 | - moved interactively_obtain...() to libmondo-stream.c
|
---|
| 90 | - wrote stuff to autodetect tape+cdrw+etc.
|
---|
| 91 | - renamed from main.c to mondo-archive.c
|
---|
| 92 | - fore+after warnings that this code is beta-quality
|
---|
| 93 | - abort if running from ramdisk
|
---|
| 94 | - remount floppy at end & unmount at start if Mandrake
|
---|
| 95 | - took out #debug stuff
|
---|
| 96 | - add 2> /dev/null to 'find' command
|
---|
| 97 | - add support for bkpinfo->nonbootable_backup
|
---|
| 98 | - add main function begin comment and debug conditional
|
---|
| 99 | compilation - Stan Benoit
|
---|
| 100 | - add debug statements to build a run tree. Stan Benoit
|
---|
| 101 | **** end change log **********/
|
---|
| 102 |
|
---|
| 103 |
|
---|
| 104 | /**
|
---|
| 105 | * @file
|
---|
| 106 | * The main file for mondoarchive.
|
---|
| 107 | */
|
---|
| 108 |
|
---|
| 109 | /************************* #include statements *************************/
|
---|
| 110 | #include <pthread.h>
|
---|
| 111 | //#include <config.h>
|
---|
| 112 | //#include "../../config.h"
|
---|
| 113 | #include <stdio.h>
|
---|
| 114 | #include <stdlib.h>
|
---|
| 115 | #include "../common/my-stuff.h"
|
---|
| 116 | #include "../common/mondostructures.h"
|
---|
| 117 | #include "../common/libmondo.h"
|
---|
| 118 | #include "mondo-cli-EXT.h"
|
---|
| 119 |
|
---|
| 120 | // for CVS
|
---|
[128] | 121 | //static char cvsid[] = "$Id: main.c 538 2006-05-13 16:39:55Z bcornec $";
|
---|
[1] | 122 |
|
---|
| 123 | /************************* external variables *************************/
|
---|
| 124 | extern void set_signals(int);
|
---|
| 125 | extern int g_current_media_number;
|
---|
[128] | 126 | extern void register_pid(pid_t, char *);
|
---|
[1] | 127 | extern int g_currentY;
|
---|
| 128 | extern bool g_text_mode;
|
---|
| 129 | extern char *g_boot_mountpt;
|
---|
| 130 | extern bool g_remount_cdrom_at_end, g_remount_floppy_at_end;
|
---|
| 131 | extern char *g_mondo_home;
|
---|
| 132 | extern char *g_tmpfs_mountpt;
|
---|
| 133 | extern char *g_erase_tmpdir_and_scratchdir;
|
---|
| 134 | extern char *g_cdrw_drive_is_here;
|
---|
[128] | 135 | static char *g_cdrom_drive_is_here = NULL;
|
---|
| 136 | static char *g_dvd_drive_is_here = NULL;
|
---|
[1] | 137 | extern double g_kernel_version;
|
---|
| 138 |
|
---|
| 139 | /***************** global vars, used only by main.c ******************/
|
---|
| 140 | bool g_skip_floppies;
|
---|
| 141 | long diffs;
|
---|
| 142 |
|
---|
| 143 | extern t_bkptype g_backup_media_type;
|
---|
| 144 | extern int g_loglevel;
|
---|
| 145 |
|
---|
| 146 | /****************** subroutines used only by main.c ******************/
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | /**
|
---|
| 150 | * Print a "don't panic" message to the log and a message about the logfile to the screen.
|
---|
| 151 | */
|
---|
| 152 | void welcome_to_mondoarchive()
|
---|
| 153 | {
|
---|
[128] | 154 | log_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org",
|
---|
[251] | 155 | PACKAGE_VERSION);
|
---|
[128] | 156 | log_msg(0, "running on %s architecture", get_architecture());
|
---|
| 157 | log_msg(0,
|
---|
| 158 | "-----------------------------------------------------------");
|
---|
| 159 | log_msg(0,
|
---|
| 160 | "NB: Mondo logs almost everything, so don't panic if you see");
|
---|
| 161 | log_msg(0,
|
---|
| 162 | "some error messages. Please read them carefully before you");
|
---|
| 163 | log_msg(0,
|
---|
| 164 | "decide to break out in a cold sweat. Despite (or perhaps");
|
---|
| 165 | log_msg(0,
|
---|
| 166 | "because of) the wealth of messages. some users are inclined");
|
---|
| 167 | log_msg(0,
|
---|
| 168 | "to stop reading this log. If Mondo stopped for some reason,");
|
---|
| 169 | log_msg(0,
|
---|
| 170 | "chances are it's detailed here. More than likely there's a");
|
---|
| 171 | log_msg(0,
|
---|
| 172 | "message at the very end of this log that will tell you what");
|
---|
| 173 | log_msg(0,
|
---|
| 174 | "is wrong. Please read it! -Devteam");
|
---|
| 175 | log_msg(0,
|
---|
| 176 | "-----------------------------------------------------------");
|
---|
[1] | 177 |
|
---|
[128] | 178 | log_msg(0, "Zero...");
|
---|
| 179 | log_msg(1, "One...");
|
---|
| 180 | log_msg(2, "Two...");
|
---|
| 181 | log_msg(3, "Three...");
|
---|
| 182 | log_msg(4, "Four...");
|
---|
| 183 | log_msg(5, "Five...");
|
---|
| 184 | log_msg(6, "Six...");
|
---|
| 185 | log_msg(7, "Seven...");
|
---|
| 186 | log_msg(8, "Eight...");
|
---|
| 187 | printf("See %s for details of backup run.\n", MONDO_LOGFILE);
|
---|
[1] | 188 | }
|
---|
| 189 |
|
---|
| 190 |
|
---|
| 191 | extern char *g_magicdev_command;
|
---|
| 192 |
|
---|
| 193 | /**
|
---|
| 194 | * Do whatever is necessary to insure a successful backup on the Linux distribution
|
---|
| 195 | * of the day.
|
---|
| 196 | */
|
---|
| 197 | void distro_specific_kludges_at_start_of_mondoarchive()
|
---|
| 198 | {
|
---|
[128] | 199 | log_msg(2, "Unmounting old ramdisks if necessary");
|
---|
| 200 | stop_magicdev_if_necessary(); // for RH+Gnome users
|
---|
| 201 | run_program_and_log_output
|
---|
| 202 | ("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
|
---|
| 203 | unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
|
---|
| 204 | // stop_autofs_if_necessary(); // for Xandros users
|
---|
| 205 | mount_boot_if_necessary(); // for Gentoo users with non-mounted /boot partitions
|
---|
| 206 | clean_up_KDE_desktop_if_necessary(); // delete various misc ~/.* files that get in the way
|
---|
[1] | 207 | }
|
---|
| 208 |
|
---|
| 209 |
|
---|
| 210 |
|
---|
| 211 | /**
|
---|
| 212 | * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive().
|
---|
| 213 | */
|
---|
| 214 | void distro_specific_kludges_at_end_of_mondoarchive()
|
---|
| 215 | {
|
---|
| 216 | // char tmp[500];
|
---|
[128] | 217 | log_msg(2, "Restarting magicdev if necessary");
|
---|
| 218 | sync();
|
---|
| 219 | restart_magicdev_if_necessary(); // for RH+Gnome users
|
---|
[1] | 220 |
|
---|
[128] | 221 | log_msg(2, "Restarting autofs if necessary");
|
---|
| 222 | sync();
|
---|
| 223 | // restart_autofs_if_necessary(); // for Xandros users
|
---|
[1] | 224 |
|
---|
[128] | 225 | log_msg(2, "Restarting supermounts if necessary");
|
---|
| 226 | sync();
|
---|
| 227 | remount_supermounts_if_necessary(); // for Mandrake users
|
---|
[1] | 228 |
|
---|
[128] | 229 | log_msg(2, "Unmounting /boot if necessary");
|
---|
| 230 | sync();
|
---|
| 231 | unmount_boot_if_necessary(); // for Gentoo users
|
---|
[1] | 232 |
|
---|
| 233 | // log_msg( 2, "Cleaning up KDE desktop");
|
---|
| 234 | // clean_up_KDE_desktop_if_necessary();
|
---|
| 235 | }
|
---|
| 236 |
|
---|
| 237 |
|
---|
| 238 | /*-----------------------------------------------------------*/
|
---|
| 239 |
|
---|
| 240 |
|
---|
| 241 |
|
---|
| 242 | /**
|
---|
| 243 | * Backup/verify the user's data.
|
---|
| 244 | * What did you think it did, anyway? :-)
|
---|
| 245 | */
|
---|
[128] | 246 | int main(int argc, char *argv[])
|
---|
[1] | 247 | {
|
---|
[128] | 248 | struct s_bkpinfo *bkpinfo;
|
---|
[538] | 249 | struct s_mrconf *mrconf;
|
---|
[128] | 250 | char *tmp;
|
---|
| 251 | int res, retval;
|
---|
| 252 | char *say_at_end;
|
---|
[1] | 253 |
|
---|
[497] | 254 | #ifdef ENABLE_NLS
|
---|
| 255 | setlocale(LC_ALL, "");
|
---|
| 256 | (void) textdomain("mondo");
|
---|
| 257 | #endif
|
---|
[1] | 258 | /* Make sure I'm root; abort if not */
|
---|
[128] | 259 | if (getuid() != 0) {
|
---|
[497] | 260 | fprintf(stderr, _("Please run as root.\n"));
|
---|
[128] | 261 | exit(127);
|
---|
| 262 | }
|
---|
[1] | 263 |
|
---|
| 264 | /* If -V, -v or --version then echo version no. and quit */
|
---|
[128] | 265 | if (argc == 2
|
---|
| 266 | && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
|
---|
| 267 | || !strcmp(argv[argc - 1], "--version"))) {
|
---|
[497] | 268 | printf(_("mondoarchive v%s\nSee man page for help\n"), PACKAGE_VERSION);
|
---|
[128] | 269 | exit(0);
|
---|
| 270 | }
|
---|
[1] | 271 |
|
---|
| 272 | /* Initialize variables */
|
---|
| 273 |
|
---|
[128] | 274 | malloc_libmondo_global_strings();
|
---|
| 275 | malloc_string(tmp);
|
---|
| 276 | malloc_string(say_at_end);
|
---|
[1] | 277 |
|
---|
[538] | 278 | /* Initialize Configuration Structure */
|
---|
| 279 | mrarchive_init_conf(mrconf);
|
---|
| 280 |
|
---|
[128] | 281 | res = 0;
|
---|
| 282 | retval = 0;
|
---|
| 283 | diffs = 0;
|
---|
| 284 | say_at_end[0] = '\0';
|
---|
[497] | 285 | printf(_("Initializing...\n"));
|
---|
[128] | 286 | if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
|
---|
| 287 | fatal_error("Cannot malloc bkpinfo");
|
---|
| 288 | }
|
---|
[1] | 289 |
|
---|
| 290 |
|
---|
| 291 | /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
|
---|
[128] | 292 | strncpy(tmp, getenv("PATH"), MAX_STR_LEN - 1);
|
---|
| 293 | tmp[MAX_STR_LEN - 1] = '\0';
|
---|
| 294 | if (strlen(tmp) >= MAX_STR_LEN - 33) {
|
---|
| 295 | fatal_error
|
---|
| 296 | ("Your PATH environmental variable is too long. Please shorten it.");
|
---|
| 297 | }
|
---|
| 298 | strcat(tmp, ":/sbin:/usr/sbin:/usr/local/sbin");
|
---|
| 299 | setenv("PATH", tmp, 1);
|
---|
[1] | 300 |
|
---|
| 301 | /* Add the ARCH environment variable for ia64 purposes */
|
---|
[128] | 302 | strncpy(tmp, get_architecture(), MAX_STR_LEN - 1);
|
---|
| 303 | tmp[MAX_STR_LEN - 1] = '\0';
|
---|
| 304 | setenv("ARCH", tmp, 1);
|
---|
[1] | 305 |
|
---|
[424] | 306 | /* Add MONDO_SHARE environment variable for mindi */
|
---|
| 307 | setenv_mondo_share();
|
---|
[258] | 308 |
|
---|
[128] | 309 | unlink(MONDO_LOGFILE);
|
---|
[1] | 310 |
|
---|
| 311 | /* Configure the bkpinfo structure, global file paths, etc. */
|
---|
[128] | 312 | g_main_pid = getpid();
|
---|
| 313 | log_msg(9, "This");
|
---|
[1] | 314 |
|
---|
[128] | 315 | register_pid(g_main_pid, "mondo");
|
---|
| 316 | set_signals(TRUE); // catch SIGTERM, etc.
|
---|
| 317 | run_program_and_log_output("dmesg -n1", TRUE);
|
---|
[1] | 318 |
|
---|
[128] | 319 | log_msg(9, "Next");
|
---|
| 320 | welcome_to_mondoarchive();
|
---|
| 321 | distro_specific_kludges_at_start_of_mondoarchive();
|
---|
| 322 | sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
|
---|
| 323 | bkpinfo->scratchdir);
|
---|
| 324 | g_kernel_version = get_kernel_version();
|
---|
[1] | 325 |
|
---|
[128] | 326 | if (argc == 4 && !strcmp(argv[1], "getfattr")) {
|
---|
| 327 | g_loglevel = 10;
|
---|
| 328 | g_text_mode = TRUE;
|
---|
| 329 | setup_newt_stuff();
|
---|
| 330 | if (!strstr(argv[2], "filelist")) {
|
---|
[497] | 331 | printf(_("Sorry - filelist goes first\n"));
|
---|
[128] | 332 | finish(1);
|
---|
| 333 | } else {
|
---|
| 334 | finish(get_fattr_list(argv[2], argv[3]));
|
---|
| 335 | }
|
---|
| 336 | finish(0);
|
---|
[1] | 337 | }
|
---|
[128] | 338 | if (argc == 4 && !strcmp(argv[1], "setfattr")) {
|
---|
| 339 | g_loglevel = 10;
|
---|
[1] | 340 | // chdir("/tmp");
|
---|
[128] | 341 | g_text_mode = TRUE;
|
---|
| 342 | setup_newt_stuff();
|
---|
| 343 | finish(set_fattr_list(argv[2], argv[3]));
|
---|
[1] | 344 | }
|
---|
[128] | 345 |
|
---|
| 346 | if (argc == 3 && !strcmp(argv[1], "wildcards")) {
|
---|
| 347 | g_loglevel = 10;
|
---|
| 348 | g_text_mode = TRUE;
|
---|
| 349 | setup_newt_stuff();
|
---|
| 350 | turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
|
---|
| 351 | printf("in=%s; out=%s\n", argv[2], tmp);
|
---|
| 352 | finish(1);
|
---|
[1] | 353 | }
|
---|
[128] | 354 |
|
---|
| 355 | if (argc == 4 && !strcmp(argv[1], "getfacl")) {
|
---|
| 356 | g_loglevel = 10;
|
---|
| 357 | g_text_mode = TRUE;
|
---|
| 358 | setup_newt_stuff();
|
---|
| 359 | if (!strstr(argv[2], "filelist")) {
|
---|
[497] | 360 | printf(_("Sorry - filelist goes first\n"));
|
---|
[128] | 361 | finish(1);
|
---|
| 362 | } else {
|
---|
| 363 | finish(get_acl_list(argv[2], argv[3]));
|
---|
| 364 | }
|
---|
| 365 | finish(0);
|
---|
| 366 | }
|
---|
| 367 | if (argc == 4 && !strcmp(argv[1], "setfacl")) {
|
---|
| 368 | g_loglevel = 10;
|
---|
[1] | 369 | // chdir("/tmp");
|
---|
[128] | 370 | g_text_mode = TRUE;
|
---|
| 371 | setup_newt_stuff();
|
---|
| 372 | finish(set_acl_list(argv[2], argv[3]));
|
---|
| 373 | }
|
---|
[1] | 374 |
|
---|
[128] | 375 | if (argc > 2 && !strcmp(argv[1], "find-cd")) {
|
---|
| 376 | g_loglevel = 10;
|
---|
| 377 | g_text_mode = TRUE;
|
---|
| 378 | setup_newt_stuff();
|
---|
| 379 | if (find_cdrw_device(tmp)) {
|
---|
[497] | 380 | printf(_("Failed to find CDR-RW drive\n"));
|
---|
[128] | 381 | } else {
|
---|
[497] | 382 | printf(_("CD-RW is at %s\n"), tmp);
|
---|
[128] | 383 | }
|
---|
| 384 | tmp[0] = '\0';
|
---|
| 385 | if (find_cdrom_device(tmp, atoi(argv[2]))) {
|
---|
[497] | 386 | printf(_("Failed to find CD-ROM drive\n"));
|
---|
[128] | 387 | } else {
|
---|
[497] | 388 | printf(_("CD-ROM is at %s\n"), tmp);
|
---|
[128] | 389 | }
|
---|
| 390 | finish(0);
|
---|
| 391 | }
|
---|
[1] | 392 |
|
---|
[128] | 393 | if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
|
---|
| 394 | g_loglevel = 10;
|
---|
| 395 | g_text_mode = TRUE;
|
---|
| 396 | setup_newt_stuff();
|
---|
| 397 | if (find_dvd_device(tmp, atoi(argv[2]))) {
|
---|
[497] | 398 | printf(_("Failed to find DVD drive\n"));
|
---|
[128] | 399 | } else {
|
---|
[497] | 400 | printf(_("DVD is at %s\n"), tmp);
|
---|
[128] | 401 | }
|
---|
| 402 | finish(0);
|
---|
| 403 | }
|
---|
[1] | 404 |
|
---|
[128] | 405 | if (argc > 2 && !strcmp(argv[1], "disksize")) {
|
---|
| 406 | printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
|
---|
| 407 | finish(0);
|
---|
| 408 | }
|
---|
| 409 | if (argc > 2 && !strcmp(argv[1], "test-dev")) {
|
---|
| 410 | if (is_dev_an_NTFS_dev(argv[2])) {
|
---|
[497] | 411 | printf(_("%s is indeed an NTFS dev\n"), argv[2]);
|
---|
[128] | 412 | } else {
|
---|
[497] | 413 | printf(_("%s is _not_ an NTFS dev\n"), argv[2]);
|
---|
[128] | 414 | }
|
---|
| 415 | finish(0);
|
---|
| 416 | }
|
---|
| 417 |
|
---|
| 418 | if (pre_param_configuration(bkpinfo)) {
|
---|
| 419 | fatal_error
|
---|
| 420 | ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
|
---|
| 421 | }
|
---|
| 422 |
|
---|
[1] | 423 | /* Process command line, if there is one. If not, ask user for info. */
|
---|
[128] | 424 | if (argc == 1) {
|
---|
| 425 | g_text_mode = FALSE;
|
---|
| 426 | setup_newt_stuff();
|
---|
| 427 | res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE); /* yes, archiving */
|
---|
| 428 | if (res) {
|
---|
| 429 | fatal_error
|
---|
| 430 | ("Syntax error. Please review the parameters you have supplied and try again.");
|
---|
| 431 | }
|
---|
| 432 | } else {
|
---|
| 433 | res = handle_incoming_parameters(argc, argv, bkpinfo);
|
---|
| 434 | if (res) {
|
---|
| 435 | printf
|
---|
[497] | 436 | (_("Errors were detected in the command line you supplied.\n"));
|
---|
| 437 | printf(_("Please review the log file - %s \n"),MONDO_LOGFILE);
|
---|
[128] | 438 | log_msg(1, "Mondoarchive will now exit.");
|
---|
| 439 | finish(1);
|
---|
| 440 | }
|
---|
| 441 | setup_newt_stuff();
|
---|
[1] | 442 | }
|
---|
| 443 |
|
---|
| 444 | /* Finish configuring global structures */
|
---|
[128] | 445 | if (post_param_configuration(bkpinfo)) {
|
---|
| 446 | fatal_error
|
---|
| 447 | ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
|
---|
| 448 | }
|
---|
[1] | 449 |
|
---|
[128] | 450 | log_to_screen
|
---|
[497] | 451 | (_("BusyBox's sources are available from http://www.busybox.net"));
|
---|
[128] | 452 | sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
|
---|
| 453 | bkpinfo->scratchdir);
|
---|
[1] | 454 |
|
---|
[128] | 455 | /* If we're meant to backup then backup */
|
---|
| 456 | if (bkpinfo->backup_data) {
|
---|
[1] | 457 | /*
|
---|
| 458 | log_to_screen("INFERNAL PORPOISES");
|
---|
| 459 | res = archive_this_fileset_with_star(bkpinfo, "/tmp/filelist.0", "/tmp/0.star.bz2", 0);
|
---|
| 460 | log_to_screen("atfws returned %d", res);
|
---|
| 461 | finish(0);
|
---|
| 462 | */
|
---|
[538] | 463 | res = backup_data(bkpinfo, mrconf);
|
---|
[128] | 464 | retval += res;
|
---|
| 465 | if (res) {
|
---|
| 466 | strcat(say_at_end,
|
---|
[497] | 467 | _("Data archived. Please check the logs, just as a precaution. "));
|
---|
[128] | 468 | } else {
|
---|
[497] | 469 | strcat(say_at_end, _("Data archived OK. "));
|
---|
[128] | 470 | }
|
---|
| 471 | }
|
---|
[1] | 472 |
|
---|
| 473 | /* If we're meant to verify then verify */
|
---|
[128] | 474 | if (bkpinfo->verify_data) {
|
---|
| 475 | res = verify_data(bkpinfo);
|
---|
| 476 | if (res < 0) {
|
---|
[497] | 477 | sprintf(tmp, _("%d difference%c found."), -res,
|
---|
[128] | 478 | (-res != 1) ? 's' : ' ');
|
---|
| 479 | strcat(say_at_end, tmp);
|
---|
| 480 | log_to_screen(tmp);
|
---|
| 481 | res = 0;
|
---|
| 482 | }
|
---|
| 483 | retval += res;
|
---|
| 484 | }
|
---|
[1] | 485 |
|
---|
| 486 | /* Offer to write floppy disk images to physical disks */
|
---|
[128] | 487 | if (bkpinfo->backup_data && !g_skip_floppies) {
|
---|
| 488 | res = offer_to_write_boot_floppies_to_physical_disks(bkpinfo);
|
---|
| 489 | retval += res;
|
---|
[1] | 490 | // res = offer_to_write_boot_ISO_to_physical_CD(bkpinfo);
|
---|
| 491 | // retval += res;
|
---|
[128] | 492 | }
|
---|
[1] | 493 |
|
---|
| 494 | /* Report result of entire operation (success? errors?) */
|
---|
[128] | 495 | if (!retval) {
|
---|
| 496 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[497] | 497 | _("Backup and/or verify ran to completion. Everything appears to be fine."));
|
---|
[128] | 498 | } else {
|
---|
| 499 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[497] | 500 | _("Backup and/or verify ran to completion. However, errors did occur."));
|
---|
[128] | 501 | }
|
---|
[1] | 502 |
|
---|
[538] | 503 | if (does_file_exist("/var/cache/mindi/mondorescue.iso")) {
|
---|
[128] | 504 | log_to_screen
|
---|
[538] | 505 | (_("/var/cache/mindi/mondorescue.iso, a boot/utility CD, is available if you want it."));
|
---|
[128] | 506 | }
|
---|
[1] | 507 |
|
---|
| 508 |
|
---|
[128] | 509 | if (length_of_file("/tmp/changed.files") > 2) {
|
---|
| 510 | if (g_text_mode) {
|
---|
| 511 | log_to_screen
|
---|
[497] | 512 | (_("Type 'less /tmp/changed.files' to see which files don't match the archives"));
|
---|
[128] | 513 | } else {
|
---|
| 514 | log_msg(1,
|
---|
[497] | 515 | _("Type 'less /tmp/changed.files' to see which files don't match the archives"));
|
---|
[128] | 516 | log_msg(2, "Calling popup_changelist_from_file()");
|
---|
| 517 | popup_changelist_from_file("/tmp/changed.files");
|
---|
| 518 | log_msg(2, "Returned from popup_changelist_from_file()");
|
---|
| 519 | }
|
---|
| 520 | } else {
|
---|
| 521 | unlink("/tmp/changed.files");
|
---|
| 522 | }
|
---|
| 523 | log_to_screen(say_at_end);
|
---|
| 524 | sprintf(tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
|
---|
| 525 | run_program_and_log_output(tmp, TRUE);
|
---|
| 526 | run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
|
---|
[1] | 527 |
|
---|
[128] | 528 | run_program_and_log_output("mount", 2);
|
---|
[1] | 529 |
|
---|
[128] | 530 | system("rm -f /var/cache/mondo-archive/last-backup.aborted");
|
---|
| 531 | system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
|
---|
| 532 | if (!retval) {
|
---|
[497] | 533 | printf(_("Mondoarchive ran OK.\n"));
|
---|
[128] | 534 | } else {
|
---|
[497] | 535 | printf(_("Errors occurred during backup. Please check logfile.\n"));
|
---|
[128] | 536 | }
|
---|
| 537 | distro_specific_kludges_at_end_of_mondoarchive();
|
---|
| 538 | register_pid(0, "mondo");
|
---|
| 539 | set_signals(FALSE);
|
---|
| 540 | chdir("/tmp"); // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
|
---|
| 541 | system(g_erase_tmpdir_and_scratchdir);
|
---|
| 542 | free_libmondo_global_strings();
|
---|
| 543 | paranoid_free(say_at_end);
|
---|
| 544 | paranoid_free(tmp);
|
---|
| 545 | paranoid_free(bkpinfo);
|
---|
[1] | 546 |
|
---|
[128] | 547 | unlink("/tmp/filelist.full");
|
---|
| 548 | unlink("/tmp/filelist.full.gz");
|
---|
[1] | 549 |
|
---|
[128] | 550 | if (!g_cdrom_drive_is_here) {
|
---|
| 551 | log_msg(10, "FYI, g_cdrom_drive_is_here was never used");
|
---|
| 552 | }
|
---|
| 553 | if (!g_dvd_drive_is_here) {
|
---|
| 554 | log_msg(10, "FYI, g_dvd_drive_is_here was never used");
|
---|
| 555 | }
|
---|
[1] | 556 |
|
---|
[128] | 557 | if (!g_text_mode) {
|
---|
| 558 | popup_and_OK
|
---|
[497] | 559 | (_("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt."));
|
---|
| 560 | log_to_screen(_("See %s for details of backup run."), MONDO_LOGFILE);
|
---|
[128] | 561 | finish(retval);
|
---|
| 562 | } else {
|
---|
[497] | 563 | printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
|
---|
[128] | 564 | exit(retval);
|
---|
| 565 | }
|
---|
| 566 |
|
---|
| 567 | return EXIT_SUCCESS;
|
---|
[1] | 568 | }
|
---|