Changeset 1256 in MondoRescue for branches/stable/mondo/src/mondoarchive/mondoarchive.c
- Timestamp:
- Mar 21, 2007, 12:48:32 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/mondoarchive/mondoarchive.c
r1245 r1256 22 22 #include "mondo-cli-EXT.h" 23 23 24 #include "mondoarchive.h" 24 25 #include "mr_mem.h" 25 26 #include "mr_str.h" 26 27 #include "mr_msg.h" 27 28 #include "mr_file.h" 29 #include "mr_conf.h" 28 30 29 31 // for CVS … … 41 43 extern char *g_erase_tmpdir_and_scratchdir; 42 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 43 50 static char *g_cdrom_drive_is_here = NULL; 44 51 static char *g_dvd_drive_is_here = NULL; 45 extern double g_kernel_version; 46 47 /***************** global vars, used only by main.c ******************/ 52 53 struct mr_ar_conf mr_conf; 54 55 /***************** global vars ******************/ 48 56 bool g_skip_floppies; 49 57 long diffs; … … 51 59 char *ps_proc_id = "$2"; 52 60 53 extern t_bkptype g_backup_media_type; 54 extern int g_loglevel; 55 56 /****************** subroutines used only by main.c ******************/ 61 /****************** subroutines used only here ******************/ 57 62 58 63 … … 60 65 * Print a "don't panic" message to the log and a message about the logfile to the screen. 61 66 */ 62 void welcome_to_mondoarchive(void)67 static void welcome_to_mondoarchive(void) 63 68 { 64 mr_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org", 65 PACKAGE_VERSION); 69 mr_msg(0, "Mondo Archive v%s --- http://www.mondorescue.org", PACKAGE_VERSION); 66 70 mr_msg(0, "running on %s architecture", get_architecture()); 67 mr_msg(0, 68 "-----------------------------------------------------------"); 69 mr_msg(0, 70 "NB: Mondo logs almost everything, so don't panic if you see"); 71 mr_msg(0, 72 "some error messages. Please read them carefully before you"); 73 mr_msg(0, 74 "decide to break out in a cold sweat. Despite (or perhaps"); 75 mr_msg(0, 76 "because of) the wealth of messages. some users are inclined"); 77 mr_msg(0, 78 "to stop reading this log. If Mondo stopped for some reason,"); 79 mr_msg(0, 80 "chances are it's detailed here. More than likely there's a"); 81 mr_msg(0, 82 "message at the very end of this log that will tell you what"); 83 mr_msg(0, 84 "is wrong. Please read it! -Devteam"); 85 mr_msg(0, 86 "-----------------------------------------------------------"); 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, "-----------------------------------------------------------"); 87 81 88 82 mr_msg(0, "Zero..."); … … 98 92 } 99 93 100 101 extern char *g_magicdev_command;102 103 94 /** 104 95 * Do whatever is necessary to insure a successful backup on the Linux distribution 105 96 * of the day. 106 97 */ 107 void distro_specific_kludges_at_start_of_mondoarchive(void)98 static void distro_specific_kludges_at_start_of_mondoarchive(void) 108 99 { 109 100 mr_msg(2, "Unmounting old ramdisks if necessary"); … … 120 111 * Undo whatever was done by distro_specific_kludges_at_start_of_mondoarchive(). 121 112 */ 122 void distro_specific_kludges_at_end_of_mondoarchive(void)113 static void distro_specific_kludges_at_end_of_mondoarchive(void) 123 114 { 124 115 mr_msg(2, "Restarting magicdev if necessary"); … … 133 124 sync(); 134 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")); 135 160 } 136 161 … … 145 170 int main(int argc, char *argv[]) 146 171 { 147 struct s_bkpinfo *bkpinfo ;172 struct s_bkpinfo *bkpinfo = NULL; 148 173 struct stat stbuf; 149 174 char *tmp = NULL; … … 157 182 (void) textdomain("mondo"); 158 183 #endif 159 /* Make sure I'm root; abort if not */ 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 */ 160 194 if (getuid() != 0) { 161 fprintf(stderr, _("Please run as root.\n")); 162 exit(127); 195 mr_log_exit(127, _("Please run as root.")); 163 196 } 164 197 … … 168 201 || !strcmp(argv[argc - 1], "--version"))) { 169 202 printf(_("mondoarchive v%s\nSee man page for help\n"), PACKAGE_VERSION); 170 exit(0); 171 } 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(); 172 217 173 218 /* Initialize variables */ 174 219 malloc_libmondo_global_strings(); 175 176 res = 0;177 retval = 0;178 220 diffs = 0; 179 180 /* initialize log file with time stamp */181 unlink(MONDO_LOGFILE);182 mr_msg_init(MONDO_LOGFILE,4);183 mr_msg(0, _("Initializing...\n"));184 mr_msg(0, _("Time started: %s"), mr_date());185 186 221 bkpinfo = mr_malloc(sizeof(struct s_bkpinfo)); 187 188 /* Add the ARCH environment variable for ia64 purposes */189 setenv("ARCH", get_architecture(), 1);190 191 /* Add MONDO_SHARE + other environment variables for mindi */192 setenv_mondo_var();193 194 222 if (stat(MONDO_CACHE, &stbuf) != 0) { 195 223 mr_mkdir(MONDO_CACHE,0x755);
Note:
See TracChangeset
for help on using the changeset viewer.