[1] | 1 | /***************************************************************************
|
---|
[1080] | 2 | * $Id: mondoarchive.c 1228 2007-03-06 12:14:45Z 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 1228 2007-03-06 12:14:45Z 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_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 | 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 | * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive().
|
---|
| 121 | */
|
---|
[1151] | 122 | void distro_specific_kludges_at_end_of_mondoarchive(void)
|
---|
[1] | 123 | {
|
---|
[1108] | 124 | mr_msg(2, "Restarting magicdev if necessary");
|
---|
[128] | 125 | sync();
|
---|
| 126 | restart_magicdev_if_necessary(); // for RH+Gnome users
|
---|
[1] | 127 |
|
---|
[1108] | 128 | mr_msg(2, "Restarting supermounts if necessary");
|
---|
[128] | 129 | sync();
|
---|
| 130 | remount_supermounts_if_necessary(); // for Mandrake users
|
---|
[1] | 131 |
|
---|
[1108] | 132 | mr_msg(2, "Unmounting /boot if necessary");
|
---|
[128] | 133 | sync();
|
---|
| 134 | unmount_boot_if_necessary(); // for Gentoo users
|
---|
[1] | 135 | }
|
---|
| 136 |
|
---|
| 137 | /*-----------------------------------------------------------*/
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | /**
|
---|
| 142 | * Backup/verify the user's data.
|
---|
| 143 | * What did you think it did, anyway? :-)
|
---|
| 144 | */
|
---|
[128] | 145 | int main(int argc, char *argv[])
|
---|
[1] | 146 | {
|
---|
[128] | 147 | struct s_bkpinfo *bkpinfo;
|
---|
[1100] | 148 | struct stat stbuf;
|
---|
[1152] | 149 | char *tmp = NULL;
|
---|
[1187] | 150 | int res = 0;
|
---|
| 151 | int retval = 0;
|
---|
| 152 | char *say_at_end = NULL;
|
---|
[1190] | 153 | char *say_at_end2 = NULL;
|
---|
[1] | 154 |
|
---|
[1187] | 155 | #ifdef ENABLE_NLS
|
---|
| 156 | setlocale(LC_ALL, "");
|
---|
| 157 | (void) textdomain("mondo");
|
---|
| 158 | #endif
|
---|
[1] | 159 | /* Make sure I'm root; abort if not */
|
---|
[128] | 160 | if (getuid() != 0) {
|
---|
[1187] | 161 | fprintf(stderr, _("Please run as root.\n"));
|
---|
[128] | 162 | exit(127);
|
---|
| 163 | }
|
---|
[1] | 164 |
|
---|
[1187] | 165 | /* If -V, -v or --version then echo version no. and quit */
|
---|
[128] | 166 | if (argc == 2
|
---|
| 167 | && (!strcmp(argv[argc - 1], "-v") || !strcmp(argv[argc - 1], "-V")
|
---|
| 168 | || !strcmp(argv[argc - 1], "--version"))) {
|
---|
[1187] | 169 | printf(_("mondoarchive v%s\nSee man page for help\n"), PACKAGE_VERSION);
|
---|
[128] | 170 | exit(0);
|
---|
| 171 | }
|
---|
[1] | 172 |
|
---|
[1187] | 173 | /* Initialize variables */
|
---|
[128] | 174 | malloc_libmondo_global_strings();
|
---|
[1] | 175 |
|
---|
[128] | 176 | res = 0;
|
---|
| 177 | retval = 0;
|
---|
| 178 | diffs = 0;
|
---|
[1187] | 179 | printf(_("Initializing...\n"));
|
---|
[1] | 180 |
|
---|
[810] | 181 | /* initialize log file with time stamp */
|
---|
| 182 | unlink(MONDO_LOGFILE);
|
---|
[1132] | 183 | mr_msg_init(MONDO_LOGFILE,4);
|
---|
[1108] | 184 | mr_msg(0, "Time started: %s", mr_date());
|
---|
[1] | 185 |
|
---|
[1132] | 186 | bkpinfo = mr_malloc(sizeof(struct s_bkpinfo));
|
---|
| 187 |
|
---|
[807] | 188 | /* Add the ARCH environment variable for ia64 purposes */
|
---|
[1152] | 189 | setenv("ARCH", get_architecture(), 1);
|
---|
[1] | 190 |
|
---|
[1228] | 191 | /* Add MONDO_SHARE + other environment variables for mindi */
|
---|
[1152] | 192 | setenv_mondo_var();
|
---|
[258] | 193 |
|
---|
[1100] | 194 | if (stat(MONDO_CACHE, &stbuf) != 0) {
|
---|
| 195 | mr_mkdir(MONDO_CACHE,0x755);
|
---|
| 196 | }
|
---|
| 197 |
|
---|
[1140] | 198 | /* BERLIOS: Hardcoded to be improved */
|
---|
| 199 | unlink(MONDO_CACHE"/mindi.conf");
|
---|
[1143] | 200 | unlink(MONDORESTORECFG);
|
---|
[1140] | 201 |
|
---|
[807] | 202 | /* Configure the bkpinfo structure, global file paths, etc. */
|
---|
[128] | 203 | g_main_pid = getpid();
|
---|
[1108] | 204 | mr_msg(9, "This");
|
---|
[1] | 205 |
|
---|
[128] | 206 | register_pid(g_main_pid, "mondo");
|
---|
| 207 | set_signals(TRUE); // catch SIGTERM, etc.
|
---|
| 208 | run_program_and_log_output("dmesg -n1", TRUE);
|
---|
[1] | 209 |
|
---|
[1108] | 210 | mr_msg(9, "Next");
|
---|
[128] | 211 | welcome_to_mondoarchive();
|
---|
| 212 | distro_specific_kludges_at_start_of_mondoarchive();
|
---|
| 213 | g_kernel_version = get_kernel_version();
|
---|
[1] | 214 |
|
---|
[128] | 215 | if (argc == 4 && !strcmp(argv[1], "getfattr")) {
|
---|
| 216 | g_loglevel = 10;
|
---|
| 217 | g_text_mode = TRUE;
|
---|
| 218 | setup_newt_stuff();
|
---|
| 219 | if (!strstr(argv[2], "filelist")) {
|
---|
[1187] | 220 | mr_msg(1,_("Sorry - filelist goes first\n"));
|
---|
[128] | 221 | finish(1);
|
---|
| 222 | } else {
|
---|
| 223 | finish(get_fattr_list(argv[2], argv[3]));
|
---|
| 224 | }
|
---|
| 225 | finish(0);
|
---|
[1] | 226 | }
|
---|
[128] | 227 | if (argc == 4 && !strcmp(argv[1], "setfattr")) {
|
---|
| 228 | g_loglevel = 10;
|
---|
| 229 | g_text_mode = TRUE;
|
---|
| 230 | setup_newt_stuff();
|
---|
| 231 | finish(set_fattr_list(argv[2], argv[3]));
|
---|
[1] | 232 | }
|
---|
[128] | 233 |
|
---|
| 234 | if (argc == 3 && !strcmp(argv[1], "wildcards")) {
|
---|
| 235 | g_loglevel = 10;
|
---|
| 236 | g_text_mode = TRUE;
|
---|
| 237 | setup_newt_stuff();
|
---|
[1152] | 238 | malloc_string(tmp);
|
---|
[128] | 239 | turn_wildcard_chars_into_literal_chars(tmp, argv[2]);
|
---|
| 240 | printf("in=%s; out=%s\n", argv[2], tmp);
|
---|
[1152] | 241 | mr_free(tmp);
|
---|
[128] | 242 | finish(1);
|
---|
[1] | 243 | }
|
---|
[128] | 244 |
|
---|
| 245 | if (argc == 4 && !strcmp(argv[1], "getfacl")) {
|
---|
| 246 | g_loglevel = 10;
|
---|
| 247 | g_text_mode = TRUE;
|
---|
| 248 | setup_newt_stuff();
|
---|
| 249 | if (!strstr(argv[2], "filelist")) {
|
---|
[1187] | 250 | mr_msg(1,_("Sorry - filelist goes first\n"));
|
---|
[128] | 251 | finish(1);
|
---|
| 252 | } else {
|
---|
| 253 | finish(get_acl_list(argv[2], argv[3]));
|
---|
| 254 | }
|
---|
| 255 | finish(0);
|
---|
| 256 | }
|
---|
| 257 | if (argc == 4 && !strcmp(argv[1], "setfacl")) {
|
---|
| 258 | g_loglevel = 10;
|
---|
| 259 | g_text_mode = TRUE;
|
---|
| 260 | setup_newt_stuff();
|
---|
| 261 | finish(set_acl_list(argv[2], argv[3]));
|
---|
| 262 | }
|
---|
[1] | 263 |
|
---|
[128] | 264 | if (argc > 2 && !strcmp(argv[1], "find-cd")) {
|
---|
| 265 | g_loglevel = 10;
|
---|
| 266 | g_text_mode = TRUE;
|
---|
| 267 | setup_newt_stuff();
|
---|
[1152] | 268 | malloc_string(tmp);
|
---|
[128] | 269 | if (find_cdrw_device(tmp)) {
|
---|
[1187] | 270 | mr_msg(1,_("Failed to find CDR-RW drive\n"));
|
---|
[128] | 271 | } else {
|
---|
[1187] | 272 | mr_msg(1,_("CD-RW is at %s\n"), tmp);
|
---|
[128] | 273 | }
|
---|
| 274 | tmp[0] = '\0';
|
---|
| 275 | if (find_cdrom_device(tmp, atoi(argv[2]))) {
|
---|
[1187] | 276 | mr_msg(1,_("Failed to find CD-ROM drive\n"));
|
---|
[128] | 277 | } else {
|
---|
[1187] | 278 | mr_msg(1,_("CD-ROM is at %s\n"), tmp);
|
---|
[128] | 279 | }
|
---|
[1152] | 280 | mr_free(tmp);
|
---|
[128] | 281 | finish(0);
|
---|
| 282 | }
|
---|
[1] | 283 |
|
---|
[128] | 284 | if (argc > 2 && !strcmp(argv[1], "find-dvd")) {
|
---|
| 285 | g_loglevel = 10;
|
---|
| 286 | g_text_mode = TRUE;
|
---|
| 287 | setup_newt_stuff();
|
---|
[1152] | 288 | malloc_string(tmp);
|
---|
[128] | 289 | if (find_dvd_device(tmp, atoi(argv[2]))) {
|
---|
[1187] | 290 | mr_msg(1,_("Failed to find DVD drive\n"));
|
---|
[128] | 291 | } else {
|
---|
[1187] | 292 | mr_msg(1,_("DVD is at %s\n"), tmp);
|
---|
[128] | 293 | }
|
---|
[1152] | 294 | mr_free(tmp);
|
---|
[128] | 295 | finish(0);
|
---|
| 296 | }
|
---|
[1] | 297 |
|
---|
[128] | 298 | if (argc > 2 && !strcmp(argv[1], "disksize")) {
|
---|
| 299 | printf("%s --> %ld\n", argv[2], get_phys_size_of_drive(argv[2]));
|
---|
| 300 | finish(0);
|
---|
| 301 | }
|
---|
| 302 | if (argc > 2 && !strcmp(argv[1], "test-dev")) {
|
---|
| 303 | if (is_dev_an_NTFS_dev(argv[2])) {
|
---|
[1187] | 304 | mr_msg(1,_("%s is indeed an NTFS dev\n"), argv[2]);
|
---|
[128] | 305 | } else {
|
---|
[1187] | 306 | mr_msg(1,_("%s is _not_ an NTFS dev\n"), argv[2]);
|
---|
[128] | 307 | }
|
---|
| 308 | finish(0);
|
---|
| 309 | }
|
---|
| 310 |
|
---|
| 311 | if (pre_param_configuration(bkpinfo)) {
|
---|
| 312 | fatal_error
|
---|
| 313 | ("Pre-param initialization phase failed. Please review the error messages above, make the specified changes, then try again. Exiting...");
|
---|
| 314 | }
|
---|
[1140] | 315 | sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
|
---|
| 316 | bkpinfo->scratchdir);
|
---|
[128] | 317 |
|
---|
[1140] | 318 | /* Process command line, if there is one. If not, ask user for info. */
|
---|
[128] | 319 | if (argc == 1) {
|
---|
| 320 | g_text_mode = FALSE;
|
---|
| 321 | setup_newt_stuff();
|
---|
| 322 | res = interactively_obtain_media_parameters_from_user(bkpinfo, TRUE); /* yes, archiving */
|
---|
| 323 | if (res) {
|
---|
| 324 | fatal_error
|
---|
| 325 | ("Syntax error. Please review the parameters you have supplied and try again.");
|
---|
| 326 | }
|
---|
| 327 | } else {
|
---|
| 328 | res = handle_incoming_parameters(argc, argv, bkpinfo);
|
---|
| 329 | if (res) {
|
---|
[1187] | 330 | mr_msg(1,
|
---|
| 331 | _("Errors were detected in the command line you supplied.\n"));
|
---|
| 332 | mr_msg(1,_("Please review the log file - %s \n"),MONDO_LOGFILE);
|
---|
[1108] | 333 | mr_msg(1, "Mondoarchive will now exit.");
|
---|
[128] | 334 | finish(1);
|
---|
| 335 | }
|
---|
| 336 | setup_newt_stuff();
|
---|
[1] | 337 | }
|
---|
| 338 |
|
---|
| 339 | /* Finish configuring global structures */
|
---|
[128] | 340 | if (post_param_configuration(bkpinfo)) {
|
---|
| 341 | fatal_error
|
---|
| 342 | ("Post-param initialization phase failed. Perhaps bad parameters were supplied to mondoarchive? Please review the documentation, error messages and logs. Exiting...");
|
---|
| 343 | }
|
---|
[1] | 344 |
|
---|
[128] | 345 | log_to_screen
|
---|
[1187] | 346 | (_("BusyBox's sources are available from http://www.busybox.net"));
|
---|
| 347 |
|
---|
[128] | 348 | sprintf(g_erase_tmpdir_and_scratchdir, "rm -Rf %s %s", bkpinfo->tmpdir,
|
---|
| 349 | bkpinfo->scratchdir);
|
---|
[1] | 350 |
|
---|
[128] | 351 | /* If we're meant to backup then backup */
|
---|
| 352 | if (bkpinfo->backup_data) {
|
---|
[541] | 353 | res = backup_data(bkpinfo);
|
---|
[128] | 354 | retval += res;
|
---|
| 355 | if (res) {
|
---|
[1187] | 356 | mr_strcat(say_at_end,
|
---|
| 357 | _("Data archived. Please check the logs, just as a precaution. "));
|
---|
[128] | 358 | } else {
|
---|
[1187] | 359 | mr_strcat(say_at_end, _("Data archived OK. "));
|
---|
[128] | 360 | }
|
---|
| 361 | }
|
---|
[1] | 362 |
|
---|
[1187] | 363 | /* If we're meant to verify then verify */
|
---|
[128] | 364 | if (bkpinfo->verify_data) {
|
---|
| 365 | res = verify_data(bkpinfo);
|
---|
| 366 | if (res < 0) {
|
---|
[1190] | 367 | mr_asprintf(&say_at_end2, _("%d difference%c found."), -res,
|
---|
[128] | 368 | (-res != 1) ? 's' : ' ');
|
---|
| 369 | res = 0;
|
---|
| 370 | }
|
---|
| 371 | retval += res;
|
---|
| 372 | }
|
---|
[1] | 373 |
|
---|
[1187] | 374 | /* Offer to write floppy disk images to physical disks */
|
---|
[128] | 375 | if (bkpinfo->backup_data && !g_skip_floppies) {
|
---|
| 376 | res = offer_to_write_boot_floppies_to_physical_disks(bkpinfo);
|
---|
| 377 | retval += res;
|
---|
| 378 | }
|
---|
[1] | 379 |
|
---|
[1187] | 380 | /* Report result of entire operation (success? errors?) */
|
---|
[128] | 381 | if (!retval) {
|
---|
| 382 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[1187] | 383 | _("Backup and/or verify ran to completion. Everything appears to be fine."));
|
---|
[128] | 384 | } else {
|
---|
| 385 | mvaddstr_and_log_it(g_currentY++, 0,
|
---|
[1187] | 386 | _("Backup and/or verify ran to completion. However, errors did occur."));
|
---|
[128] | 387 | }
|
---|
[1] | 388 |
|
---|
[1044] | 389 | if (does_file_exist("/var/cache/mindi/mondorescue.iso")) {
|
---|
[128] | 390 | log_to_screen
|
---|
[1187] | 391 | (_("/var/cache/mindi/mondorescue.iso, a boot/utility CD, is available if you want it."));
|
---|
[128] | 392 | }
|
---|
[1] | 393 |
|
---|
| 394 |
|
---|
[128] | 395 | if (length_of_file("/tmp/changed.files") > 2) {
|
---|
| 396 | if (g_text_mode) {
|
---|
| 397 | log_to_screen
|
---|
[1187] | 398 | (_("Type 'less /tmp/changed.files' to see which files don't match the archives"));
|
---|
[128] | 399 | } else {
|
---|
[1108] | 400 | mr_msg(1,
|
---|
[1187] | 401 | _("Type 'less /tmp/changed.files' to see which files don't match the archives"));
|
---|
[1108] | 402 | mr_msg(2, "Calling popup_changelist_from_file()");
|
---|
[128] | 403 | popup_changelist_from_file("/tmp/changed.files");
|
---|
[1108] | 404 | mr_msg(2, "Returned from popup_changelist_from_file()");
|
---|
[128] | 405 | }
|
---|
| 406 | } else {
|
---|
| 407 | unlink("/tmp/changed.files");
|
---|
| 408 | }
|
---|
| 409 | log_to_screen(say_at_end);
|
---|
[1187] | 410 | mr_free(say_at_end);
|
---|
[1190] | 411 | if (say_at_end2 != NULL) {
|
---|
| 412 | log_to_screen(say_at_end2);
|
---|
| 413 | mr_free(say_at_end2);
|
---|
| 414 | }
|
---|
[1187] | 415 |
|
---|
[1152] | 416 | mr_asprintf(&tmp, "umount %s/tmpfs", bkpinfo->tmpdir);
|
---|
[128] | 417 | run_program_and_log_output(tmp, TRUE);
|
---|
[1152] | 418 | mr_free(tmp);
|
---|
[128] | 419 | run_program_and_log_output(g_erase_tmpdir_and_scratchdir, TRUE);
|
---|
[1] | 420 |
|
---|
[128] | 421 | run_program_and_log_output("mount", 2);
|
---|
[1] | 422 |
|
---|
[128] | 423 | system("rm -f /var/cache/mondo-archive/last-backup.aborted");
|
---|
| 424 | system("rm -Rf /tmp.mondo.* /mondo.scratch.*");
|
---|
| 425 | if (!retval) {
|
---|
[1187] | 426 | printf(_("Mondoarchive ran OK.\n"));
|
---|
[128] | 427 | } else {
|
---|
[1187] | 428 | printf(_("Errors occurred during backup. Please check logfile.\n"));
|
---|
[128] | 429 | }
|
---|
| 430 | distro_specific_kludges_at_end_of_mondoarchive();
|
---|
| 431 | register_pid(0, "mondo");
|
---|
| 432 | set_signals(FALSE);
|
---|
| 433 | chdir("/tmp"); // just in case there's something wrong with g_erase_tmpdir_and_scratchdir
|
---|
| 434 | system(g_erase_tmpdir_and_scratchdir);
|
---|
| 435 | free_libmondo_global_strings();
|
---|
[1080] | 436 | mr_free(bkpinfo);
|
---|
[1] | 437 |
|
---|
[128] | 438 | unlink("/tmp/filelist.full");
|
---|
| 439 | unlink("/tmp/filelist.full.gz");
|
---|
[1] | 440 |
|
---|
[128] | 441 | if (!g_cdrom_drive_is_here) {
|
---|
[1108] | 442 | mr_msg(10, "FYI, g_cdrom_drive_is_here was never used");
|
---|
[128] | 443 | }
|
---|
| 444 | if (!g_dvd_drive_is_here) {
|
---|
[1108] | 445 | mr_msg(10, "FYI, g_dvd_drive_is_here was never used");
|
---|
[128] | 446 | }
|
---|
[1] | 447 |
|
---|
[810] | 448 | /* finalize log file with time stamp */
|
---|
[1187] | 449 | mr_msg(1, "Time finished: %s", mr_date());
|
---|
[1132] | 450 | mr_msg_close();
|
---|
[810] | 451 |
|
---|
[128] | 452 | if (!g_text_mode) {
|
---|
| 453 | popup_and_OK
|
---|
[1187] | 454 | (_("Mondo Archive has finished its run. Please press ENTER to return to the shell prompt."));
|
---|
| 455 | log_to_screen(_("See %s for details of backup run."), MONDO_LOGFILE);
|
---|
[128] | 456 | finish(retval);
|
---|
| 457 | } else {
|
---|
[1187] | 458 | printf(_("See %s for details of backup run.\n"), MONDO_LOGFILE);
|
---|
[128] | 459 | exit(retval);
|
---|
| 460 | }
|
---|
| 461 |
|
---|
| 462 | return EXIT_SUCCESS;
|
---|
[1] | 463 | }
|
---|