Changeset 127 in MondoRescue for trunk/mondo/mondo/common/libmondo-tools.c
- Timestamp:
- Nov 19, 2005, 2:27:31 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/common/libmondo-tools.c
r94 r127 168 168 169 169 asprintf(&tmp, 170 170 "for i in `find /root /home -type d -name Desktop -maxdepth 2`; do \ 171 171 file=$i/.directory; if [ -f \"$file\" ] ; then mv -f $file $file.old ; \ 172 172 cat $file.old | awk '{if (index($0, \"rootimagesmindi\")) { while (length($0)>2) { getline;} ; } \ … … 189 189 190 190 asprintf(&home_sz, 191 192 191 call_program_and_get_last_line_of_output 192 ("find /usr/lib/ /usr/local/ /usr/share/ /usr/local/share/ /opt/ /ramdisk/usr/share/ -type d -maxdepth 2 -name include -prune -o -type d -maxdepth 2 -path '*/mondo/restore-scripts' -printf '%h\n' 2> /dev/null")); 193 193 194 194 if (home_sz[0] == '\0') { 195 195 paranoid_free(home_sz); 196 196 asprintf(&home_sz, 197 198 197 call_program_and_get_last_line_of_output 198 ("find /usr -type d -path '*/mondo/restore-scripts' -follow -maxdepth 3 -printf '%h\n' 2> /dev/null")); 199 199 } 200 200 if (home_sz[0] == '\0') { … … 402 402 #ifdef __FreeBSD__ 403 403 asprintf(&tmp, 404 405 404 call_program_and_get_last_line_of_output 405 ("vmstat | tail -1 | tr -s ' ' | cut -d' ' -f6")); 406 406 avm += atol(tmp); 407 407 paranoid_free(tmp); 408 408 asprintf(&tmp, 409 410 409 call_program_and_get_last_line_of_output 410 ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc")); 411 411 avm += atol(tmp); 412 412 paranoid_free(tmp); 413 413 asprintf(&command, "mdmfs -s %d%c md9 %s", rdsiz_MB, 'm', 414 g_tmpfs_mountpt);414 g_tmpfs_mountpt); 415 415 #else 416 416 asprintf(&tmp, 417 418 417 call_program_and_get_last_line_of_output 418 ("free | grep \":\" | tr -s ' ' '\t' | cut -f2 | head -n1")); 419 419 avm += atol(tmp); 420 420 paranoid_free(tmp); 421 421 asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c", 422 g_tmpfs_mountpt, rdsiz_MB, 'm');422 g_tmpfs_mountpt, rdsiz_MB, 'm'); 423 423 run_program_and_log_output("cat /proc/cpuinfo", 5); 424 424 /* BERLIOS: rpm is not necessarily there ! */ … … 453 453 454 454 if (bkpinfo->backup_media_type == dvd) { 455 if (! 455 if (!(find_home_of_exe("growisofs"))) { 456 456 fatal_error("Please install growisofs."); 457 457 } … … 483 483 sprintf(bkpinfo->call_make_iso, 484 484 "%s %s -Z %s . 2>> _ERR_", 485 mondo_mkisofs_sz, 486 "", bkpinfo->media_device); 485 mondo_mkisofs_sz, "", bkpinfo->media_device); 487 486 } 488 487 paranoid_free(mondo_mkisofs_sz); … … 572 571 log_it("isodir = %s", bkpinfo->isodir); 573 572 asprintf(&command, "df %s | tail -n1 | cut -d' ' -f1", 574 bkpinfo->isodir);573 bkpinfo->isodir); 575 574 log_it("command = %s", command); 576 575 asprintf(&tmp, call_program_and_get_last_line_of_output(command)); … … 582 581 583 582 asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3", 584 tmp);583 tmp); 585 584 paranoid_free(tmp); 586 585 log_it("command = %s", command); … … 595 594 log_it("isomnt: %s, %d", tmp, strlen(tmp)); 596 595 if (strlen(bkpinfo->isodir) < strlen(tmp)) { 597 asprintf(&iso_path, "");596 asprintf(&iso_path, ""); 598 597 } else { 599 598 asprintf(&iso_path, "%s", bkpinfo->isodir + strlen(tmp)); … … 627 626 } else { 628 627 asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr) 629 *((struct in_addr *) hent-> 630 h_addr)), strchr(bkpinfo->nfs_mount, ':')); 628 *((struct in_addr 629 *) hent-> 630 h_addr)), 631 strchr(bkpinfo->nfs_mount, ':')); 631 632 strcpy(bkpinfo->nfs_mount, ip_address); 632 633 paranoid_free(ip_address); … … 789 790 790 791 asprintf(&command, "df -m %s | tail -n1 | tr -s ' ' '\t' | cut -f4", 791 partition);792 partition); 792 793 asprintf(&out_sz, call_program_and_get_last_line_of_output(command)); 793 794 paranoid_free(command); … … 836 837 } 837 838 asprintf(&tmp, 838 839 839 call_program_and_get_last_line_of_output 840 ("free | grep Mem | head -n1 | tr -s ' ' '\t' | cut -f2")); 840 841 if (atol(tmp) < 35000) { 841 842 retval++; … … 926 927 ("umount `mount | grep cdr | cut -d' ' -f3 | tr '\n' ' '`", 5); 927 928 asprintf(&tmp, 928 929 929 call_program_and_get_last_line_of_output 930 ("mount | grep -E \"cdr(om|w)\"")); 930 931 if (strcmp("", tmp)) { 931 932 if (strstr(tmp, "autofs")) { … … 1027 1028 if (!does_file_exist(config_file)) { 1028 1029 asprintf(&tmp, "(read_cfg_var) Cannot find %s config file", 1029 config_file);1030 config_file); 1030 1031 log_to_screen(tmp); 1031 1032 paranoid_free(tmp); … … 1039 1040 } else { 1040 1041 asprintf(&command, "cat %s | grep \"%s .*\" | cut -d' ' -f2,3,4,5", 1041 config_file, label);1042 config_file, label); 1042 1043 strcpy(value, call_program_and_get_last_line_of_output(command)); 1043 1044 paranoid_free(command); … … 1150 1151 log_it("Started autofs OK"); 1151 1152 } 1152 1153 paranoid_free(tmp); 1153 1154 } 1154 1155 … … 1168 1169 log_msg(4, "Done. Great. Seeting command to something"); 1169 1170 asprintf(&command, 1170 1171 "cat /etc/fstab | grep -v \":\" | grep -vx \"#.*\" | grep -w \"/boot\" | tr -s ' ' '\t' | cut -f1 | head -n1"); 1171 1172 log_msg(4, "Cool. Command = '%s'", command); 1172 1173 asprintf(&tmp, call_program_and_get_last_line_of_output(command)); … … 1191 1192 asprintf(&g_boot_mountpt, tmp); 1192 1193 asprintf(&tmp1, 1193 "%s (your /boot partition) is not mounted. I'll mount it before backing up",1194 g_boot_mountpt);1194 "%s (your /boot partition) is not mounted. I'll mount it before backing up", 1195 g_boot_mountpt); 1195 1196 log_it(tmp1); 1196 1197 paranoid_free(tmp1); … … 1263 1264 if (!does_file_exist(config_file)) { 1264 1265 asprintf(&tmp, "(write_cfg_file) Cannot find %s config file", 1265 config_file);1266 config_file); 1266 1267 log_to_screen(tmp); 1267 1268 paranoid_free(tmp); … … 1269 1270 } 1270 1271 asprintf(&tempfile, 1271 1272 1272 call_program_and_get_last_line_of_output 1273 ("mktemp -q /tmp/mojo-jojo.blah.XXXXXX")); 1273 1274 if (does_file_exist(config_file)) { 1274 1275 asprintf(&command, "cat %s | grep -vx \"%s .*\" > %s", config_file, 1275 label, tempfile);1276 label, tempfile); 1276 1277 paranoid_system(command); 1277 1278 paranoid_free(command);
Note:
See TracChangeset
for help on using the changeset viewer.