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