Changeset 1904 in MondoRescue
- Timestamp:
- Apr 10, 2008, 1:20:42 AM (16 years ago)
- Location:
- branches/stable
- Files:
-
- 2 deleted
- 8 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mindi/deplist.txt
r1842 r1904 15 15 fstab raidtab modules.conf conf.modules mondorestore modules.conf.local 16 16 /etc/mdadm/mdadm.conf /etc/mdadm.conf 17 /sbin/ldconfig 17 18 afio star ntfsclone parted ms-sys file getfattr setfattr getfacl setfacl 18 19 buffer … … 44 45 45 46 # For Debug mode 46 # gdb 47 # gdb valgrind /usr/lib/valgrind 47 48 48 49 #----------------- For all you LVM users out there, much love ----------------- -
branches/stable/mindi/mindi
r1903 r1904 147 147 148 148 149 AddFileToDir() {150 local filename minidir_root noof_disks diskno res filesize would_occupy zipsize complevel cutoff compressed_fname siz151 filename=$1152 minidir_root=$2153 noof_disks=$3154 155 diskno=$noof_disks156 mkdir -p $minidir_root/$diskno157 [ "$LAST_COMPRESSED_SIZE" = "" ] && LAST_COMPRESSED_SIZE=0158 if [ ! -e "$filename" ] ; then159 if [ -h "$filename" ] ; then160 cp --parents -pRdf $filename $minidir_root/$diskno 2>> $LOGFILE161 return $noof_disks162 else163 Die "AddFileToDir asked me to add $filename, which does not exist. Oops! Did you run out of disk space or is your Linux distro severely broken?"164 fi165 fi166 167 # move to the disk that has room on it (or end up using the last, if all full)168 while [ "$diskno" -lt $MAX_DISKS ] ; do169 mkdir -p $minidir_root/$diskno170 filesize=`du -sk $filename | cut -f1`171 cp --parents -Rdf $filename $minidir_root/$diskno 2>> $LOGFILE172 if [ "$filesize" -le "4" ] ; then173 siz=$filesize174 elif [ ! -f "$filename" ] ; then175 siz=0176 else177 siz=`grep -m 1 "$filename.gz$" $minidir_root/compressed/compressed.txt | cut -f1`178 [ "$siz" = "" ] && Die "FIXME - can't find $filename's size."179 siz=$(($siz-2));# to allow for sectors & the fact that they round up180 fi181 [ ! "$siz" ] && siz=4182 [ "$siz" -lt "0" ] && siz=0183 LAST_COMPRESSED_SIZE=$(($LAST_COMPRESSED_SIZE+$siz))184 [ "$LAST_COMPRESSED_SIZE" -le "$MAX_COMPRESSED_SIZE" ] &&return $diskno185 echo "disk=$diskno siz=$LAST_COMPRESSED_SIZE" >> $LOGFILE186 LAST_COMPRESSED_SIZE=0187 rm -f $minidir_root/$diskno/$filename188 diskno=$(($diskno+1))189 done190 return 0 ; # failed191 }192 193 194 149 AddKeyboardMappingFile() { 195 150 local mappath r included_list included_item i res ii sss … … 380 335 done 381 336 echo $r 382 }383 384 385 CreateDataDiskImagesFromTarballs() {386 local tardir outdir diskno noof_disks kp387 tardir=$1388 outdir=$2389 noof_disks=$3390 391 mkdir -p $outdir392 diskno=1393 echo -en "Creating data disk "394 while [ "$diskno" -le "$noof_disks" ] ; do395 echo -en "#$diskno..."396 cp -f $tardir/$diskno.tar.gz $outdir 2>> $LOGFILE || LogIt "[line 424] Cannot copy $tardir/$diskno.tar.gz to $outdir"397 CreateOneDataDiskImage $tardir/$diskno.tar.gz $outdir/mindi-data-$diskno.img $diskno $noof_disks398 diskno=$(($diskno+1))399 done400 mv -f $tardir/all.tar.gz $outdir401 du -sk $outdir/*gz >> $LOGFILE402 echo -e "$DONE"403 }404 405 406 407 CreateOneDataDiskImage() {408 local tarball imagefile dev diskno noof_disks mountpoint409 tarball=$1410 imagefile=$2411 diskno=$3412 noof_disks=$4413 414 mountpoint=$MINDI_TMP/mountpoint.$$415 mkdir -p $mountpoint416 dd if=/dev/zero of=$imagefile bs=1k count=1440 &> /dev/null || LogIt "Cannot dd (CODI)"417 echo "Creating ext2 filesystem on $imagefile" >> $LOGFILE418 mke2fs -N 12 -F $imagefile >> $LOGFILE 2>> $LOGFILE || Die "Unable to create an ext2 file system on $imagefile"419 mount -t ext2 -o loop $imagefile $mountpoint || Die "Can't loopmount $imagefile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel."420 mv $tarball $mountpoint/421 if [ "$?" -ne "0" ] ; then422 umount $mountpoint423 rmdir $mountpoint424 Die "Tarball $tarball is too big for disk! (CODI)\nAdjust mindi_max_compressed_size in your $MINDI_CONFIG"425 fi426 [ "$diskno" -eq "$noof_disks" ] && echo "This is the last disk ($diskno=$noof_disks)" >> $mountpoint/LAST-DISK427 umount $mountpoint || LogIt "Cannot umount (CODI)"428 rmdir $mountpoint || LogIt "Cannot rmdir (CODI)"429 337 } 430 338 … … 1563 1471 1564 1472 1565 MoveHyperlinkSensibly() {1566 local filename minidir_root resides_on_diskno noof_disks old_diskno d old_pwd1567 filename=$11568 minidir_root=$21569 resides_on_diskno=$31570 noof_disks=$41571 1572 [ -h "$minidir_root/$resides_on_diskno/$filename" ] || Die "$filename isn't a softlink (or doesn't exist): how can I move it sensibly?"1573 1574 old_diskno=$resides_on_diskno1575 d=11576 while [ "$d" -le "$noof_disks" ] ; do1577 if [ "$d" -ne "$old_diskno" ] ; then1578 old_pwd=`pwd`1579 cd $minidir_root/$old_diskno1580 cp --parents -Rdf $filename $minidir_root/$d/ 2>> $LOGFILE || Die "Can't move $filename (sensibly) from $old_diskno to $d"1581 rm -f $filename1582 cd $old_pwd1583 fi1584 # when the softlink is resolvable, our work here is done1585 [ -e "$minidir_root/$d/$filename" ] && return 01586 old_diskno=$d1587 d=$(($d+1))1588 done1589 return 11590 }1591 1592 1593 1473 OfferToMakeBootableISO() { 1594 1474 local i old_pwd … … 1784 1664 fi 1785 1665 echo -en "." 1786 }1787 1788 1789 PluralOrNot() {1790 [ "$1" -gt "1" ] && echo -en "s"1791 1666 } 1792 1667 … … 2127 2002 2128 2003 PrepareDataDiskImages() { 2129 local needlist bigdir minidir_root tardirdiskdir imagesdir res i j k old_pwd lines lfiles2004 local needlist bigdir diskdir imagesdir res i j k old_pwd lines lfiles 2130 2005 2131 2006 imagesdir=$1 2132 rm -f $imagesdir/mindi -*.img $imagesdir/[0-9]*.tar.gz $imagesdir/mindi.iso2007 rm -f $imagesdir/mindi.iso 2133 2008 needlist=$MINDI_TMP/what-we-need.txt 2134 2009 bigdir=$MINDI_TMP/bigdir 2135 minidir_root=$MINDI_TMP/minidir2136 mkdir -p $minidir_root2137 2010 mkdir -p $bigdir/usr/bin 2138 tardir=$MINDI_TMP/tardir2139 2011 2140 2012 if [ -e "$DEPLIST_FILE" ]; then … … 2176 2048 fi 2177 2049 if [ "$res" -ne "0" ] ; then 2178 Die "You have $res file `PluralOrNot $res`present in dependency list\nbut absent from filesystem."2050 Die "You have $res files present in dependency list\nbut absent from filesystem." 2179 2051 fi 2180 2052 FindAndAddUserKeyboardMappingFile … … 2227 2099 echo -e "$DONE" 2228 2100 TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1` 2229 SplitDirectoryIntoMinidirs $bigdir $minidir_root2230 noof_disks=$?2231 [ "$noof_disks" -eq "0" ] && Die "Too much stuff!"2232 2101 MakeMountlist $MINDI_TMP/mountlist.txt 2233 mkdir -p $ minidir_root/$noof_disks/tmp2234 cp -f $MINDI_TMP/mountlist.txt $ minidir_root/$noof_disks/tmp/mountlist.txt 2> /dev/null || Die "Cannot copy mountlist.txt from $MINDI_TMP to data disk"2102 mkdir -p $bigdir/tmp 2103 cp -f $MINDI_TMP/mountlist.txt $bigdir/tmp/mountlist.txt 2> /dev/null || Die "Cannot copy mountlist.txt from $MINDI_TMP to data disk" 2235 2104 if [ _"$MONDO_SHARE" != _"" ]; then 2236 cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MINDI_TMP/. 2>> $LOGFILE 2237 fi 2238 [ $LVM != "false" ] && $MINDI_LIB/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm || LVM="false" 2239 cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE 2240 ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks 2241 CreateDataDiskImagesFromTarballs $tardir $imagesdir $noof_disks 2105 cp -f $bigdir/tmp/mountlist.txt $MINDI_TMP/. 2>> $LOGFILE 2106 fi 2107 [ $LVM != "false" ] && $MINDI_LIB/analyze-my-lvm > $bigdir/tmp/i-want-my-lvm || LVM="false" 2108 cat $bigdir/tmp/mountlist.txt >> $LOGFILE 2109 echo -en "$FILES_IN_FILELIST" > $bigdir/FILES-IN-FILELIST 2> /dev/null 2110 echo -en "$LAST_FILELIST_NUMBER" > $bigdir/LAST-FILELIST-NUMBER 2> /dev/null 2111 if [ _"$MONDO_SHARE" != _"" ]; then 2112 for q in filelist.full.gz biggielist.txt ; do 2113 [ ! -e "$MINDI_TMP/$q" ] && Die "Cannot find $MINDI_TMP/$q" 2114 cp -pRdf $MINDI_TMP/$q $bigdir/tmp 2>> $LOGFILE 2115 done 2116 fi 2117 2118 echo -en "Tarring and zipping the data content..." 2119 size_of_all_tools=`du -sk $bigdir | cut -f1` 2120 (cd $bigdir ; tar -b 4096 -cf - . 2> /dev/null | gzip -9 > $imagesdir/all.tar.gz) 2121 du -sk $imagesdir/*gz >> $LOGFILE 2122 echo -e "$DONE" 2123 2242 2124 FRIENDLY_OUTSTRING="Boot and data disk images were created." 2243 # One 1.72MB boot disk, one 2.88MB boot disk and $noof_disks data disk images 2244 rmdir $tardir $bigdir 2125 rm -rf $bigdir 2245 2126 rm -f $needlist 2246 return $noof_disks2247 2127 } 2248 2128 … … 2296 2176 2297 2177 2298 RejigHyperlinks() {2299 local minidir_root noof_disks fname path diskno old_pwd awk_loc gawk_loc dir i2300 minidir_root=$12301 noof_disks=$22302 2303 old_pwd=`pwd`2304 diskno=12305 while [ "$diskno" -le "$noof_disks" ] ; do2306 mkdir -p $minidir_root/$diskno2307 cd $minidir_root/$diskno2308 for fname in `find -type d -o -print` ; do2309 [ -h "$minidir_root/$diskno/$fname" ] && MoveHyperlinkSensibly $fname $minidir_root $diskno $noof_disks2310 done2311 diskno=$(($diskno+1))2312 done2313 2314 cd $old_pwd2315 return2316 }2317 2318 2319 2178 ReplaceIndividualLine() { 2320 2179 local orig_file new_file lino newstring lines_total lines_remaining … … 2403 2262 2404 2263 2405 SplitDirectoryIntoMinidirs() {2406 local bigdir minidir_root i noof_disks old_pwd res2407 2408 bigdir=$12409 minidir_root=$22410 [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*2411 2412 TryToFitDataIntoSeveralDirs $bigdir $minidir_root2413 noof_disks=$?2414 if [ "$noof_disks" -eq "0" ] ; then2415 echo "Failed to fit data into several dirs."2416 return 02417 fi2418 RejigHyperlinks $minidir_root $noof_disks2419 [ "$bigdir" != "" ] && rm -Rf $bigdir/*2420 return $noof_disks2421 }2422 2423 2264 2424 2265 StripExecutable() … … 2435 2276 fi 2436 2277 rm -f $tmpfile 2437 }2438 2439 2440 TemporarilyCompressAllFiles() {2441 local i orig_fname out_fname out_list2442 2443 i=02444 out_list=$2/compressed/compressed.txt2445 mkdir -p $2/compressed2446 > $out_list2447 for orig_fname in $1 ; do2448 out_fname=$2/compressed/$orig_fname.gz2449 mkdir -p $out_fname 2> /dev/null2450 rmdir $out_fname 2> /dev/null2451 gzip -c6 $orig_fname > $out_fname 2> /dev/null2452 i=$(((($i+1))%15))2453 [ "$i" -eq "0" ] && echo -en "."2454 du -sk $out_fname >> $out_list2455 done2456 2278 } 2457 2279 … … 2551 2373 fi 2552 2374 echo "$output" | tr -s ' ' '\n' | sort -u | tr '\n' ' ' 2553 }2554 2555 2556 TryToFitDataIntoSeveralDirs() {2557 local bigdir minidir_root noof_disks diskno list_of_files filename old_pwd progress2558 local i retval noof_disks total_files list_of_devs2559 2560 bigdir=$12561 minidir_root=$22562 BIG_CLUNKY_SIZE_COUNTER=02563 retval=02564 noof_disks=12565 2566 echo -en "\r \rDividing data into several groups..."2567 old_pwd=`pwd`2568 cd $bigdir2569 list_of_files=`GetFileSizeList . | sort -nr | cut -f2 | grep -Fv "/dev/"`2570 progress=02571 total_files=`CountItemsIn "$list_of_files"`2572 if [ "`echo "$filename" | grep -x "/dev/.*"`" ] ; then2573 filesize=12574 fi2575 mkdir -p $minidir_root/$noof_disks2576 if [ -e "dev" ] ; then2577 echo "Copying dev/* to $minidir_root/$noof_disks" >> $LOGFILE2578 cp --parents -pRdf dev $minidir_root/$noof_disks 2>> $LOGFILE2579 fi2580 TemporarilyCompressAllFiles "$list_of_files" $minidir_root2581 for filename in $list_of_files ; do2582 AddFileToDir $filename $minidir_root $noof_disks2583 i=$?2584 if [ "$i" -gt "$noof_disks" ] ; then2585 noof_disks=$i2586 echo -en "\r\t\t\t\t\t\t($noof_disks disks)"2587 fi2588 if [ "$i" -eq "0" ] ; then2589 LogIt "Cannot add file $filename to minidir $minidir_root"2590 retval=$(($retval+1))2591 fi2592 progress=$(($progress+1))2593 echo -en "\r\t\t\t\t\t\t\t\t$(($progress*100/$total_files))% complete\r"2594 done2595 cd $old_pwd2596 echo -en "\rThe files have been subdivided into $noof_disks directories. \r"2597 [ "$minidir_root" != "" ] && rm -Rf $minidir_root/compressed2598 if [ "$retval" -gt "0" ] ; then2599 return 02600 else2601 return $noof_disks2602 fi2603 2375 } 2604 2376 … … 2863 2635 2864 2636 2865 ZipMinidirsIntoTarballs() {2866 local minidir_root tardir noof_disks diskno old_pwd i2867 minidir_root=$12868 tardir=$22869 noof_disks=$32870 2871 echo -en "Tarring and zipping the group`PluralOrNot $noof_disks`..."2872 mkdir -p $tardir2873 mkdir -p $minidir_root/all2874 old_pwd=`pwd`2875 diskno=12876 while [ "$diskno" -le "$noof_disks" ] ; do2877 cd $minidir_root/$diskno || LogIt "WARNING - cannot cd to $minidir_root/$diskno"2878 tar -cf - . 2>> $LOGFILE | gzip -9 > $tardir/$diskno.tar.gz || Die "Can't tar/gzip disk#$diskno; please tell Dev Team -exactly- what the errors where."2879 diskno=$(($diskno+1))2880 echo -n "..."2881 cp -pRdf * $minidir_root/all 2>> $LOGFILE2882 done2883 mkdir -p $minidir_root/all/tmp2884 cd $minidir_root/all2885 size_of_all_tools=`du -sk . | cut -f1`2886 if [ _"$MONDO_SHARE" != _"" ]; then2887 for q in filelist.full.gz biggielist.txt ; do2888 [ ! -e "$MINDI_TMP/$q" ] && Die "Cannot find $MINDI_TMP/$q"2889 cp -pRdf $MINDI_TMP/$q tmp/ 2>> $LOGFILE2890 done2891 mkdir -p $minidir_root/all/tmp2892 fi2893 tar -b 4096 -cf - * 2> /dev/null | gzip -9 > $tardir/all.tar.gz2894 dd if=/dev/zero bs=1k count=64 >> $imagesdir/all.tar.gz 2> /dev/null2895 [ "`du -sm $imagesdir/all.tar.gz | cut -f1`" -ge "30" ] && Die "You have too many tools in your shed"2896 cd $old_pwd2897 [ "$minidir_root" != "" ] && rm -Rf $minidir_root2898 echo -e "$DONE"2899 }2900 2901 2637 2902 2638 ############################################################################## … … 3380 3116 3381 3117 PrepareDataDiskImages $MINDI_CACHE 3382 noof_disks=$?3383 3118 ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE)) 3384 3119 rds=$(($ramdisk_size-$((ramdisk_size%4096)))) … … 3407 3142 LogIt "Finished." 3408 3143 elif [ "$PROMPT_MAKE_TAPE_IMAGE" = "yes" ] ; then 3409 rm -f $MINDI_CACHE/{*img,*gz,*iso} 3144 rm -f $MINDI_CACHE/{*img,*iso} 3145 if [ "$PROMPT_MAKE_USB_IMAGE" = "yes" ] && [ "$USBDEVICE" != "" ]; then 3146 OfferToMakeBootableUSB $MINDI_CACHE 3147 fi 3410 3148 OfferToMakeBootableISO $MINDI_CACHE 3411 3149 if [ -e "$MINDI_CACHE/all.tar.gz" ] ; then -
branches/stable/mindi/rootfs/sbin/install-additional-tools
r1842 r1904 20 20 mountdir=$GROOVY 21 21 # Should be the same as in mindi => conf param 22 MAX_DISKS=9923 22 mkdir -p $mountdir 24 diskno=125 23 res=0 26 24 if [ -e "/tmp/TAPEDEV-HAS-DATA-DISKS" ] ; then 27 25 LogIt "I am assuming the data disks' contents are already in $mountdir." 28 26 else 29 while [ "$diskno" -lt "$MAX_DISKS" ] ; do 30 LogIt "PLEASE WAIT. Untarring disk #$diskno" 2 31 untar $diskno $mountdir 32 res=$(($res+$?)) 33 [ -e "/LAST-DISK" ] && diskno=999 34 diskno=$(($diskno+1)) 35 [ -e "/tmp/CDROM-LIVES-HERE" ] && [ ! -f "/mnt/cdrom/images/$diskno.tar.gz" ] && break 36 done 27 LogIt "PLEASE WAIT. Untarring data content" 2 28 29 mountpoint=/dev/null 30 [ -e "/tmp/CDROM-LIVES-HERE" ] && mountpoint=/mnt/cdrom/images 31 tarball=$mountpoint/all.tar.gz 32 if [ -e "/tmp/CDROM-LIVES-HERE" ] ; then 33 [ -e "$tarball" ] || LogIt "Can't find CD's $tarball" 1 34 fi 35 36 old_pwd=`pwd` 37 cd $mountdir 38 counter=0 39 for fname in `tar -zxvf $tarball` ; do 40 counter=$(($counter+1)) 41 [ "$(($counter % 4))" -eq "0" ] && echo -en "\r\t\t\t\t\t\t\t\\" 42 [ "$(($counter % 4))" -eq "1" ] && echo -en "\r\t\t\t\t\t\t\t|" 43 [ "$(($counter % 4))" -eq "2" ] && echo -en "\r\t\t\t\t\t\t\t/" 44 [ "$(($counter % 4))" -eq "3" ] && echo -en "\r\t\t\t\t\t\t\t-" 45 done 46 cd $old_pwd 47 echo -e -n "\r" 48 [ ! -e "/tmp/CDROM-LIVES-HERE" ] && umount $mountpoint 49 sleep 1 37 50 fi 38 rm -f /LAST-DISK39 51 40 52 LogIt "Recombining large files..." 1 -
branches/stable/mondo/src/common/libmondo-archive.c
r1903 r1904 2907 2907 2908 2908 (void) fwrite((void *) &biggiestruct, 1, sizeof(biggiestruct), fout); 2909 mr_fclose(fout); 2909 if (fout) { 2910 mr_fclose(fout); 2911 } 2910 2912 length = totallength / optimal_set_size / 1024; 2911 2913 mr_msg(1, "Opening in %s; slicing it and writing to CD/tape", -
branches/stable/mondo/src/common/libmondo-mountlist.c
r1663 r1904 847 847 mountlist->el[items].mountpoint, 848 848 mountlist->el[items].format, 849 siz, mountlist->el[items].label , mountlist->el[items].uuid);849 siz, mountlist->el[items].label); 850 850 #elif __FreeBSD__ 851 851 sscanf(incoming, … … 855 855 mountlist->el[items].format, siz); 856 856 strcpy(mountlist->el[items].label, ""); 857 strcpy(mountlist->el[items].uuid, "");858 857 #endif 859 858 … … 910 909 mountlist->el[items].format, 911 910 mountlist->el[items].size, 912 mountlist->el[items].label, 913 mountlist->el[items].uuid); 911 mountlist->el[items].label); 914 912 items++; 915 913 } … … 953 951 mountlist->el[i].device, mountlist->el[i].mountpoint, 954 952 mountlist->el[i].format, mountlist->el[i].size, 955 mountlist->el[i].label , mountlist->el[i].uuid);953 mountlist->el[i].label); 956 954 } 957 955 paranoid_fclose(fout); -
branches/stable/mondo/src/common/libmondo-stream.c
r1903 r1904 850 850 851 851 /*@ long ***************************************************** */ 852 long bytes_to_write = 0 ;852 long bytes_to_write = 0L; 853 853 854 854 /*@ long long *************************************************** */ -
branches/stable/mondo/src/common/mondostructures.h
r1817 r1904 35 35 36 36 /** 37 * For ext2 and ext3, this is the filesystem label (if there is one). If not, this should be "".37 * For ext2 and ext3, this is the filesystem label or uuid (if there is one). If not, this should be "". 38 38 */ 39 39 char label[256]; 40 40 41 /**42 * This is the filesystem UUID (if there is one). If not, this should be "".43 */44 char uuid[64];45 41 }; 46 42 -
branches/stable/mondo/src/mondorestore/mondorestore.c
r1903 r1904 2883 2883 make_hole_for_dir(MONDO_CACHE); 2884 2884 2885 /* Backup original mountlist.txt */2885 /* Backup original mountlist.txt */ 2886 2886 mr_asprintf(&tmp, "%s.orig", g_mountlist_fname); 2887 2887 if (!does_file_exist(g_mountlist_fname)) { … … 2897 2897 mr_free(tmp); 2898 2898 2899 /* Init directories */2899 /* Init directories */ 2900 2900 make_hole_for_dir("/var/log"); 2901 2901 make_hole_for_dir("/tmp/tmpfs"); /* just in case... */
Note:
See TracChangeset
for help on using the changeset viewer.