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