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