[1] | 1 | /***************************************************************************
|
---|
[1080] | 2 | * $Id: main.c 1102 2007-02-05 23:49:19Z bruno $
|
---|
| 3 | */
|
---|
[1] | 4 |
|
---|
| 5 |
|
---|
| 6 | /**
|
---|
| 7 | * @file
|
---|
| 8 | * The main file for mondoarchive.
|
---|
| 9 | */
|
---|
| 10 |
|
---|
| 11 | /************************* #include statements *************************/
|
---|
| 12 | #include <pthread.h>
|
---|
| 13 | #include <stdio.h>
|
---|
| 14 | #include <stdlib.h>
|
---|
[1100] | 15 | #include <sys/types.h>
|
---|
| 16 | #include <sys/stat.h>
|
---|
| 17 | #include <unistd.h>
|
---|
| 18 |
|
---|
[1067] | 19 | #include "my-stuff.h"
|
---|
[1] | 20 | #include "../common/mondostructures.h"
|
---|
| 21 | #include "../common/libmondo.h"
|
---|
| 22 | #include "mondo-cli-EXT.h"
|
---|
| 23 |
|
---|
[1087] | 24 | #include "mr_str.h"
|
---|
[1102] | 25 | #include "mr_file.h"
|
---|
[1087] | 26 |
|
---|
[1] | 27 | // for CVS
|
---|
[128] | 28 | //static char cvsid[] = "$Id: main.c 1102 2007-02-05 23:49:19Z bruno $";
|
---|
[1] | 29 |
|
---|
| 30 | /************************* external variables *************************/
|
---|
| 31 | extern void set_signals(int);
|
---|
| 32 | extern int g_current_media_number;
|
---|
[128] | 33 | extern void register_pid(pid_t, char *);
|
---|
[1] | 34 | extern int g_currentY;
|
---|
| 35 | extern bool g_text_mode;
|
---|
| 36 | extern char *g_boot_mountpt;
|
---|
| 37 | extern bool g_remount_cdrom_at_end, g_remount_floppy_at_end;
|
---|
| 38 | extern char *g_mondo_home;
|
---|
| 39 | extern char *g_tmpfs_mountpt;
|
---|
| 40 | extern char *g_erase_tmpdir_and_scratchdir;
|
---|
| 41 | extern char *g_cdrw_drive_is_here;
|
---|
[128] | 42 | static char *g_cdrom_drive_is_here = NULL;
|
---|
| 43 | static char *g_dvd_drive_is_here = NULL;
|
---|
[1] | 44 | extern double g_kernel_version;
|
---|
| 45 |
|
---|
| 46 | /***************** global vars, used only by main.c ******************/
|
---|
| 47 | bool g_skip_floppies;
|
---|
| 48 | long diffs;
|
---|
[792] | 49 | char *ps_options = "auxww";
|
---|
[928] | 50 | char *ps_proc_id = "$2";
|
---|
[1] | 51 |
|
---|
| 52 | extern t_bkptype g_backup_media_type;
|
---|
| 53 | extern int g_loglevel;
|
---|
| 54 |
|
---|
| 55 | /****************** subroutines used only by main.c ******************/
|
---|
| 56 |
|
---|
| 57 |
|
---|
| 58 | /**
|
---|
| 59 | * Print a "don't panic" message to the log and a message about the logfile to the screen.
|
---|
| 60 | */
|
---|
| 61 | void welcome_to_mondoarchive()
|
---|
| 62 | {
|
---|
[128] | 63 | log_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org",
|
---|
[251] | 64 | PACKAGE_VERSION);
|
---|
[128] | 65 | log_msg(0, "running on %s architecture", get_architecture());
|
---|
| 66 | log_msg(0,
|
---|
| 67 | "-----------------------------------------------------------");
|
---|
| 68 | log_msg(0,
|
---|
| 69 | "NB: Mondo logs almost everything, so don't panic if you see");
|
---|
| 70 | log_msg(0,
|
---|
| 71 | "some error messages. Please read them carefully before you");
|
---|
| 72 | log_msg(0,
|
---|
| 73 | "decide to break out in a cold sweat. Despite (or perhaps");
|
---|
| 74 | log_msg(0,
|
---|
| 75 | "because of) the wealth of messages. some users are inclined");
|
---|
| 76 | log_msg(0,
|
---|
| 77 | "to stop reading this log. If Mondo stopped for some reason,");
|
---|
| 78 | log_msg(0,
|
---|
| 79 | "chances are it's detailed here. More than likely there's a");
|
---|
| 80 | log_msg(0,
|
---|
| 81 | "message at the very end of this log that will tell you what");
|
---|
| 82 | log_msg(0,
|
---|
| 83 | "is wrong. Please read it! -Devteam");
|
---|
| 84 | log_msg(0,
|
---|
| 85 | "-----------------------------------------------------------");
|
---|
[1] | 86 |
|
---|
[128] | 87 | log_msg(0, "Zero...");
|
---|
| 88 | log_msg(1, "One...");
|
---|
| 89 | log_msg(2, "Two...");
|
---|
| 90 | log_msg(3, "Three...");
|
---|
| 91 | log_msg(4, "Four...");
|
---|
| 92 | log_msg(5, "Five...");
|
---|
| 93 | log_msg(6, "Six...");
|
---|
| 94 | log_msg(7, "Seven...");
|
---|
| 95 | log_msg(8, "Eight...");
|
---|
| 96 | printf("See %s for details of backup run.\n", MONDO_LOGFILE);
|
---|
[1] | 97 | }
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | extern char *g_magicdev_command;
|
---|
| 101 |
|
---|
| 102 | /**
|
---|
| 103 | * Do whatever is necessary to insure a successful backup on the Linux distribution
|
---|
| 104 | * of the day.
|
---|
| 105 | */
|
---|
| 106 | void distro_specific_kludges_at_start_of_mondoarchive()
|
---|
| 107 | {
|
---|
[128] | 108 | log_msg(2, "Unmounting old ramdisks if necessary");
|
---|
| 109 | stop_magicdev_if_necessary(); // for RH+Gnome users
|
---|
| 110 | run_program_and_log_output
|
---|
| 111 | ("umount `mount | grep shm | grep mondo | cut -d' ' -f3`", 2);
|
---|
| 112 | unmount_supermounts_if_necessary(); // for Mandrake users whose CD-ROMs are supermounted
|
---|
| 113 | // stop_autofs_if_necessary(); // for Xandros users
|
---|
| 114 | mount_boot_if_necessary(); // for Gentoo users with non-mounted /boot partitions
|
---|
| 115 | clean_up_KDE_desktop_if_necessary(); // delete various misc ~/.* files that get in the way
|
---|
[1] | 116 | }
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 |
|
---|
| 120 | /**
|
---|
| 121 | * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive().
|
---|
| 122 | */
|
---|
| 123 | void distro_specific_kludges_at_end_of_mondoarchive()
|
---|
| 124 | {
|
---|
| 125 | // char tmp[500];
|
---|
[128] | 126 | log_msg(2, "Restarting magicdev if necessary");
|
---|
| 127 | sync();
|
---|
| 128 | restart_magicdev_if_necessary(); // for RH+Gnome users
|
---|
[1] | 129 |
|
---|
[128] | 130 | log_msg(2, "Restarting autofs if necessary");
|
---|
| 131 | sync();
|
---|
| 132 | // restart_autofs_if_necessary(); // for Xandros users
|
---|
[1] | 133 |
|
---|
[128] | 134 | log_msg(2, "Restarting supermounts if necessary");
|
---|
| 135 | sync();
|
---|
| 136 | remount_supermounts_if_necessary(); // for Mandrake users
|
---|
[1] | 137 |
|
---|
[128] | 138 | log_msg(2, "Unmounting /boot if necessary");
|
---|
| 139 | sync();
|
---|
| 140 | unmount_boot_if_necessary(); // for Gentoo users
|
---|
[1] | 141 |
|
---|
| 142 | // log_msg( 2, "Cleaning up KDE desktop");
|
---|
| 143 | // clean_up_KDE_desktop_if_necessary();
|
---|
| 144 | }
|
---|
| 145 |
|
---|
| 146 | /*-----------------------------------------------------------*/
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 |
|
---|
| 150 | /**
|
---|
| 151 | * Backup/verify the user's data.
|
---|
| 152 | * What did you think it did, anyway? :-)
|
---|
| 153 | */
|
---|
[128] | 154 | int main(int argc, char *argv[])
|
---|
[1] | 155 | {
|
---|
[128] | 156 | struct s_bkpinfo *bkpinfo;
|
---|
[1100] | 157 | struct stat stbuf;
|
---|
[128] | 158 | char *tmp;
|
---|
| 159 | int res, retval;
|
---|
| 160 | char *say_at_end;
|
---|
[1] | 161 |
|
---|
| 162 | /* Make sure I'm root; abort if not */
|
---|
[128] | 163 | if (getuid() != 0) {
|
---|
[541] | 164 | fprintf(stderr, "Please run as root.\r\n");
|
---|
[128] | 165 | exit(127);
|
---|
| 166 | }
|
---|
[1] | 167 |
|
---|
| 168 | /* If -V, -v or --version then echo version no. and quit */
|
---|
[128] | 169 | if (argc == 2
|
---|
| 170 | && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
|
---|
| 171 | || !strcmp(argv[argc - 1], "--version"))) {
|
---|
[541] | 172 | printf("mondoarchive v%s\nSee man page for help\n", PACKAGE_VERSION);
|
---|
[128] | 173 | exit(0);
|
---|
| 174 | }
|
---|
[1] | 175 |
|
---|
| 176 | /* Initialize variables */
|
---|
| 177 |
|
---|
[128] | 178 | malloc_libmondo_global_strings();
|
---|
| 179 | malloc_string(tmp);
|
---|
| 180 | malloc_string(say_at_end);
|
---|
[1] | 181 |
|
---|
[128] | 182 | res = 0;
|
---|
| 183 | retval = 0;
|
---|
| 184 | diffs = 0;
|
---|
| 185 | say_at_end[0] = '\0';
|
---|
[541] | 186 | printf("Initializing...\n");
|
---|
[1080] | 187 | bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
|
---|
[1] | 188 |
|
---|
[810] | 189 | /* initialize log file with time stamp */
|
---|
| 190 | unlink(MONDO_LOGFILE);
|
---|
[813] | 191 | log_msg(0, "Time started: %s", mr_date());
|
---|
[1] | 192 |
|
---|
[807] | 193 | /* make sure PATH environmental variable allows access to mkfs, fdisk, etc. */
|
---|
[128] | 194 | strncpy(tmp, getenv("PATH"), MAX_STR_LEN - 1);
|
---|
| 195 | tmp[MAX_STR_LEN - 1] = '\0';
|
---|
| 196 | if (strlen(tmp) >= MAX_STR_LEN - 33) {
|
---|
| 197 | fatal_error
|
---|
| 198 | ("Your PATH environmental variable is too long. Please shorten it.");
|
---|
| 199 | }
|
---|
| 200 | strcat(tmp, ":/sbin:/usr/sbin:/usr/local/sbin");
|
---|
| 201 | setenv("PATH", tmp, 1);
|
---|
[1] | 202 |
|
---|
[807] | 203 | /* Add the ARCH environment variable for ia64 purposes */
|
---|
[128] | 204 | strncpy(tmp, get_architecture(), MAX_STR_LEN - 1);
|
---|
| 205 | tmp[MAX_STR_LEN - 1] = '\0';
|
---|
| 206 | setenv("ARCH", tmp, 1);
|
---|
[1] | 207 |
|
---|
[1100] | 208 | /* Add MONDO_SHARE + others environment variable for mindi */
|
---|
[424] | 209 | setenv_mondo_share();
|
---|
[258] | 210 |
|
---|
[1100] | 211 | if (stat(MONDO_CACHE, &stbuf) != 0) {
|
---|
| 212 | mr_mkdir(MONDO_CACHE,0x755);
|
---|
| 213 | }
|
---|
| 214 |
|
---|
[807] | 215 | /* Configure the bkpinfo structure, global file paths, etc. */
|
---|
[128] | 216 | g_main_pid = getpid();
|
---|
| 217 | log_msg(9, "This");
|
---|
[1] | 218 |
|
---|
[128] | 219 | register_pid(g_main_pid, "mondo");
|
---|
| 220 | set_signals(TRUE); // catch SIGTERM, etc.
|
---|
| 221 | run_program_and_log_output("dmesg -n1", TRUE);
|
---|
[1] | 222 |
|
---|
[128] | 223 | log_msg(9, "Next");
|
---|
| 224 | welcome_to_mondoarchive();
|
---|
| 225 | distro_specific_kludges_at_start_of_mondoarchive();
|
---|
| 226 | sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
|
---|
| 227 | bkpinfo->scratchdir);
|
---|
| 228 | g_kernel_version = get_kernel_version();
|
---|
[1] | 229 |
|
---|
[128] | 230 | if (argc == 4 && !strcmp(argv[1], "getfattr")) {
|
---|
| 231 | g_loglevel = 10;
|
---|
| 232 | g_text_mode = TRUE;
|
---|
| 233 | setup_newt_stuff();
|
---|
| 234 | if (!strstr(argv[2], "filelist")) {
|
---|
[541] | 235 | printf("Sorry - filelist goes first\n");
|
---|
[128] | 236 | finish(1);
|
---|
| 237 | } else {
|
---|
| 238 | finish(get_fattr_list(argv[2], argv[3]));
|
---|
| 239 | }
|
---|
| 240 | finish(0);
|
---|
[1] | 241 | }
|
---|
[128] | 242 | if (argc == 4 && !strcmp(argv[1], "setfattr")) {
|
---|
| 243 | g_loglevel = 10;
|
---|
[1] | 244 | // chdir("/tmp");
|
---|
[128] | 245 | g_text_mode = TRUE;
|
---|
| 246 | setup_newt_stuff();
|
---|
| 247 | finish(set_fattr_list(argv[2], argv[3]));
|
---|
[1] | 248 | }
|
---|
[128] | 249 |
|
---|
| 250 | if (argc == 3 && !strcmp(argv[1], "wildcards")) {
|
---|
| 251 | g_loglevel = 10;
|
---|
| 252 | g_text_mode = TRUE;
|
---|
| 253 | setup_newt_stuff();
|
---|
| 254 | turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
|
---|
| 255 | printf("in=%s; out=%s\n", argv[2], tmp);
|
---|
| 256 | finish(1);
|
---|
[1] | 257 | }
|
---|
[128] | 258 |
|
---|
| 259 | if (argc == 4 && !strcmp(argv[1], "getfacl")) {
|
---|
| 260 | g_loglevel = 10;
|
---|
| 261 | g_text_mode = TRUE;
|
---|
| 262 | setup_newt_stuff();
|
---|
| 263 | if (!strstr(argv[2], "filelist")) {
|
---|
[541] | 264 | printf("Sorry - filelist goes first\n");
|
---|
[128] | 265 | finish(1);
|
---|
| 266 | } else {
|
---|
| 267 | finish(get_acl_list(argv[2], argv[3]));
|
---|
| 268 | }
|
---|
| 269 | finish(0);
|
---|
| 270 | }
|
---|
| 271 | if (argc == 4 && !strcmp(argv[1], "setfacl")) {
|
---|
| 272 | g_loglevel = 10;
|
---|
[1] | 273 | // chdir("/tmp");
|
---|
[128] | 274 | g_text_mode = TRUE;
|
---|
| 275 | setup_newt_stuff();
|
---|
| 276 | finish(set_acl_list(argv[2], argv[3]));
|
---|
| 277 | }
|
---|
[1] | 278 |
|
---|
[128] | 279 | if (argc > 2 && !strcmp(argv[1], "find-cd")) {
|
---|
| 280 | g_loglevel = 10;
|
---|
| 281 | g_text_mode = TRUE;
|
---|
| 282 | setup_newt_stuff();
|
---|
| 283 | if (find_cdrw_device(tmp)) {
|
---|
[541] | 284 | printf("Failed to find CDR-RW drive\n");
|
---|
[128] | 285 | } else {
|
---|
[541] | 286 | printf("CD-RW is at %s\n", tmp);
|
---|
[128] | 287 | }
|
---|
| 288 | tmp[0] = '\0';
|
---|
| 289 | if (find_cdrom_device(tmp, atoi(argv[2]))) {
|
---|
[541] | 290 | printf("Failed to find CD-ROM drive\n");
|
---|
[128] | 291 | } else {
|
---|
[541] | 292 | printf("CD-ROM is at %s\n", tmp);
|
---|
[128] | 293 | }
|
---|
| 294 | finish(0);
|
---|
| 295 | }
|
---|
[1] | 296 |
|
---|
[128] | 297 | if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
|
---|
| 298 | g_loglevel = 10;
|
---|
| 299 | g_text_mode = TRUE;
|
---|
| 300 | setup_newt_stuff();
|
---|
| 301 | if (find_dvd_device(tmp, atoi(argv[2]))) {
|
---|
[541] | 302 | printf("Failed to find DVD drive\n");
|
---|
[128] | 303 | } else {
|
---|
[541] | 304 | printf("DVD is at %s\n", tmp);
|
---|
[128] | 305 | }
|
---|
| 306 | finish(0);
|
---|
| 307 | }
|
---|
[1] | 308 |
|
---|
[128] | 309 | if (argc > 2 && !strcmp(argv[1], "disksize")) {
|
---|
| 310 | printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
|
---|
| 311 | finish(0);
|
---|
| 312 | }
|
---|
| 313 | if (argc > 2 && !strcmp(argv[1], "test-dev")) {
|
---|
| 314 | if (is_dev_an_NTFS_dev(argv[2])) {
|
---|
[541] | 315 | printf("%s is indeed an NTFS dev\n", argv[2]);
|
---|
[128] | 316 | } else {
|
---|
[541] | 317 | printf("%s is _not_ an NTFS dev\n", argv[2]);
|
---|
[128] | 318 | }
|
---|
| 319 | finish(0);
|
---|
| 320 | }
|
---|
| 321 |
|
---|
| 322 | if (pre_param_configuration(bkpinfo)) {
|
---|
| 323 | fatal_error
|
---|
| 324 | ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
|
---|
| 325 | }
|
---|
| 326 |
|
---|
[1] | 327 | /* Process command line, if there is one. If not, ask user for info. */
|
---|
[128] | 328 | if (argc == 1) {
|
---|
| 329 | g_text_mode = FALSE;
|
---|
| 330 | setup_newt_stuff();
|
---|
| 331 | res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE); /* yes, archiving */
|
---|
| 332 | if (res) {
|
---|
| 333 | fatal_error
|
---|
| 334 | ("Syntax error. Please review the parameters you have supplied and try again.");
|
---|
| 335 | }
|
---|
| 336 | } else {
|
---|
| 337 | res = handle_incoming_parameters(argc, argv, bkpinfo);
|
---|
| 338 | if (res) {
|
---|
| 339 | printf
|
---|
[541] | 340 | ("Errors were detected in the command line you supplied.\n");
|
---|
| 341 | printf("Please review the log file - " MONDO_LOGFILE "\n");
|
---|
[128] | 342 | log_msg(1, "Mondoarchive will now exit.");
|
---|
| 343 | finish(1);
|
---|
| 344 | }
|
---|
| 345 | setup_newt_stuff();
|
---|
[1] | 346 | }
|
---|
| 347 |
|
---|
| 348 | /* Finish configuring global structures */
|
---|
[128] | 349 | if (post_param_configuration(bkpinfo)) {
|
---|
| 350 | fatal_error
|
---|
| 351 | ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
|
---|
| 352 | }
|
---|
[1] | 353 |
|
---|
[128] | 354 | log_to_screen
|
---|
[541] | 355 | ("BusyBox's sources are available from http://www.busybox.net");
|
---|
[128] | 356 | sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
|
---|
| 357 | bkpinfo->scratchdir);
|
---|
[1] | 358 |
|
---|
[128] | 359 | /* If we're meant to backup then backup */
|
---|
| 360 | if (bkpinfo->backup_data) {
|
---|
[541] | 361 | res = backup_data(bkpinfo);
|
---|
[128] | 362 | retval += res;
|
---|
| 363 | if (res) {
|
---|
| 364 | strcat(say_at_end,
|
---|
[541] | 365 | "Data archived. Please check the logs, just as a precaution. ");
|
---|
[128] | 366 | } else {
|
---|
[541] | 367 | strcat(say_at_end, "Data archived OK. ");
|
---|
[128] | 368 | }
|
---|
| 369 | }
|
---|
[1] | 370 |
|
---|
| 371 | /* If we're meant to verify then verify */
|
---|
[128] | 372 | if (bkpinfo->verify_data) {
|
---|
| 373 | res = verify_data(bkpinfo);
|
---|
| 374 | if (res < 0) {
|
---|
[541] | 375 | sprintf(tmp, "%d difference%c found.", -res,
|
---|
[128] | 376 | (-res != 1) ? 's' : ' ');
|
---|
| 377 | strcat(say_at_end, tmp);
|
---|
| 378 | log_to_screen(tmp);
|
---|
| 379 | res = 0;
|
---|
| 380 | }
|
---|
| 381 | retval += res;
|
---|
| 382 | }
|
---|
[1] | 383 |
|
---|
| 384 | /* Offer to write floppy disk images to physical disks */
|
---|
[128] | 385 | if (bkpinfo->backup_data && !g_skip_floppies) {
|
---|
| 386 | res = offer_to_write_boot_floppies_to_physical_disks(bkpinfo);
|
---|
| 387 | retval += res;
|
---|
[1] | 388 | // res = offer_to_write_boot_ISO_to_physical_CD(bkpinfo);
|
---|
| 389 | // retval += res;
|
---|
[128] | 390 | }
|
---|
[1] | 391 |
|
---|
| 392 | /* Report result of entire operation (success? errors?) */
|
---|
[128] | 393 | if (!retval) {
|
---|
| 394 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[541] | 395 | "Backup and/or verify ran to completion. Everything appears to be fine.");
|
---|
[128] | 396 | } else {
|
---|
| 397 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[541] | 398 | "Backup and/or verify ran to completion. However, errors did occur.");
|
---|
[128] | 399 | }
|
---|
[1] | 400 |
|
---|
[1044] | 401 | if (does_file_exist("/var/cache/mindi/mondorescue.iso")) {
|
---|
[128] | 402 | log_to_screen
|
---|
[1044] | 403 | ("/var/cache/mindi/mondorescue.iso, a boot/utility CD, is available if you want it.");
|
---|
[128] | 404 | }
|
---|
[1] | 405 |
|
---|
| 406 |
|
---|
[128] | 407 | if (length_of_file("/tmp/changed.files") > 2) {
|
---|
| 408 | if (g_text_mode) {
|
---|
| 409 | log_to_screen
|
---|
[541] | 410 | ("Type 'less /tmp/changed.files' to see which files don't match the archives");
|
---|
[128] | 411 | } else {
|
---|
| 412 | log_msg(1,
|
---|
[541] | 413 | "Type 'less /tmp/changed.files' to see which files don't match the archives");
|
---|
[128] | 414 | log_msg(2, "Calling popup_changelist_from_file()");
|
---|
| 415 | popup_changelist_from_file("/tmp/changed.files");
|
---|
| 416 | log_msg(2, "Returned from popup_changelist_from_file()");
|
---|
| 417 | }
|
---|
| 418 | } else {
|
---|
| 419 | unlink("/tmp/changed.files");
|
---|
| 420 | }
|
---|
| 421 | log_to_screen(say_at_end);
|
---|
| 422 | sprintf(tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
|
---|
| 423 | run_program_and_log_output(tmp, TRUE);
|
---|
| 424 | run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
|
---|
[1] | 425 |
|
---|
[128] | 426 | run_program_and_log_output("mount", 2);
|
---|
[1] | 427 |
|
---|
[128] | 428 | system("rm -f /var/cache/mondo-archive/last-backup.aborted");
|
---|
| 429 | system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
|
---|
| 430 | if (!retval) {
|
---|
[541] | 431 | printf("Mondoarchive ran OK.\n");
|
---|
[128] | 432 | } else {
|
---|
[541] | 433 | printf("Errors occurred during backup. Please check logfile.\n");
|
---|
[128] | 434 | }
|
---|
| 435 | distro_specific_kludges_at_end_of_mondoarchive();
|
---|
| 436 | register_pid(0, "mondo");
|
---|
| 437 | set_signals(FALSE);
|
---|
| 438 | chdir("/tmp"); // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
|
---|
| 439 | system(g_erase_tmpdir_and_scratchdir);
|
---|
| 440 | free_libmondo_global_strings();
|
---|
[1080] | 441 | mr_free(say_at_end);
|
---|
| 442 | mr_free(tmp);
|
---|
| 443 | mr_free(bkpinfo);
|
---|
[1] | 444 |
|
---|
[128] | 445 | unlink("/tmp/filelist.full");
|
---|
| 446 | unlink("/tmp/filelist.full.gz");
|
---|
[1] | 447 |
|
---|
[128] | 448 | if (!g_cdrom_drive_is_here) {
|
---|
| 449 | log_msg(10, "FYI, g_cdrom_drive_is_here was never used");
|
---|
| 450 | }
|
---|
| 451 | if (!g_dvd_drive_is_here) {
|
---|
| 452 | log_msg(10, "FYI, g_dvd_drive_is_here was never used");
|
---|
| 453 | }
|
---|
[1] | 454 |
|
---|
[810] | 455 | /* finalize log file with time stamp */
|
---|
[813] | 456 | log_msg(0, "Time finished: %s", mr_date());
|
---|
[810] | 457 |
|
---|
[128] | 458 | if (!g_text_mode) {
|
---|
| 459 | popup_and_OK
|
---|
[541] | 460 | ("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt.");
|
---|
| 461 | log_to_screen("See %s for details of backup run.", MONDO_LOGFILE);
|
---|
[128] | 462 | finish(retval);
|
---|
| 463 | } else {
|
---|
[541] | 464 | printf("See %s for details of backup run.\n", MONDO_LOGFILE);
|
---|
[128] | 465 | exit(retval);
|
---|
| 466 | }
|
---|
| 467 |
|
---|
| 468 | return EXIT_SUCCESS;
|
---|
[1] | 469 | }
|
---|