source: MondoRescue/branches/2.2.4/mindi/mindi@ 1450

Last change on this file since 1450 was 1450, checked in by Bruno Cornec, 17 years ago

Add ata_generic for mindi

  • Property svn:keywords set to Rev Id
File size: 112.6 KB
RevLine 
[747]1#!/bin/bash
2
3# $Id: mindi 1450 2007-05-20 20:51:53Z bruno $
4#
5#-----------------------------------------------------------------------------
6# mindi - mini-Linux distro based on the user's filesystem & distribution
7#
8# Mindi can create a multi-floppy boot/root kit. The first floppy is the boot
9# disk: it contains a kernel, a ramdisk etc. The second disk is data disk #1;
10# the third disk is data disk #2; and so it goes.
11#
12# See http://www.mondorescue.org for details.
13#-----------------------------------------------------------------------------
14
15### Which arch are we on (useful for ia64 port)
[925]16ARCH=`/bin/arch`
[747]17
18ADDITIONAL_BOOT_PARAMS="acpi=off apm=off devfs=nomount noresume selinux=0 barrier=off"
19
[925]20#RUN_AFTER_INITIAL_BOOT_PHASE="echo \"Who lives in a pineapple under the sea?\" > /tmp/spongebob.squarepants.txt"
[747]21 # after booting from floppy/CD image but before
22 # accessing auxiliary data disks (or the rest of
23 # the CD), the initscript will run the above command.
24
25RUN_AFTER_BOOT_PHASE_COMPLETE="ide-opt"
26 # after the emergency boot process is complete but
27 # before the init script runs mondorestore, it will
28 # run this command.
29
30MINDI_REV=RRR
31MINDI_VER=VVV
32
33MINDI_VERSION=${MINDI_VER}-r$MINDI_REV
34MINDI_PREFIX=XXX
35MINDI_CONF=YYY
36MINDI_SBIN=${MINDI_PREFIX}/sbin
[934]37MINDI_LIB=LLL
[747]38
[925]39# Temporary directory for mindi
40TMPDIR=/tmp
41
[747]42EXTRA_SPACE=24576 ; # increase if you run out of ramdisk space
[1282]43BOOT_SIZE=8192 ; # size of the boot disk
[747]44WRITE_BOOT_FLOPPIES="yes" ; # do you want to be propted to write floppy images
45PROMPT_WRITE_BOOT_FLOPPIES="yes"
46 # do you want to be prompted to write
47 # floppy images out to floppy disks?
48 # if 'no', images will not be written to floppies
49
50PROMPT_MAKE_CD_IMAGE="yes"
51 # Ask if you want to make a CD Image to be written?
52 # if this is set to 'no', then the image will be created automatically
53
[966]54USE_OWN_KERNEL="yes"
[747]55 # If set to "no", you will be prompted for whether or not
56 # you want to use your own kernel, or the supplied default.
57 # If "yes" mindi will automatically use your own kernel.
[925]58
[747]59MY_FSTAB=/etc/fstab
60FLOPPY_MODS="ide-floppy floppy"
61TAPE_MODS="ht st osst ide-tape ide_tape"
[1417]62SCSI_MODS="3w-xxxx 3w_xxxx 3x_9xxx 3x-9xxx 53c7,8xx a100u2w a320raid aacraid adpahci advansys aha152x aha1542 aha1740 aic79xx aic79xx_mod aic7xxx aic7xxx_mod aic7xxx_old AM53C974 atp870u BusLogic cciss cpqfc dmx3191d dpt_i2o dtc eata eata_dma eata_pio fdomain gdth g_NCR5380 i2o_block i2o_core ide-scsi ieee1394 imm in2000 initio ips iscsi isp megaraid megaraid_mm megaraid_mbox mptbase mptscsih mptsas mptspi mptfc mptscsi mptctl NCR53c406a ncr53c8xx nsp32 pas16 pci2000 pci2220i pcmcia ppa psi240i qla1280 qla2200 qla2300 qlogicfas qlogicfc qlogicisp raw1394 scsi_debug scsi_mod sd_mod seagate sg sim710 sr_mod sym53c416 sym53c8xx sym53c8xx_2 t128 tmscsim u14-34f ultrastor wd7000 vmhgfs"
[747]63
64# ide-probe-mod
[1450]65IDE_MODS="ide ide-generic ide-detect ide-mod ide-disk ide-cd ide_cd ide-cs ide-core ide_core edd paride ata_generic ata_piix libata via82cxxx generic nvidia ahci sata_nv cmd64x"
[747]66PCMCIA_MODS="pcmcia_core ds yenta_socket"
[1432]67USB_MODS="usb-storage usb-ohci usb-uhci usbcore usb_storage input hid uhci_hcd ehci_hcd uhci-hcd ehci-hcd ohci-hcd ohci_hcd usbkbd usbhid keybdev mousedev"
[747]68CDROM_MODS="$TAPE_MODS $FLOPPY_MODS $IDE_MODS af_packet cdrom isocd isofs inflate_fs nls_iso8859-1 nls_cp437 sg sr_mod zlib_inflate $USB_MODS $PCMCIA_MODS"
[1430]69NET_MODS="sunrpc nfs nfs_acl lockd fscache loop mii 3c59x e100 bcm5700 bnx2 e1000 eepro100 ne2k-pci tg3 pcnet32 8139cp 8139too 8390 forcedeth vmxnet vmnet"
[1258]70EXTRA_MODS="$CDROM_MODS vfat fat loop md-mod linear raid0 raid1 xor raid5 raid456 lvm-mod dm-mod dm-snapshot dm-zero dm-mirror jfs xfs xfs_support pagebuf reiserfs ext2 ext3 minix nfs nfs_acl nfsd lockd sunrpc jbd mbcache"
[1230]71# Replace with that line for HP OCMP e.g.
72#DENY_MODS="MPS_Driver_Mapper mps octtldrv tscttl streams"
73DENY_MODS=""
[1399]74# Force some modules to be included
[1354]75FORCE_MODS=""
[925]76
[747]77LOGFILE=/var/log/mindi.log
78FDDEVICE=/dev/fd0 ; # 1.44MB floppy #0
[925]79CACHE_LOC=/var/cache/mindi
[747]80FORCE_DUAL_FLOPPIES=no
81BOOT_MEDIA_MESSAGE="\
82To format and restore all files automatically, type 'nuke' <enter>.\n\
83To restore some/all files interactively, type 'interactive' <enter>.\n\
84To compare the archives with your filesystem, type 'compare' <enter>.\n\
85To boot to a command-line prompt (expert mode), type 'expert' <enter>.\n\
86You may add one or more of the following parameters as well:-\n\n\
87 donteject - mondorestore will not eject the CD; this is useful if, for\n\
88 instance, your PC's case has a concealed CD-ROM drive\n\
89 noresize - your mountlist will not be adjusted to use your unallocated\n\
90 hard disk space\n\
91 textonly - do not call any Newt library routines; this is unattractive\n\
92 but valuable if you find your Newt library has bugs in it\n\n\
93e.g. Type 'nuke donteject textonly' if you have an unstable Newt library and \n\
94a PC whose CD-ROM drive tray would be damaged if it unexpectedly ejected.\n\
95"
[925]96FDISK=$MINDI_SBIN/parted2fdisk
[747]97
[925]98# Using a config file allow to overwrite some values
99MINDI_CONFIG="$MINDI_CONF/mindi.conf"
100if [ -f $MINDI_CONFIG ]; then
101 . $MINDI_CONFIG
102fi
103
104# Now we can create what we nedd
[940]105MINDI_TMP=`mktemp -d $TMPDIR/mindi.XXXXXXXXXX`
106mkdir -p $MINDI_TMP
107
108# Purge from potential old run
109rm -rf $CACHE_LOC/* 2> /dev/null
[925]110mkdir -p $CACHE_LOC
[747]111# ----------------------------------------------------------------------------
112
113
114AbortHere() {
115 [ "$mountpoint" ] && umount $mountpoint 2>> $LOGFILE
116 Die "Program is terminating in response to signal received from OS/user"
117}
118
119
120HackSyslinuxFile() {
121 local incoming
122 incoming=`ReadLine`
123 while [ "$incoming" ] ; do
124 echo -en "$incoming" | sed s/24000/$1/
125 if [ "`echo "$incoming" | grep append`" ] ; then
126 echo -en " $ADDITIONAL_BOOT_PARAMS"
127 fi
128 echo -en "\n"
129 incoming=`ReadLine`
130 done
131 if [ -e "$MINDI_LIB/memtest.img" ] ; then
132 echo -en "label memtest\n kernel memdisk\n append initrd=memtest.img\n\n"
133 fi
134}
135
136
137Aborted() {
138 trap SIGHUP SIGTERM SIGTRAP SIGINT
[925]139 [ "$CACHE_LOC" != "" ] && rm -f $CACHE_LOC/mindi*img $CACHE_LOC/*gz $CACHE_LOC/mindi.iso
[747]140 [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*
141 Die "User abort."
142}
143
144
145AddFileToCfgIfExists() {
146 [ -e "$1" ] && echo -en "$2 `cat $1`\n" >> $3
147}
148
149
150AddFileToDir() {
151 local filename minidir_root noof_disks diskno res filesize disksize would_occupy zipsize complevel cutoff compressed_fname siz
152 filename=$1
153 minidir_root=$2
154 noof_disks=$3
155
156 diskno=$noof_disks
157 mkdir -p $minidir_root/$diskno
158 [ "$LAST_COMPRESSED_SIZE" = "" ] && LAST_COMPRESSED_SIZE=0
159 if [ ! -e "$filename" ] ; then
[925]160 if [ -h "$filename" ] ; then
[963]161 cp --parents -pRdf $filename $minidir_root/$diskno 2>> $LOGFILE
[925]162 return $noof_disks
163 else
164 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?"
165 fi
[747]166 fi
[925]167
168 # move to the disk that has room on it (or end up using the last, if all full)
[747]169 while [ "$diskno" -lt "40" ] ; do
[925]170 mkdir -p $minidir_root/$diskno
[747]171 filesize=`du -sk $filename | cut -f1`
[963]172 cp --parents -Rdf $filename $minidir_root/$diskno 2>> $LOGFILE
[747]173 if [ "$filesize" -le "4" ] ; then
174 siz=$filesize
175 elif [ ! -f "$filename" ] ; then
176 siz=0
177 else
178 siz=`grep -m 1 "$filename.gz$" $minidir_root/compressed/compressed.txt | cut -f1`
179 [ "$siz" = "" ] && Die "FIXME - can't find $filename's size."
180 siz=$(($siz-2));# to allow for sectors & the fact that they round up
181 fi
[925]182 [ ! "$siz" ] && siz=4
183 [ "$siz" -lt "0" ] && siz=0
[747]184 LAST_COMPRESSED_SIZE=$(($LAST_COMPRESSED_SIZE+$siz))
[925]185 [ "$LAST_COMPRESSED_SIZE" -le "$MAX_COMPRESSED_SIZE" ] &&return $diskno
186 echo "disk=$diskno siz=$LAST_COMPRESSED_SIZE" >> $LOGFILE
187 LAST_COMPRESSED_SIZE=0
188 rm -f $minidir_root/$diskno/$filename
[747]189 diskno=$(($diskno+1))
190 done
191 return 0 ; # failed
192}
193
194
195AddKeyboardMappingFile() {
196 local mappath r included_list included_item i res ii sss
197 mappath=$1
198 KBDEPTH=$(($KBDEPTH+1))
199 [ "$KBDEPTH" -gt "128" ] && Die "Edit $MINDI_SBIN/mindi and disable FindAndAddUserKeyboardMappingFile (line 2160, approx.)"
200 if [ -e "$bigdir/$mappath" ] ; then
201 echo "$mappath already added" >> $LOGFILE
202 return
203 elif [ -d "$bigdir/$mappath" ] ; then
204 echo "Cannot add $mappath: it's a directory. Sorry."
205 return
206 fi
207 echo "Added kbd map $mappath" >> $LOGFILE
208 if [ ! -e "$mappath" ] ; then
209 mappath=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
210 if [ ! -e "$mappath" ] ; then
[963]211 LogIt "Cannot add $mappath: kbd map file not found"
[747]212 return
213 fi
214 else
215 echo -en "`basename $mappath | tr '.' '#' | sed s/#kmap#gz// | sed s/#inc#gz//` " | tr '#' '.'
216 fi
217
218 mkdir -p $bigdir/etc
[963]219 cp --parents -pRdf $mappath $bigdir 2>> $LOGFILE || LogIt "AKMF -- Could not copy $mappath to $bigdir"
[747]220 if [ "`echo $mappath | grep -F ".gz"`" ] ; then
221 included_list=`gzip -dc $mappath | grep -Fi include | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
222 else
223 included_list=`grep -Fi include $mappath | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
224 fi
225 for included_item in $included_list ; do
[925]226 if [ ! -e "$included_item" ] ; then
[747]227 sss=`find $KEYDIR/keymaps | grep -F "${included_item}.inc"`
[925]228 [ "$sss" = "" ] && sss=`find $KEYDIR/keymaps | grep -F "$included_item"`
229 for ii in $sss ; do
[747]230 [ -e "$ii" ] && AddKeyboardMappingFile $ii
[925]231 done
232 else
233 AddKeyboardMappingFile $included_item
234 fi
[747]235 done
236}
237
238
239ChopUpAndCopyFile() {
240 local filename slicesize outdir res biggienumber filesize sliceno noof_slices testfile scratchfile
241 filename=$1
242 outdir=$2
243 slicesize=$3
244 biggienumber=$4
245
246 [ -d "$filename" ] && Die "Cannot chop up $filename: it's a directory. Please amend deplist.txt accordingly."
247 mkdir -p $outdir
248
249 sliceno=0
[940]250 scratchfile=$MINDI_TMP/blah.$$.dat
[963]251 cp -f $filename $scratchfile 2>> $LOGFILE || Die "CUACF -- cannot copy $filename to $scratchfile - did you run out of disk space?"
[747]252 [ "`head $scratchfile -n1 | grep -F "bin/sh"`" != "" ] && StripComments $scratchfile "-$filename-"
253 [ "`echo "$filename" | grep -F "etc/termcap"`" != "" ] && StripComments $scratchfile "-$filename-"
254 if [ "`echo "$filename" | grep -F "lib/modules/" | grep "\.*o\.gz"`" != "" ] ; then
[925]255 mv $scratchfile $scratchfile.gz
[963]256 gunzip -f $scratchfile || LogIt "Cannot gunzip $scratchfile.gz"
[925]257 filename=`echo "$filename" | tr '.' '#' | sed s/#o#gz/#o/ | sed s/#ko#gz/#ko/ | tr '#' '.'`
[747]258 fi
259 filesize=`du -sk $scratchfile | cut -f1`
260 noof_slices=$(($filesize/$slicesize))
261 echo "$filename" > $outdir/slice-$biggienumber.name
262 echo "$filesize" > $outdir/slice-$biggienumber.size
263 [ -x "$scratchfile" ] && StripExecutable $scratchfile "-$filename-"
264 while [ "$sliceno" -le "$noof_slices" ] ; do
[963]265 dd if=$scratchfile skip=$(($sliceno*$slicesize)) of=$outdir/slice-$biggienumber.`printf "%03d" $sliceno` bs=1k count=$slicesize &> /dev/null
[747]266 sliceno=$(($sliceno+1))
267 done
268 rm -f $scratchfile
269}
270
271
272CopyBootBFile() {
273 local copy_to copy_from possible_locations liloc
274 copy_to=$1
275 copy_from=/boot/boot.b
276 liloc=`which lilo.real 2>/dev/null`
277 [ $liloc ] || liloc=`which lilo 2>/dev/null`
278 if [ $liloc ]; then
279 if ! [ `strings $liloc | grep "boot\.b"` ]; then
[963]280 LogIt "boot.b files built into lilo; I'll create a dummy."
[747]281 > $copy_to
282 return 0
283 fi
284 fi
285 if [ ! -f "$copy_from" ] ; then
286 LogIt "OK, you don't have a /boot/boot.b file, which is odd because\n most _good_ Linux distributions come with one, even if it's only a softlink"
287 copy_from=`grep install= /etc/lilo.conf | grep "\.b" | cut -d'=' -f2`
288 if [ ! -f "$copy_from" ] ; then
[963]289 LogIt "Nor can I find it from your /etc/lilo.conf file. This is very odd."
[747]290 copy_from=`FindSensibleBootBFile`
[963]291 LogIt "I'm going to use '$copy_from'"
[747]292 fi
293 fi
[963]294 cp -f $copy_from $copy_to 2>> $LOGFILE || LogIt "CBBF -- warning -- cannot find your boot.b file. That's it, I quit... (j/k)"
[747]295}
296
297
298CopyDependenciesToDirectory() {
299 local outdir incoming fname filesize counter
300 outdir=$1
301 mkdir -p $outdir
302 incoming=`ReadLine`
303 counter=0
304 while [ "$incoming" != "" ] ; do
[925]305 if [ -d "$incoming" ] ; then
[747]306 find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir
307 elif [ -e "$incoming" ] ; then
308 filesize=`du -sk $incoming | cut -f1`
309 if [ "$filesize" -gt "$(($CHOPSIZE*2))" ] && [ ! -h "$incoming" ] ; then
310 ChopUpAndCopyFile $incoming $outdir $CHOPSIZE $BIGNO
311 BIGNO=$(($BIGNO+1))
312 else
[953]313 cp --parents -Rdf $incoming $outdir 2> /dev/null || Die "Cannot copy $incoming to $outdir - did you run out of disk space?"
[925]314 if [ "`echo "$incoming" | grep "lib/modules/.*\..*o\.gz"`" != "" ] ; then
[963]315 gunzip -f $outdir/$incoming || LogIt "Cannot gunzip $outdir/$incoming"
[925]316 fi
317 [ -x "$outdir" ] && StripExecutable $outdir "-$filename-"
318 fi
319 counter=$(($counter+1))
320 if [ "$counter" -ge "5" ] ; then
321 counter=0
322 echo -en "."
323 fi
[747]324 fi
325 incoming=`ReadLine`
326 done
327}
328
329
330CopyImageToDisk() {
331 local image dev procno res comment
332 image=$1
333 dev=$2
334 comment=$3
335 [ ! -f "$image" ] && [ ! -b "$image" ] && Die "Image $image does not exist. Did you run out of disk space?"
336 Prompt "About to write $comment. Please press ENTER."
337 echo -en "Formatting disk..."
338 if which fdformat > /dev/null ; then
[925]339 fdformat -n $dev > /dev/null 2> /dev/null || Die "Cannot format $dev - is your Linux distro broken?"
[747]340 elif which superformat > /dev/null ; then
[925]341 superformat $dev > /dev/null 2> /dev/null || Die "Cannot format $dev - is your Linux distro broken?"
[747]342 else
[925]343 Die "Please install either fdformat or superformat."
[747]344 fi
345 echo -en "\rWriting $comment"
346 if echo $image | grep "mindi-[r|b]oot\.1440" &> /dev/null ; then
[925]347 cat $image > $dev &
[747]348 else
[925]349 dd if=$image of=$dev &> /dev/null &
[747]350 fi
351 procno=$!
352 ps $procno > /dev/null 2> /dev/null
353 while [ "$?" -eq "0" ] ; do
354 sleep 3
355 echo -en "."
356 ps $procno > /dev/null 2> /dev/null
357 done
358 echo -e "$DONE"
[963]359 LogIt "$comment has been written."
[747]360}
361
362
363CountItemsIn() {
364 local r
365 r=0
366 for q in $1 ; do
367 r=$(($r+1))
368 done
369 echo $r
370}
371
372
373CreateDataDiskImagesFromTarballs() {
374 local tardir outdir diskno noof_disks kp
375 tardir=$1
376 outdir=$2
377 noof_disks=$3
378
379 mkdir -p $outdir
380 diskno=1
381 echo -en "Creating data disk "
382 while [ "$diskno" -le "$noof_disks" ] ; do
[925]383 echo -en "#$diskno..."
[963]384 cp -f $tardir/$diskno.tar.gz $outdir 2>> $LOGFILE || LogIt "[line 424] Cannot copy $tardir/$diskno.tar.gz to $outdir"
[747]385 CreateOneDataDiskImage $tardir/$diskno.tar.gz $outdir/mindi-data-$diskno.img $diskno $noof_disks
386 diskno=$(($diskno+1))
387 done
388 mv -f $tardir/all.tar.gz $outdir
389 du -sk $outdir/*gz >> $LOGFILE
390 echo -e "$DONE"
391}
392
393
394
395CreateOneDataDiskImage() {
396 local tarball imagefile dev diskno noof_disks mountpoint
397 tarball=$1
398 imagefile=$2
399 diskno=$3
400 noof_disks=$4
401
[940]402 mountpoint=$MINDI_TMP/mountpoint.$$
[747]403 mkdir -p $mountpoint
[963]404 dd if=/dev/zero of=$imagefile bs=1k count=1440 &> /dev/null || LogIt "Cannot dd (CODI)"
[964]405 mke2fs -N 12 -F $imagefile >> $LOGFILE 2>> $LOGFILE
[747]406 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."
407 mv $tarball $mountpoint/
408 if [ "$?" -ne "0" ] ; then
[925]409 umount $mountpoint
410 Die "Tarball $tarball is too big for disk! (CODI)\nTell Dev Team to adjust MAX_COMPRESSED_SIZE"
[747]411 fi
412 [ "$diskno" -eq "$noof_disks" ] && echo "This is the last disk ($diskno=$noof_disks)" >> $mountpoint/LAST-DISK
[963]413 umount $mountpoint || LogIt "Cannot umount (CODI)"
414 rmdir $mountpoint || LogIt "Cannot rmdir (CODI)"
[747]415}
416
417
[925]418# Last function called before exiting
419# Parameter is exit code value
[931]420MindiExit() {
[925]421 local my_partitions
[747]422
[925]423 echo "Mindi $MINDI_VERSION is exiting" >> $LOGFILE
424 echo "End date : `date`" >> $LOGFILE
[1335]425 if [ _"$MONDO_SHARE" != _"" ] ; then
[1349]426 echo "------------- mindi logfile included -------------------------" >> /var/log/mondoarchive.log
[1315]427 cat $LOGFILE >> /var/log/mondoarchive.log
[1349]428 echo "--------------------------------------------------------------">> /var/log/mondoarchive.log
[1315]429 fi
[747]430
[925]431 sync
432 cd /
[747]433
[925]434 # Unmount whtat could remain mounted
435 my_partitions=`mount | grep -F $$ | cut -f1 -d' '`
436 [ "$my_partitions" != "" ] && umount $my_partitions
[940]437 # Clean temporary files only when standalone mindi
[948]438 if [ _"$MINDI_TMP" != _"$MONDO_TMP" ]; then
[940]439 rm -Rf $MINDI_TMP
440 fi
[925]441 exit $1
442}
443
[747]444Die() {
[925]445 local i
[747]446 if [ "$1" = "" ] ; then
[963]447 LogIt "FATAL ERROR"
[747]448 else
[963]449 LogIt "FATAL ERROR. $1"
[747]450 fi
451
[1315]452 LogIt "Please e-mail a copy of $LOGFILE to the mailing list."
[963]453 LogIt "See http://www.mondorescue.org for more information."
[747]454 LogIt "WE CANNOT HELP unless you enclose that file.\n"
[925]455 MindiExit -1
[747]456}
457
458
459DropOptimizedLibraries() {
460 local outdir filelist list_of_optimized_libraries optimized_lib_name vanilla_lib_name reason msg resolved res
461 filelist=$1
462 outdir=$2
463
464 list_of_optimized_libraries=`grep "lib/i[5-7]86/" $filelist`
465 if [ "$list_of_optimized_libraries" = "" ] ; then
[859]466 return 0
[747]467 fi
468 echo -en "Dropping i686-optimized libraries if appropriate"
469 for optimized_lib_name in $list_of_optimized_libraries ; do
[859]470 echo -en "."
471 reason=""
[1400]472 vanilla_lib_name=`echo "$optimized_lib_name" | sed -e 's/i[5-7]86//' -e 's/cmov//' | tr -s '/' '/'`
[859]473 echo "$vanilla_lib_name" >> $filelist
474 resolved=$vanilla_lib_name
[747]475 echo "Adding $resolved to filelist" >> $LOGFILE
[861]476 resolved=`ReadAllLink $resolved`
477 echo "Adding $resolved to filelist" >> $LOGFILE
[859]478 mkdir -p $outdir$optimized_lib_name > /dev/null 2> /dev/null
479 rmdir $outdir$optimized_lib_name > /dev/null 2> /dev/null
480 ln -sf $vanilla_lib_name $outdir$optimized_lib_name
481 echo "Excluding $optimized_lib_name" >> $LOGFILE
[935]482 grep -Fvx "$optimized_lib_name" "$filelist" > $filelist.tmp
[859]483 echo "Replacing it with $vanilla_lib_name" >> $LOGFILE
484 echo "$vanilla_lib_name" >> $filelist.tmp
485 mv -f $filelist.tmp $filelist
[747]486 done
[925]487 $AWK '{ print $1; }' $filelist | sort -u > $filelist.tmp
[747]488 mv -f $filelist.tmp $filelist
489 echo -e "$DONE"
490}
491
492
493FindAndAddUserKeyboardMappingFile() {
494 local r res mapfile mappath included_item included_list keyfile mp locale
[963]495 LogIt "Analyzing your keyboard's configuration."
[747]496 KEYDIR=/lib/kbd
497 [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share/kbd # Slackware
498 [ ! -e "$KEYDIR" ] && KEYDIR=/usr/lib/kbd
499 [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share
500 if [ ! -e "$KEYDIR" ] ; then
[963]501 LogIt "Keyboard mapping directory not found. I shall use default map at boot-time."
[747]502 return 0
503 fi
504 if [ -e "/etc/sysconfig/keyboard" ] ; then
505 echo "Red Hat-style config detected." >> $LOGFILE
506 keyfile=/etc/sysconfig/keyboard
507 elif [ -e "/etc/rc.d/rc.keymap" ] ; then
508 echo "Slackware-style config detected." >> $LOGFILE
509 keyfile=/etc/rc.d/rc.keymap
510 elif [ -e "/etc/rc.config" ] ; then
511 echo "Debian-style config detected." >> $LOGFILE
512 keyfile=/etc/rc.config
513 elif [ -e "/etc/console/boottime.kmap.gz" ] ; then
514 echo "Debian-style config detected." >> $LOGFILE
515 echo -en "Adding the following keyboard mapping tables: "
516 mkdir -p $bigdir/tmp
517 echo "/etc/console/boottime.kmap.gz" > $bigdir/tmp/KEYMAP-LIVES-HERE
518 KBDEPTH=0
519 mkdir -p $bigdir/etc/console
[963]520 cp /etc/console/boottime.kmap.gz $bigdir/etc/console 2>> $LOGFILE
[747]521 echo -e "$DONE"
522 return 0
523 else
524 echo -en "Searching for rc.config ..."
525 keyfile=`find /etc -name rc.config | head -n1`
526 if [ "$keyfile" = "" ] || [ ! -e "$keyfile" ] ; then
[963]527 LogIt "Unknown config detected. Default keyboard map will be used."
[747]528 return
529 else
530 echo "Found $keyfile" >> $LOGFILE
531 fi
532 fi
533 if [ ! -e "$KEYDIR/keymaps" ] ; then
[963]534 LogIt "Keyboard mapping directory not found. Default keyboard map will be used."
[747]535 return
536 fi
537 echo "keyfile=$keyfile" >> $LOGFILE
538 locale=`grep -F KEYTABLE "$keyfile" | tr -d '"' |cut -d'=' -f2`
539 [ ! "$locale" ] && locale=`grep '.map$' "$keyfile" | sed 's/^.* //'` # Slackware
540 echo "locale=$locale" >> $LOGFILE
541 mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep -F "/${locale}." | grep -vx " *#.*"`
542 [ ! "$mp" ] && mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
543 # If we have multiple keymaps then log it !!
544 echo "$mp" | grep -q " "
545 if [ $? -eq 0 ]; then
546 echo "WARNING: Multiple keymaps found: $mp" | tee -a $LOGFILE
547 echo "The following one will be used" >> $LOGFILE
548 fi
549 for i in $mp ; do
550 mappath=$i
551 [ -e "$i" ] && [ ! -d "$i" ] && break
552 done
553 if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
554 mappath=$(locate */kbd/keymaps/*/$locale)
555 fi
556 echo "mappath = $mappath" >> $LOGFILE
557 if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
[963]558 LogIt "Keyboard mapping file not found. Default keyboard map will be used."
[747]559 return
560 fi
561 echo -en "Adding the following keyboard mapping tables: "
562 mkdir -p $bigdir/tmp
563 echo "$mappath" > $bigdir/tmp/KEYMAP-LIVES-HERE
564 KBDEPTH=0
565 AddKeyboardMappingFile $mappath
566 echo -e "$DONE"
567 return 0
568}
569
570
571FindIsolinuxBinary() {
572 ISOLINUX=/usr/lib/isolinux.bin
573 [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/lib/syslinux/isolinux.bin
574 [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/share/syslinux/isolinux.bin
575 [ ! -e "$ISOLINUX" ] && ISOLINUX=/usr/share/lib/syslinux/isolinux.bin
576 [ ! -e "$ISOLINUX" ] && ISOLINUX=`locate isolinux.bin | grep -x "/.*/isolinux.bin"`
577 [ ! -e "$ISOLINUX" ] && Die "Please install isolinux first. If your syslinux RPM doesn't include isolinux, you may download an isolinux RPM from Mondo's website - go to http://www.mondorescue.com and click on 'Download'"
578 echo "Found isolinux.bin at $ISOLINUX" >> $LOGFILE
579}
580
581
582FindLiloBinary() {
583 if which lilo &> /dev/null ; then
[925]584 if which lilo.real > /dev/null 2> /dev/null ; then
585 LILO_EXE=lilo.real
[963]586 LogIt "lilo.real found; will be used instead of lilo (*grumble* *mutter*)"
[925]587 else
588 LILO_EXE=lilo
589 fi
590 $LILO_EXE -V | grep -F "21.6" > /dev/null && Die "Please upgrade LILO. Your version has a serious bug. If you're not _using_ LILO, fine, uninstall it. :)"
[747]591 else
[925]592 LILO_EXE=`which false`
[747]593 fi
594}
595
[925]596
[747]597FindSensibleBootBFile() {
598 local i out last
599 out=""
600 last=""
601 for i in `find /boot -type f | grep -v chain | grep -v os2 | sort -u` ; do
602 if [ "`strings $i 2> /dev/null | head -n1`" = "LILO" ] ; then
603 out="$out $i"
[925]604 last="$i"
[747]605 fi
606 done
607 echo "$last"
608}
609
610
611FindSpecificModuleInPath() {
612 local modpaths pwd line
613 pwd=`pwd`
614 if [ "$YOUR_KERNEL_SUCKS" ] ; then
[940]615 cd $MINDI_TMP
[747]616 else
617 cd /
618 fi
619 if [ ! -e "$1" ] ; then
[963]620 LogIt "WARNING - cannot search specific path '$1'"
[747]621 return 1
622 fi
623 modpaths=`find $1 -name $2.*o -type f`
624 [ "$?" -ne "0" ] && Die "find $1 -name $2.o -type f --- failed"
625 [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.o.gz -type f`
626 [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.ko.gz -type f`
627 [ "$modpaths" = "" ] && modpaths=`find $1 -name $2 -type f`
628 echo "$modpaths"
629 cd $pwd
630}
631
632
633GenerateGiantDependencyList() {
634 local incoming loc fname list_of_files i tempfile outfile progress filelist res r mapfile mappath included_list included_item old_pwd tempdepfile modres noof_lines lvmversion lvmresolved
635
636 echo -en "Analyzing dependency requirements"
637 outfile=$1
[940]638 tempfile=$MINDI_TMP/$$.txt
[747]639 incoming=`ReadLine`
640
641 > $tempfile
642 progress=0
643 res=0
644 noof_lines=$2
645 while [ "$incoming" != "" ] ; do
[861]646 if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
647 incoming=`ReadLine`
648 continue
649 fi
650 if [ "$incoming" = "LVMFILES:" ] ; then
651 break
652 fi
[747]653 filelist=`GenerateListForFile "$incoming"`
654 r=$?
[963]655 [ "$r" -ne "0" ] && LogIt "$incoming not found"
[747]656 res=$(($res+$r))
[861]657# echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE
[747]658 for fname in $filelist ; do
[861]659 [ "$fname" != "" ] && echo "$fname" >> $tempfile
[747]660 done
661 progress=$(($progress+1))
662 echo -en "\r\t\t\t\t\t\t\t\t"
663 i=$(($progress*100))
664 i=$(($i/$noof_lines))
665 echo -en "$i"
666 echo -en "%"
667 modres=$(($progress%4))
668 [ "$modres" -eq "0" ] && echo -en "\t/"
669 [ "$modres" -eq "1" ] && echo -en "\t-"
670 [ "$modres" -eq "2" ] && echo -en "\t\\"
671 [ "$modres" -eq "3" ] && echo -en "\t|"
672 incoming=`ReadLine`
673 done
[861]674 if [ "$incoming" = "LVMFILES:" ] ; then
675 incoming=`ReadLine`
676 lvmversion=""
677 while [ "$incoming" != "" ] ; do
678 if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
679 incoming=`ReadLine`
680 continue
681 fi
682 filelist=`GenerateListForFile "$incoming"`
683 for tool in $filelist ; do
684 lvmresolved=`readlink -f $tool`
[1342]685 if [ "$tool" = "$lvmresolved" ]; then
[861]686 echo "$tool" >> $tempfile
687 elif echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
688 if [ "$lvmversion" = "" ] ; then
689 lvmversion=`$lvmresolved`
690 echo "$lvmresolved" >> $tempfile
691 fi
692 toolstripped=`echo $tool | $AWK -F / '{print $NF;}'`
[1342]693 if [ "$lvmversion" = "200" ]; then
[861]694 # pvdata and lvmcreate_initrd don't exist in LVM2
695 case "$toolstripped" in
696 "pvdata")
697 continue
698 ;;
699 "lvmcreate_initrd")
700 continue
701 ;;
702 esac
703 fi
704 toolpath="/sbin/lvm-"$lvmversion"/"$toolstripped
705 if [ -e "$toolpath" ] ; then
706 echo "$toolpath" >> $tempfile
707 echo "$tool" >> $tempfile
708 else
709 toolpath="/lib/lvm-"$lvmversion"/"$toolstripped
710 fi
711 if [ -e "$toolpath" ] ; then
712 echo "$toolpath" >> $tempfile
713 echo "$tool" >> $tempfile
714 else
715 echo "Where are your LVM-Tools? Couldn't find $tool"
716 fi
717 else
718 echo "$tool" >> $tempfile
719 fi
720 done
721 progress=$(($progress+1))
722 echo -en "\r\t\t\t\t\t\t\t\t"
723 i=$(($progress*100))
724 i=$(($i/$noof_lines))
725 echo -en "$i"
726 echo -en "%"
727 modres=$(($progress%4))
728 [ "$modres" -eq "0" ] && echo -en "\t/"
729 [ "$modres" -eq "1" ] && echo -en "\t-"
730 [ "$modres" -eq "2" ] && echo -en "\t\\"
731 [ "$modres" -eq "3" ] && echo -en "\t|"
732 incoming=`ReadLine`
733 done
[747]734 fi
735 echo -en "$DONE\nMaking complete dependency list"
736
737 tr -s '/' '/' < $tempfile | sort -u > $tempfile.new
738 mv -f $tempfile.new $tempfile
739 > $outfile.pre
740 progress=0
741 noof_lines=`cat $tempfile | wc -l`
742 for fname in `cat $tempfile` ; do
[925]743 echo "$fname" >> $outfile.pre
744 LocateDeps $fname >> $outfile.pre
745 progress=$(($progress+1))
[747]746 echo -en "\r\t\t\t\t\t\t\t\t"
747 i=$(($progress*100))
748 i=$(($i/$noof_lines))
749 echo -en "$i"
750 echo -en "%"
[925]751 modres=$(($progress%4))
[747]752 [ "$modres" -eq "0" ] && echo -en "\t/"
753 [ "$modres" -eq "1" ] && echo -en "\t-"
754 [ "$modres" -eq "2" ] && echo -en "\t\\"
755 [ "$modres" -eq "3" ] && echo -en "\t|"
756 done
[1335]757 if [ _"$MONDO_SHARE" != _"" ] ; then
[925]758 mkdir -p $bigdir/tmp
759 mkdir -p $bigdir/sbin
760 mkdir -p $bigdir/bin
[940]761 if [ -e "$MINDI_TMP/post-nuke.tgz" ] ; then
[963]762 LogIt "\nIncorporating post-nuke tarball"
[925]763 old_pwd=`pwd`
764 cd $bigdir
[963]765 tar -zxf $MINDI_TMP/post-nuke.tgz || LogIt "Error occurred when untarring post-nuke tarball"
[925]766 cd $old_pwd
[747]767 fi
[963]768 if cp -f $MINDI_TMP/mondo*restore $bigdir/usr/bin 2>> $LOGFILE ; then
[925]769 LocateDeps $bigdir/usr/bin/mondo*restore >> $outfile.pre
770 else
[963]771 LogIt "Cannot find mondo*restore in mondo's tempdir, $MINDI_TMP"
772 LogIt "I bet you've got a spare copy of Mondo or Mindi floating around on your system."
[925]773 LogIt "If Mindi was called by Mondo then send me a bug report.\n It not, type 'ps ax' to see which Mondo-related process is still running;\n then kill it. :-)\n Finally, run Mindi again."
774 Die "Odd."
775 fi
[963]776 cp -f $MINDI_TMP/BOOTLOADER.* $bigdir 2> /dev/null || LogIt "\nMondo v1.2x defaults to LILO as the bootloader, BTW."
[940]777 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[963]778 LogIt "Incorporating NFS-related settings"
[925]779 for r in NFS-* ISO-PREFIX ; do
[963]780 cp -f $MINDI_TMP/$r $bigdir/tmp 2>> $LOGFILE || Die "Cannot copy $r - did you run out of disk space?"
[925]781 echo "Copying $r to ramdisk" >> $LOGFILE
782 done
783 fi
[747]784 fi
[925]785 tr ' ' '\n' < $outfile.pre | tr -s '/' '/' | grep -Fvx "" | sort -u | grep -Ev "/libX11|/libXext|/libXi|/libgtk|/libgdk" > $outfile
[747]786 rm -f $tempfile $outfile.pre
787 [ "$res" -eq "0" ] && echo -e "\r\t\t\t\t\t\t\t\t$DONE" || echo "\nFailed."
788 return $res
789}
790
791
792GenerateListForFile() {
793 local files_found loc fname incoming i res
794 incoming="$1"
795 files_found=""
796 res=0
797
798 for fname in $incoming ; do
799 files_found="$files_found `LocateFile $fname`"
800 done
801
802 echo "$files_found" | tr ' ' '\n' | sort -u | tr '\n' ' '
803}
804
805
806# Returns all disk devices which are part of a raid array
807GetAllRaidMembers() {
808 $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*device/ if(\$2) {print \$2}" < /etc/raidtab
809}
810
811
812GetFileSizeList() {
813 local i
814 for i in `find $1 -type d -o -print` ; do
815 du -sk $i
816 done
817}
818
819
820GetHomeDir() {
821 local res loc
822 loc=`which $1 2>/dev/null`
823 res=`file $loc | $AWK '{print $NF;}'`
824 dirname $res
825}
826
827
[1230]828# Check kernel filesystem capabilites for accessing initrd image
829#
830# Interface definition:
831# param #1: absolute path to kernel image
832GetInitrdFilesystemToUse() {
833
834 # interface test: make sure we have one parameter
835 if [ $# -ne 1 ]; then
836 Die "GetInitrdFilesystemToUse(): Expected 1 parameter, got $#."
837 fi
838
839 # interface parameters
840 local lvKernelImage=$1
841
842 # local constants (filesystem magic strings)
843 local lcMagicCramfs="<3>cramfs: wrong magic"
844 local lcMagicExt2fs="<3>EXT2-fs: blocksize too small for device."
845 local lcMagicInitfs="<6>checking if image is initramfs..."
846
847 # local variables
848 local lvOffset
849 local lvScanRes
850 local lvUseFilesystem
851
852 # say where we are.
853 echo " GetInitrdFilesystemToUse(): called with parameter: $lvKernelImage.\n" >> $LOGFILE
854
855 # verify that file exists
856 [ ! -f $lvKernelImage ] && Die "File $lvKernelImage not found. Terminating."
857
858 # get offet of gzip magic "1f8b0800" in file
859 lvOffset=`od -vA n -t x1 $lvKernelImage | tr -d '[:space:]' | awk '{ print match($0, "1f8b0800")}'`
860 [ $lvOffset -eq 0 ] && Die "gzip magic not found in file $lvKernelImage. Terminating."
861 lvOffset=`expr $lvOffset / 2`
862 echo " GetInitrdFilesystemToUse(): gzip magic found at lvOffset $lvOffset.\n" >> $LOGFILE
863
864 # scan kernel image for initrd filessystem support
865 lvScanRes=`dd ibs=1 skip=$lvOffset if=$lvKernelImage obs=1M 2>/dev/null | gunzip -c | strings | grep -e "$lcMagicCramfs" -e "$lcMagicExt2fs" -e "$lcMagicInitfs"`
866
867 # determine which filesystem to use for initrd image: ext2fs, gzip'ed cpio (initramfs ) or cramfs
868 if [ `echo $lvScanRes | grep -c "$lcMagicExt2fs"` -eq 1 ]; then
869 lvUseFilesystem="ext2fs"
870 elif [ `echo $lvScanRes | grep -c "$lcMagicInitfs"` -eq 1 ]; then
871 lvUseFilesystem="initramfs"
872 elif [ `echo $lvScanRes | grep -c "$lcMagicCramfs"` -eq 1 ]; then
873 lvUseFilesystem="cramfs"
874 else
875 lvUseFilesystem="UNSUPPORTED"
876 fi
877
878 # say what we are using
879 echo " GetInitrdFilesystemToUse(): Filesytem to use for initrd is $lvUseFilesystem.\n" >> $LOGFILE
880
881 # return file system to use
882 echo "$lvUseFilesystem"
883
884}
885
[747]886# Searches parent raid device of given disk device
887# $1: disk device (i.e. /dev/hda1)
888GetParentRaidDev() {
889 $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {dev=\$2} /^[[:space:]]*device/ {if(\$2==\"$1\") {print dev; exit}}" < /etc/raidtab
890}
891
892
893# Searches members of raid device
894# $1: raid device (/dev/md...)
895GetRaidDevMembers() {
896 $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {if(dev) exit; if(\$2 == \"$1\") dev=\$2} /^[[:space:]]*device/ {if(dev) {print \$2}}" < /etc/raidtab
897}
898
899
900HackPathsToFailsafe() {
901 local incoming newpath kver stub i pwd
902 kver=`uname -r`
903 incoming=`ReadLine`
904 pwd=`pwd`
[940]905 cd $MINDI_TMP
[747]906 while [ "$incoming" != "" ] ; do
[925]907 stub=`basename $incoming`
908 newpath=`FindSpecificModuleInPath lib/modules/$FAILSAFE_KVER $stub`
909 for i in $newpath ; do
910 echo "$i"
911 done
912 read incoming
[747]913 done
914 cd $pwd
915}
916
917
918ListAllPartitions() {
919 local res currline partition all_partitions ap_orig remaining i j
920
[957]921 grep -vx " *#.*" $MY_FSTAB | grep -vx " *none.*" | $AWK '/^\/dev\/[imhs]d||^LABEL\=\/|^UUID=/ && !/fdd|cdr|zip|floppy/ {print $1}'
[747]922 [ -e "/etc/raidtab" ] && $AWK '/^ *device/ {print $2}' /etc/raidtab
923 return
924}
925
926
927ListImagesForUser() {
928 local path fname
929 path=$1
930 echo -en "In the directory '$path' you will find the images:-\n"
931 for fname in `ls $path | grep -F mindi-` ; do
932 printf "%19s " $fname
933 done
934 echo " "
935}
936
937
938ListKernelModulePaths() {
939 local module_list module fname oss r kern
940 oss="/root/oss/modules"
[1399]941 module_list="$MODULES"
[1230]942 # Remove unwanted modules from list
943 for i in $DENY_MODS; do
944 module_list=`echo ${module_list} | tr ' ' '\n' | grep -Ev "^${i}$" | tr '\n' ' '`
945 done
[747]946###
947### Sq-Modification ... Use kernelname for module search path if specified
948###
949 # kern="`uname -r`"
950 if [ "${kernelname}" != "" -a "${kernelname}" != "FAILSAFE" ]
951 then
952 kern=${kernelname}
953 else
954 kern="`uname -r`"
955 fi
956###
957### Sq-Mod End
958###
959 for module in $module_list $EXTRA_MODS ; do
960 r=`find /lib/modules/$kern -type f | grep "/${module}\..*o" | tail -n1`
961 echo "module $module --> $r" >> $LOGFILE
962 [ "$r" ] && echo "$r"
963 [ -f "$oss" ] && find $oss | grep -F $module
964 done
965 find /lib/modules/$kern/modules.* -type f 2> /dev/null
966 [ -f "$oss" ] && find $oss.* 2> /dev/null
967}
968
969
970LocateDeps() {
971 local incoming fname deps
972 incoming="$1"
973 for fname in $incoming ; do
974 if [ ! -e "$fname" ] ; then
[963]975 echo "WARNING - $fname does not exist; cannot be LDD'd." >> $LOGFILE
[747]976 if echo $fname | grep lvm &> /dev/null ; then
977 echo "This warning only affects you if you are using LVM." >> $LOGFILE
[1399]978 if echo "$MODULES" | grep lvm &> /dev/null ; then
[747]979 echo "I think you are, so please take heed!" >> $LOGFILE
980# LogIt "Where is liblvm? You need it."
981 else
982 echo "I don't think you are, so don't worry about it." >> $LOGFILE
983 fi
984 fi
985 elif [ -h "$fname" ] && [ -x "$fname" ] ; then
986 echo "$fname is softlink" >> $LOGFILE
987 else
988 ldd $fname 2> /dev/null | ProcessLDD $fname
989 fi
990 done
991}
992
[925]993
[860]994# Give all symlinks recursively of a full path name
995ReadAllLink() {
996 file="$1"
[747]997
[860]998 if [ ! -h $file ]; then
999 echo "$file"
1000 return 0
1001 fi
[747]1002
[1021]1003 link=`readlink -f $file`
[862]1004 d=`dirname $file`
1005 if [ ! -e "$link" -a ! -e "$d/$link" ]; then
1006 echo "Problem with dead link on $file -> $link" >> $LOGFILE
1007 fi
[1230]1008 if [ -h "$d" ]; then
1009 echo "$link $d"
[860]1010 else
[1230]1011 echo "$link"
1012 fi
[860]1013}
1014
[925]1015
[747]1016LocateFile() {
1017 local i path fname_to_find location output resolved tmp stub cache_id loclist
1018 fname_to_find="$1"
1019 if echo "$fname_to_find" | grep -x "/.*" ; then
[859]1020 output="$fname_to_find"
[860]1021 if [ -h "$output" ] ; then
1022 output="`ReadAllLink $output` $output"
1023 fi
[859]1024 echo "$output"
1025 return 0
[747]1026 fi
1027 output=""
[884]1028 #for path in /etc /usr /usr/bin /usr/sbin /bin /usr/X11R6/bin /sbin /usr/local/bin /usr/local/sbin /usr/lib /usr/lib64 /lib /lib64 /usr/local/lib /usr/local/lib64 /usr/X11R6/lib /usr/X11R6/lib64 `find /usr/lib64 /lib64 /usr/local/lib64 /usr/X11R6/lib64 -type d` ; do
1029 for path in /etc /usr /usr/bin /usr/sbin /bin /usr/X11R6/bin /sbin /usr/local/bin /usr/local/sbin /usr/lib /usr/lib64 /usr/lib64/* /lib /lib64 /lib64/* /usr/local/lib /usr/local/lib64 /usr/local/lib64/* /usr/X11R6/lib /usr/X11R6/lib64 /usr/X11R6/lib64/* ; do
1030 [ ! -d "$path" ] && continue
[860]1031 for location in "$path/$fname_to_find" ; do
[859]1032 [ ! -e "$location" ] && continue
1033 output="$location $output"
[860]1034 if [ -h "$location" ] ; then
[861]1035 output="`ReadAllLink $location` $output"
[860]1036 fi
[859]1037 done
[747]1038 done
1039 if [ "$output" = "" ] ; then
[860]1040 return 1
[747]1041 fi
1042 echo "$output"
1043 return 0
1044}
1045
1046
1047LogIt() {
1048 if [ -e /dev/stderr ] ; then
[925]1049 echo -e "$1" >> /dev/stderr
[747]1050 elif [ -e /usr/bin/logger ] ; then
[925]1051 /usr/bin/logger -s $1
[747]1052 fi
[965]1053 echo -e "$1" >> $LOGFILE
[747]1054}
1055
1056
1057# Called by TurnTgzIntoRdz, to make /tmp/mondo-restore.cfg
1058MakeMondoConfigFile() {
1059 local outfile use_lzo use_comp use_star
1060 outfile=$1
1061 > $outfile
1062 [ "$TAPESIZE" ] && echo "media-size $TAPESIZE" >> $outfile
1063 [ "$TAPEDEV" ] && echo "media-dev $TAPEDEV" >> $outfile
1064 [ "$FILES_IN_FILELIST" ] && echo "files-in-filelist $FILES_IN_FILELIST" >> $outfile
1065 [ "$LAST_FILELIST_NUMBER" ] && echo "last-filelist-number $LAST_FILELIST_NUMBER" >> $outfile
1066 [ "$INTERNAL_TAPE_BLOCK_SIZE" ] && echo "internal-tape-block-size $INTERNAL_TAPE_BLOCK_SIZE" >> $outfile
1067 use_lzo=$USE_LZO; [ "$use_lzo" = "" ] && use_lzo="no"
[998]1068 use_gzip=$USE_GZIP; [ "$use_gzip" = "" ] && use_gzip="no"
[747]1069 use_comp=$USE_COMP; [ "$use_comp" = "" ] && use_comp="yes"
1070 use_star=$USE_STAR; [ "$use_star" = "" ] && use_star="no"
1071 echo "use-lzo $use_lzo" >> $outfile
[998]1072 echo "use-gzip $use_gzip" >> $outfile
[747]1073 echo "use-star $use_star" >> $outfile
1074 echo "use-comp $use_comp" >> $outfile
1075 echo "datestamp `date`" >> $outfile
1076 [ "$ESTIMATED_TOTAL_NOOF_SLICES" ] && echo "total-slices $ESTIMATED_TOTAL_NOOF_SLICES" >> $outfile
[940]1077 AddFileToCfgIfExists $MINDI_TMP/NFS-CLIENT-IPADDR nfs-client-ipaddr $outfile
1078 AddFileToCfgIfExists $MINDI_TMP/NFS-CLIENT-NETMASK nfs-client-netmask $outfile
1079 AddFileToCfgIfExists $MINDI_TMP/NFS-CLIENT-BROADCAST nfs-client-broadcast $outfile
1080 AddFileToCfgIfExists $MINDI_TMP/NFS-CLIENT-DEFGW nfs-client-defgw $outfile
1081 AddFileToCfgIfExists $MINDI_TMP/NFS-SERVER-MOUNT nfs-server-mount $outfile
1082 AddFileToCfgIfExists $MINDI_TMP/NFS-SERVER-PATH nfs-server-path $outfile
1083 AddFileToCfgIfExists $MINDI_TMP/NFS-DEV nfs-dev $outfile
1084 AddFileToCfgIfExists $MINDI_TMP/NFS-SERVER-IPADDR nfs-server-ipaddr $outfile
1085 AddFileToCfgIfExists $MINDI_TMP/ISO-DEV iso-dev $outfile
1086 AddFileToCfgIfExists $MINDI_TMP/ISO-MNT iso-mnt $outfile
1087 AddFileToCfgIfExists $MINDI_TMP/ISO-PREFIX iso-prefix $outfile
1088 AddFileToCfgIfExists $MINDI_TMP/ISODIR isodir $outfile
1089 AddFileToCfgIfExists $MINDI_TMP/BOOTLOADER.DEVICE bootloader.device $outfile
1090 AddFileToCfgIfExists $MINDI_TMP/BOOTLOADER.NAME bootloader.name $outfile
1091 AddFileToCfgIfExists $MINDI_TMP/KEYMAP-LIVES-HERE keymap-lives-here $outfile
1092 AddFileToCfgIfExists $MINDI_TMP/TAPEDEV-HAS-DATA-DISKS tapedev-has-data-disks $outfile
1093 AddFileToCfgIfExists $MINDI_TMP/BACKUP-MEDIA-TYPE backup-media-type $outfile
1094 AddFileToCfgIfExists $MINDI_TMP/DIFFERENTIAL differential $outfile
[949]1095 AddFileToCfgIfExists $MINDI_TMP/ACL acl $outfile
1096 AddFileToCfgIfExists $MINDI_TMP/XATTR xattr $outfile
[747]1097}
1098
1099
1100MakeModuleLoadingScript() {
1101 local module fname params modpath kver outerloop i modpaths kver searchpath list_to_echo j
1102 tmpmodprobe_flag=$1
1103 outfile=$2
1104 > $outfile || Die "Cannot create empty $outfile"
1105 echo -en "#\041/bin/sh\n\n" >> $outfile
1106 echo "echo -en \"Loading your modules...\"" >> $outfile
1107 if [ "$YOUR_KERNEL_SUCKS" ] ; then
1108 kver=$FAILSAFE_KVER
[940]1109 cd $MINDI_TMP
[747]1110 searchpath=lib/modules/$kver
1111 else
1112###
1113### Sq-Modification ... Use kernelname for module search path if specified
1114###
1115 #kver=`uname -r`
1116 if [ "${kernelname}" != "" ]
1117 then
[925]1118 kver=${kernelname}
[747]1119 else
[925]1120 kver=`uname -r`
[747]1121 fi
1122###
1123### Sq-Modification end
1124###
1125 searchpath=/lib/modules/$kver
1126 fi
1127
1128 echo -en "for outerloop in 1 2 3 4 5 ; do\necho -en \".\"\n" >> $outfile
[1230]1129 # BERLIOS: That code is duplicated - Should be done once only
[1399]1130 list_to_echo="$MODULES"
[1230]1131 # Remove unwanted modules from list
1132 for i in $DENY_MODS; do
1133 list_to_echo=`echo ${list_to_echo} | tr ' ' '\n' | grep -Ev "^${i}$" | tr '\n' ' '`
1134 done
[925]1135
[747]1136 # Make temporary modprobe.conf file if we are told so
[1342]1137 if [ "$tmpmodprobe_flag" = "Y" ] ; then
[940]1138 infile="$MINDI_TMP/modprobe.conf.mindi"
[747]1139 find /etc/modprobe.d -maxdepth 1 -name "*" -xtype f -print0 | xargs -0 cat > $infile
1140 else
1141 infile="/etc/modules.conf"
1142 fi
1143 for module in $list_to_echo $EXTRA_MODS ; do
1144 params=`sed -n "s/^options \\+$module \\+//p" $infile`
1145 modpaths=`FindSpecificModuleInPath $searchpath $module`
1146 for i in $modpaths ; do
1147 echo "MyInsmod $i $params > /dev/null 2> /dev/null" \
1148 | tr '.' '#' \
1149 | sed s/#o#gz/#o/ \
1150 | sed s/#o#gz/#o/ \
1151 | sed s/#ko#gz/#ko/ \
1152 | sed s/#ko#gz/#ko/ \
1153 | tr '#' '.' >> $outfile
1154 echo -en "$i added to module list.\n" >> $LOGFILE
1155 done
1156 done
1157 echo -en "done\n" >> $outfile
1158 echo "echo \"Done.\"" >> $outfile
1159 chmod +x $outfile
1160 cd /
1161 # Remove temporary modprobe.conf file if we have created one
[1342]1162 if [ "$tmpmodprobe_flag" = "Y" ] ; then
[747]1163 rm -f $infile
1164 fi
1165}
1166
1167
1168MakeMountlist() {
1169 local scratchdir mountlist all_partitions current_partition \
1170partition_size partition_format outstring partition_number \
1171partition_mountpt c_p lwm_info psz lvm_dev unofficial_outstring \
1172absolute_partition old_partition_fmt current_lvolume
1173
[967]1174 echo "Your raw fstab file looks like this:" >> $LOGFILE
1175 echo "------------------------------------" >> $LOGFILE
[747]1176 cat $MY_FSTAB >> $LOGFILE
[967]1177 echo "Your mountlist will look like this:" | tee -a $LOGFILE
1178 echo "-----------------------------------" >> $LOGFILE
[747]1179
1180# scratchdir, mountlist(OUT)
[940]1181 scratchdir=$MINDI_TMP
[747]1182 mountlist=$1
1183
1184# NB: partition = device
1185# NB: mountpt = where the device is mounted
1186
1187 [ -e "$MY_FSTAB" ] || Die "Cannot find your fstab file ($MY_FSTAB)"
1188
1189 rm -f $mountlist
1190 mkdir -p $mountlist
1191 rm -Rf $mountlist
1192 > $mountlist
1193 echo -en "\rHang on...\r"
1194 all_partitions=""
1195
1196 if [ $LVM != "false" ]; then
1197 echo -en "\rAnalyzing LVM...\r"
[968]1198 $MINDI_LIB/analyze-my-lvm > $MINDI_TMP/lvm.res
[971]1199 if [ $? -ne 0 ]; then
[963]1200 LVM="false"
1201 fi
[968]1202 all_partitions=`cat $MINDI_TMP/lvm.res | grep -F ">>>" | cut -d' ' -f2-32`
[747]1203 fi
1204 all_partitions="$all_partitions `ListAllPartitions 2> /dev/null`"
1205# echo "all partitions = $all_partitions" > /dev/stderr
1206 for i in $IMAGE_DEVS ; do
1207 mount | grep -F "$i " > /dev/null 2> /dev/null && Die "Sorry, $i is already mounted! CANNOT DO IMAGEDEV on it if it's mounted."
1208 done
1209 [ "$IMAGE_DEVS" != "" ] && all_partitions="`echo "$all_partitions $IMAGE_DEVS" | tr ' ' '\n' | sort -u | tr '\n ' ' '`"
[976]1210 printf " %-15s %-15s %-15s %-15s %-15s %-15s\n" DEVICE MOUNTPOINT FORMAT "SIZE (MB)" LABEL UUID | tee -a $LOGFILE
[747]1211 useless_dev="/dev/floppy /dev/fd0h1440 /dev/fd0H1440 /dev/cdrom /dev/cdrom/cdrom /dev/cdrom/cdrom1 /dev/cdrom/cdrom2 /dev/cdrom0 /dev/cdrom1 /dev/cdrom2 /dev/cdrom3 /dev/cdrw /dev/scd /dev/ram :/ /dev/sr0 /dev/sr1 /dev/cdrom1"
1212 for c_p in $all_partitions ; do
1213 [ "`echo "$useless_dev" | grep -F "$c_p"`" != "" ] || [ "`echo "$c_p" | grep ":"`" != "" ] && continue
1214 [ "`echo "$c_p" | grep -x "/dev/cdroms.*"`" ] && continue
1215 if [ -h "$c_p" ] && [ "`echo "$c_p" | grep -F "/dev/hd"`" = "" ] && [ "`echo "$c_p" | grep -F "/dev/sd"`" = "" ] && [ "`echo "$c_p" | grep -F "/dev/md"`" = "" ] ; then
[861]1216 current_partition=`readlink -f $c_p`
[747]1217 [ "`echo "$current_partition" | grep -F "/dev/mapper"`" != "" ] && current_partition="$c_p"
1218 [ "`echo "$useless_dev" | grep -F "$current_partition"`" ] && continue
1219 else
1220 current_partition="$c_p"
1221 fi
1222 [ "$c_p" = "none" ] && continue
1223 redhat_label=""
[957]1224 uuid=""
[861]1225 absolute_partition=`readlink -f $c_p`
[747]1226 partition_mountpt=`tr -s '\t' ' ' < $MY_FSTAB | /bin/grep -w "$current_partition" | /bin/grep -vx " *#.*" | $AWK '{print $2}' | head -n1`
1227
1228 # Detects noauto partitions not mounted and exclude them
1229 partition_option=`tr -s '\t' ' ' < $MY_FSTAB | /bin/grep -w "$current_partition" | /bin/grep -vx " *#.*" | $AWK '{print $4}' | head -n1`
1230 if [ "`echo "$partition_option" | grep -i noauto`" != "" ] && [ "`mount | grep -w "$partition_mountpt"`" = "" ] ; then
1231 continue
1232 fi
1233
1234 # This part tries to retrieve the correct device from a LABEL line in /etc/fstab
1235 # current_partition contains only first column of /etc/fstab
1236 if [ "`echo "$current_partition" | /bin/grep -i "LABEL="`" != "" ]; then
1237 str_to_find_fmt_with=$current_partition
[980]1238 redhat_label=`echo "$current_partition" | cut -d'=' -f2`
[747]1239 actual_dev=""
[853]1240
1241 # 1st try, findfs - the RHEL way of finding labels and their partitions
1242 if [ -x "/sbin/findfs" ]; then
[855]1243 actual_dev=`/sbin/findfs LABEL=${redhat_label} 2> /dev/null`
[853]1244 fi
[747]1245
[853]1246 # 2nd try : blkid, the good way for all LABEL except swap
1247 if [ "x$actual_dev" = "x" -a -x "/sbin/blkid" ]; then
[980]1248 actual_dev=`/sbin/blkid | /bin/grep "$redhat_label" | grep LABEL= | cut -d':' -f1`
[747]1249 # For LVM FS it will give a /dev/dm-# which should then be converted
[748]1250 if [ $LVM = "v2" ] && [ "`echo $actual_dev | grep '/dev/dm'`" ]; then
[963]1251 major=`/bin/ls -l $actual_dev | $AWK '{print $5}'`
1252 minor=`/bin/ls -l $actual_dev | $AWK '{print $6}'`
[747]1253 for dev in `ls /dev/mapper/*`; do
[963]1254 major1=`/bin/ls -l $dev | $AWK '{print $5}'`
1255 minor1=`/bin/ls -l $dev | $AWK '{print $6}'`
[747]1256 if [ $major1 = $major ] && [ $minor1 = $minor ]; then
[963]1257 actual_dev=`/bin/ls -l $dev | $AWK '{print $10}'`
[747]1258 break
1259 fi
1260 done
1261 fi
1262 fi
1263
[853]1264 # 3rd try, which works on a standard partition (ext2/3), but not on swap
[747]1265 # For LVM gives a /dev/mapper entry
1266 if [ "x$actual_dev" = "x" ]; then
[980]1267 actual_dev=`/bin/mount -l | /bin/grep "\[$redhat_label\]" | cut -d' ' -f1`
[747]1268 fi
1269
[853]1270 # 4th try, with vol_id
[747]1271 # SWAP only
1272 if [ "x$actual_dev" = "x" -a -x "/sbin/vol_id" ]; then
[963]1273 list_swaps=`cat /proc/swaps | /bin/grep "/dev/" | $AWK '{ print $1 }' `
[747]1274 for dev_swap in $list_swaps ; do
1275 dev_exists=`/sbin/vol_id $dev_swap | /bin/grep "$redhat_label"`
1276 if [ "x$dev_exists" != "x" ]; then
1277 actual_dev=$dev_swap
1278 break;
1279 fi
1280 done
1281 fi
1282
[853]1283 # 5th try : pre-formated LABEL. Format is : LABEL=SWAP-mydevice or SW-mydevice. e.g. : LABEL=SWAP-hda5
[789]1284 # LABEL=SW-cciss/c0d0p3 (RDP)
[853]1285 # or could be a string that isn't a complete device name (eg. LABEL =SWAP-cciss/c0d0p)
[747]1286 # SWAP only
[789]1287 if [ "x$actual_dev" = "x" -a _"`echo $current_partition | /bin/grep -iE 'LABEL=SWAP|LABEL=SW-'`" != _"" ]; then
[853]1288 for try_dev in `tail +2 /proc/swaps | cut -d' ' -f1`
1289 do
1290 # Location of the swap label for kernel 2.6
[1009]1291 try_dev_label=`dd bs=1 count=16 skip=1052 if=$try_dev 2> /dev/null`
[853]1292 if [ "x$try_dev_label" = "x$redhat_label" ]; then
[855]1293 actual_dev=$try_dev
[853]1294 fi
1295 done
[747]1296 fi
[1008]1297
1298 # Check if one of all those tries has known success
1299 if [ "x$actual_dev" != "x" ]; then
1300 current_partition=$actual_dev
1301 else
1302 Die "Your system uses a LABEL partition ($current_partition), but you lack the tool to support it.\nPlease replace labels with their correct devices in /etc/fstab or install findfs|blkid|vol_id"
1303 fi
[957]1304 # This part tries to retrieve the correct device from a UUID line in /etc/fstab
1305 # current_partition contains only first column of /etc/fstab
[1009]1306 elif [ "`echo "$current_partition" | /bin/grep -i "UUID="`" != "" ]; then
[957]1307 str_to_find_fmt_with=$current_partition
[980]1308 uuid=`echo "$current_partition" | cut -d'=' -f2`
[957]1309 actual_dev=""
1310
1311 # 1st try, findfs - the RHEL way of finding labels and their partitions
1312 if [ -x "/sbin/findfs" ]; then
1313 actual_dev=`/sbin/findfs UUID=${uuid} 2> /dev/null`
1314 fi
1315
1316 # 2nd try : blkid, the good way for all LABEL except swap
1317 if [ "x$actual_dev" = "x" -a -x "/sbin/blkid" ]; then
[980]1318 actual_dev=`/sbin/blkid | /bin/grep "$uuid" | grep UUID= | cut -d':' -f1`
[957]1319 # For LVM FS it will give a /dev/dm-# which should then be converted
1320 if [ $LVM = "v2" ] && [ "`echo $actual_dev | grep '/dev/dm'`" ]; then
[963]1321 major=`/bin/ls -l $actual_dev | $AWK '{print $5}'`
1322 minor=`/bin/ls -l $actual_dev | $AWK '{print $6}'`
[957]1323 for dev in `ls /dev/mapper/*`; do
[963]1324 major1=`/bin/ls -l $dev | $AWK '{print $5}'`
1325 minor1=`/bin/ls -l $dev | $AWK '{print $6}'`
[957]1326 if [ $major1 = $major ] && [ $minor1 = $minor ]; then
[963]1327 actual_dev=`/bin/ls -l $dev | $AWK '{print $10}'`
[957]1328 break
1329 fi
1330 done
1331 fi
1332 fi
1333
1334 # 3th try, with vol_id
1335 if [ "x$actual_dev" = "x" -a -x "/sbin/vol_id" ]; then
[963]1336 list_dev=`mount | /bin/grep -E '^/' | $AWK '{ print $1 }' `
[957]1337 for dev in $list_dev ; do
1338 dev_exists=`/sbin/vol_id $dev | /bin/grep "$uuid"`
1339 if [ "x$dev_exists" != "x" ]; then
1340 actual_dev=$dev
1341 break;
1342 fi
1343 done
1344 fi
1345
[747]1346 # Check if one of all those tries has known success
1347 if [ "x$actual_dev" != "x" ]; then
1348 current_partition=$actual_dev
1349 else
[1315]1350 Die "Your system uses a UUID partition ($current_partition), but you lack the tool to support it.\nPlease replace labels with their correct devices in $MY_FSTAB or install findfs|blkid|vol_id"
[747]1351 fi
1352 else
1353 str_to_find_fmt_with=$current_partition
1354 fi
1355
1356 partition_format=`$AWK '$1 == "'"$str_to_find_fmt_with"'" {print $3}' $MY_FSTAB`
1357 # Some distributions such as Debian do not put /dev/<VG>/<LV> in fstab
1358 # for LVM partitions but use /dev/mapper/<VG>-<LV> instead. Fortunately,
1359 # the former is then a link to the latter, so we test whether
1360 # $current_partition is actually such a link or not and set
[755]1361 # $current_lvolume accordingly. On Debian you may find more than one answer
1362 # so we remove the one corresponding to /dev/.static
1363 # On RedHat even if the device name is different (/dev/mapper/<VG><LV>), the
1364 # principle is the same and we need to find the link to it as well.
1365 # Note that $current_lvolume may well be an
[747]1366 # ordinary device. It is just to make sure that we feed the right value
1367 # into any of the LVM tools if possible.
1368
1369 current_lvolume="$current_partition"
[763]1370 if [ $LVM = "v2" ] && [ "`echo $current_partition | grep -E '^/dev/mapper/'`" ]; then
[755]1371 # .static dir are a Debian specificity
[763]1372 current_lvolume="`find /dev -lname "$current_partition" | grep -Ev '^/dev/\.static/'`"
[755]1373 echo $current_lvolume | grep -q ' '
[784]1374 if [ $? -eq 0 ]; then
[755]1375 echo "WARNING: Multiple Logical Volumes found. Report to dev team" >> $LOGFILE
1376 fi
[747]1377 fi
1378 #
1379 # End of LVM device style variation code (other than $current_lvolume).
1380
[745]1381 if [ $LVM != "false" ] && [ "`$LVMCMD lvdisplay $current_lvolume 2> /dev/null`" ]; then
1382 # Size computed via LVM not directly
[747]1383 partition_size="lvm"
1384 else
1385 partition_size=`SizeOfPartition $current_partition`
1386 [ "`echo "$current_partition" | grep "[0-9]"`" = "" ] && continue
1387 [ "`echo "$current_partition" | grep -c "^/"`" -ne "1" ] && continue
1388 if [ "$partition_format" = "swap" ] || [ "$partition_mountpt" = "swap" ] ; then
1389 partition_size=`grep -Fv "Priority" /proc/swaps | tr -s '\t' ' ' | grep -F "$current_partition" | $AWK '{print $3}'`
1390 [ "$partition_mountpt" != "swap" ] && partition_mountpt="swap"
1391 [ "$partition_format" != "swap" ] && partition_format="swap"
1392 if [ "$partition_size" = "" ] ; then
1393 totalsize=0
1394 items=0
1395 for i in `tr -s ' ' '\t' < /proc/swaps | grep -Fv "Filename" | cut -f3` ; do
1396 totalsize=$(($totalsize+$i))
1397 items=$(($items+1))
1398 done
1399 [ "$items" -gt "0" ] && partition_size=$(($totalsize/$items)) || partition_size=0
1400 [ "$partition_size" -lt "125000" ] && partition_size=125000
1401 echo "I'm guessing $c_p is $(($partition_size/1024))MB" >> $LOGFILE
1402 fi
1403 fi
1404 fi
1405 [ "$partition_mountpt" = "swap" ] && partition_format="swap"
1406 [ "$partition_format" = "swap" ] && partition_mountpt="swap"
1407 if [ "$partition_mountpt" = "" ] ; then
1408 if [ "`$LVMCMD pvdisplay $current_lvolume 2> /dev/null`" != "" ] ; then
1409 if [ "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
1410 partition_mountpt="raid"
1411 partition_format="raid"
1412 else
1413 partition_mountpt="lvm"
1414 partition_format="lvm"
1415 fi
1416 fi
1417 fi
1418 psz=$partition_size
1419 echo "Examining $current_partition (mount=$partition_mountpt fmt=$partition_format psz=$psz)" >> $LOGFILE
1420 [ "$psz" != "lvm" ] && psz=$(($psz/1024))
1421 if [ "`echo " $IMAGE_DEVS " | grep -F " $current_partition "`" != "" ] ; then
1422 partition_mountpt="image"
1423 old_partition_fmt=$partition_format
1424 partition_format="`$FDISK -l 2>> $LOGFILE | tr '*' ' ' | tr '+' ' ' | tr -s ' ' '\t' | grep -w "$absolute_partition" | cut -f5`"
1425 partition_size=$(($partition_size+1)); # just in case
1426 if [ "$partition_format" = "Linux" ] ; then
1427 echo "Are you imaging a mounted swap partition? Silly..." >> $LOGFILE
1428 echo "Reverting format from $old_partition_fmt to $partition_format" >> $LOGFILE
1429 partition_format=$old_partition_fmt
1430 fi
1431 fi
1432 if [ "$EXCLUDE_DEVS" ] && [ "`echo " $EXCLUDE_DEVS " | grep -F " $current_partition "`" ] || [ "`echo " $EXCLUDE_DEVS " | grep " $current_partition "`" ] ; then
1433 echo "Excluding $current_partition from mountlist" >> $LOGFILE
1434 continue
1435 fi
1436 if [ ! "$partition_mountpt" ] ; then
[965]1437 echo "------- $FDISK -l $qq log ------------" >> $LOGFILE
[747]1438 for qq in "" `find /dev/ida/c*d* ! -name '*p*'` ; do
1439 partition_format=`$FDISK -l $qq 2>> $LOGFILE | grep -w "$c_p" | sed 's/12/|/' | tr -s '\t' ' ' | cut -d'|' -f2 | cut -d' ' -f2-9`
1440 [ "$partition_format" ] && break
1441 done
[965]1442 echo "------- $FDISK log end ------------" >> $LOGFILE
[747]1443 if [ "$partition_format" = "Compaq diagnostics" ] ; then
1444 partition_format="compaq"
1445 elif [ ! "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
[963]1446 LogIt "Unable to find mountpoint of $current_partition - ignoring"
[747]1447 continue
1448 fi
1449 fi
1450 partition_format="`echo "$partition_format" | cut -d',' -f1`"; # in case user has ext3,ext2 or something dumb like that
[963]1451 [ "$partition_format" = "auto" ] && partition_format="`mount | grep -w $current_partition | $AWK '{print$5;}'`"; # in case user uses 'auto' (dumb!)
[976]1452 unofficial_outstring=`printf "\t%-15s %-15s %-15s %7s %-15s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label" $uuid`
[747]1453 if [ "$current_partition" = "" ] ; then
1454 echo "Unknown partition (outstring = $unofficial_outstring)" >> $LOGFILE
1455 elif [ "$partition_mountpt" = "" ] && [ -f "/etc/raidtab" ] ; then
1456 if [ "`grep -F device /etc/raidtab 2>/dev/null | grep -F $current_partition`" ] ; then
1457 partition_mountpt=raid
1458 partition_format=raid
[976]1459 printf "\t%-15s %-15s %-15s %7s %-15s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label" $uuid | tee -a $LOGFILE
1460 printf "%s %s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" $uuid >> $mountlist
[747]1461 else
1462 echo "Unknown mountpoint (outstring = $unofficial_outstring)" >> $LOGFILE
1463 fi
1464 elif [ "$partition_format" = "" ] ; then
1465 echo "Unknown format (outstring = $unofficial_outstring)" >> $LOGFILE
1466 elif [ "$partition_size" = "" ] ; then
1467 echo "Unknown partition size (outstring = $unofficial_outstring)" >> $LOGFILE
1468 elif [ "$partition_mountpt" = "/proc" ] || [ "$partition_mountpt" = "/dev/pts" ] ; then
1469 continue
1470 else
1471 if [ "$partition_format" = "dos" ] || [ "$partition_format" = "msdos" ] ; then
1472 echo "Stupid bastard..." >> $LOGFILE
1473 partition_format="vfat"
1474 fi
[976]1475 printf "\t%-15s %-15s %-15s %7s %-15s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label" $uuid | tee -a $LOGFILE
1476 printf "%s %s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" $uuid >> $mountlist
[747]1477 fi
1478 done
1479}
1480
1481
1482MakeSureNumberIsInteger() {
1483 res=`echo "$1" | tr -s '\-[0-9]' ' '`
1484 if [ "$res" != " " ] && [ "$res" != "" ] ; then
1485 echo "result = '$res'"
1486 Die "$1 should be an integer"
1487 fi
1488}
1489
1490
1491MakeSyslinuxMessageFile() {
1492 mkdir -p $1
1493 rmdir $1
1494 echo -en " " > $1
1495 if [ "`grep -Fi "debian" /etc/issue.net 2> /dev/null`" ] ; then
1496 sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cut -d ' ' -f 3 /etc/issue.net` `hostname`"% | sed s/KKKKK/"Kernel `uname -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ >> $1.tmp
1497 else
1498 sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`grep -i "linux" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`grep -i "kernel" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' '\\r' 'on' 'an' '\/' '`uname -r`' 'on' 'an' '`uname -m`/ >> $1.tmp
1499 fi
1500 sed s/%r/"`uname -r`"/ $1.tmp | sed s/%t/"`hostname`"/ > $1
1501 rm -f $1.tmp
1502 if [ "$CDRECOVERY" != "yes" ] ; then
[940]1503 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[747]1504 echo -en "Press <enter> to continue.\n" >> $1
[940]1505 elif [ ! "$MINDI_TMP" ] ; then
[747]1506 echo -en "FYI, this is _not_ a Mondo Rescue CD.\n" >> $1
1507 if [ -e "$MINDI_LIB/memtest.img" ] ; then
1508 echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n" >> $1
1509 fi
1510 else
1511 echo -en "$BOOT_MEDIA_MESSAGE" >> $1
1512 fi
1513 else
1514 echo -en " \
1515To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
1516CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n" >> $1
1517 fi
1518}
1519
1520
1521MoveHyperlinkSensibly() {
1522 local filename minidir_root resides_on_diskno noof_disks old_diskno d old_pwd
1523 filename=$1
1524 minidir_root=$2
1525 resides_on_diskno=$3
1526 noof_disks=$4
1527
1528 [ -h "$minidir_root/$resides_on_diskno/$filename" ] || Die "$filename isn't a softlink (or doesn't exist): how can I move it sensibly?"
1529
1530 old_diskno=$resides_on_diskno
1531 d=1
1532 while [ "$d" -le "$noof_disks" ] ; do
1533 if [ "$d" -ne "$old_diskno" ] ; then
1534 old_pwd=`pwd`
1535 cd $minidir_root/$old_diskno
[963]1536 cp --parents -Rdf $filename $minidir_root/$d/ 2>> $LOGFILE || Die "Can't move $filename (sensibly) from $old_diskno to $d"
[747]1537 rm -f $filename
1538 cd $old_pwd
1539 fi
1540# when the softlink is resolvable, our work here is done
1541 [ -e "$minidir_root/$d/$filename" ] && return 0
1542 old_diskno=$d
1543 d=$(($d+1))
1544 done
1545 return 1
1546}
1547
1548
1549
1550OfferToCopyImagesToDisks() {
1551 local imagesdir i imagename dev count boot_dev data_dev
1552 imagesdir=$1
1553 boot_dev=$2
1554 data_dev=$3
[925]1555
[966]1556 echo -en "Would you like to create boot+data floppy disks now (y/[n]) ?"
[747]1557 read i
1558 [ "$i" != "y" ] && [ "$i" != "Y" ] && return
1559 mount | grep -F /dev/fd > /dev/null && Die "Please unmount your floppies first."
1560 echo "WARNING! THIS WILL ERASE YOUR FLOPPY DISKS."
1561 [ ! -e "$boot_dev" ] && Die "Cannot find $boot_dev - is your Linux distro broken?"
1562 [ ! -e "$data_dev" ] && Die "Cannot find $data_dev - is your Linux distro broken?"
1563 i=`find $imagesdir -type f | grep -F "/mindi-root.1" 2> /dev/null`
[1282]1564 j=`find $imagesdir -type f | grep -F "/mindi-boot" | grep -Ev "2880|$BOOT_SIZE"`
[747]1565 if [ "$i" ] ; then
1566 CopyImageToDisk $j $data_dev "boot disk"
1567 CopyImageToDisk $i $data_dev "root disk"
1568 else
1569 CopyImageToDisk $j $boot_dev "boot/root disk"
1570 fi
1571 count=1
1572 for i in `find $imagesdir | grep -F mindi-data` ; do
1573 CopyImageToDisk $i $data_dev "data disk #$count"
1574 count=$(($count+1))
1575 done
1576}
1577
1578
1579OfferToMakeBootableISO() {
1580 local i old_pwd
[1335]1581 if [ "$PROMPT_MAKE_CD_IMAGE" = "yes" ] && [ _"$MONDO_SHARE" = _"" ] ; then
[966]1582 echo -en "Shall I make a bootable CD image? (y/[n]) "
[747]1583 read i
1584 [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
1585 fi
[940]1586 if [ ! "$MINDI_TMP" ] ; then
[963]1587 LogIt "NB: Mindi's bootable CD always uses isolinux."
1588 LogIt "For a bootable CD w/LILO, please use Mondo."
[747]1589 fi
[940]1590 rm -Rf $MINDI_TMP/iso
1591 mkdir -p $MINDI_TMP/iso/{images,archives,isolinux}
[963]1592 cp -f $1/*.img $1/*.gz $MINDI_TMP/iso/images 2>> $LOGFILE || LogIt "OfferToMakeBootableISO: Cannot copy $i to $MINDI_TMP/iso/images"
[747]1593 old_pwd=`pwd`
[940]1594 cd $MINDI_TMP/iso
[747]1595 echo "mindi_lib = $MINDI_LIB" >> $LOGFILE
1596 for i in memdisk memtest.bin memtest.img ; do
[953]1597 j=$MINDI_LIB/$i
1598 k=$MINDI_TMP/iso/isolinux
1599 if [ -e "$j" ] ; then
[963]1600 LogIt "Copying $j to $k"
[953]1601 cp -f $j $k 2> /dev/null || Die "Failed to copy $j to $k"
1602 cp -f $j $MINDI_TMP 2> /dev/null || Die "Failed to copy $j to $MINDI_TMP"
1603 cp -f $j $MONDO_ROOT 2>> $LOGFILE || Die "Failed to copy $j to $MONDO_ROOT"
1604 fi
[747]1605 done
[940]1606 MakeSyslinuxMessageFile $MINDI_TMP/iso/isolinux/message.txt
[1010]1607 cp $kernelpath $MINDI_TMP/iso/isolinux/vmlinuz 2> /dev/null || Die "Cannot copy vmlinuz ($kernelpath) to mondo root ($MINDI_TMP/iso/isolinux/vmlinuz). Did you run out of disk space?"
1608 cp $kernelpath $MONDO_ROOT/vmlinuz 2> /dev/null || Die "Cannot copy vmlinuz ($kernelpath) to mondo root ($MONDO_ROOT/vmlinuz). Did you run out of disk space?"
[963]1609 cp $MINDI_TMP/mindi.rdz $MINDI_TMP/iso/isolinux/initrd.img 2>> $LOGFILE
[1010]1610 cp $MINDI_TMP/mindi.rdz $MONDO_ROOT/initrd.img 2>> $LOGFILE
[747]1611 [ -e "$iso_cfg_file" ] || Die "FIXME - unable to find $iso_cfg_file - this should never occur"
[940]1612 cd $MINDI_TMP/iso/isolinux
1613 cat $iso_cfg_file | HackSyslinuxFile $ramdisk_size $MINDI_TMP/iso > isolinux.cfg || Die "Cannot copy isolinux.cfg from mindi_home to tmp_root - did you run out of disk space?"
1614 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[747]1615 mv isolinux.cfg isolinux.cfg.old
1616 sed s/interactive/iso/ isolinux.cfg.old > isolinux.cfg
1617 fi
1618 if [ "$ARCH" != "ia64" ] ; then
[953]1619 cp $ISOLINUX isolinux.bin 2> /dev/null || Die "Cannot copy isolinux.bin ($ISOLINUX) to tmp_root - did you run out of disk space?"
[963]1620 cp $ISOLINUX ../ 2>> $LOGFILE
[747]1621 fi
[940]1622 cd $MINDI_TMP/iso
[747]1623 if [ "$ARCH" != "ia64" ] ; then
[953]1624 cp -f $MINDI_TMP/iso/isolinux/{isolinux.cfg,initrd.img,vmlinuz,isolinux.bin,message.txt} $MONDO_ROOT 2> /dev/null || Die "Cannot copy core files to ramdisk for boot disk. Did you run out of disk space?"
[747]1625 fi
[963]1626 [ "$MONDO_SHARE" ] && cp -f $MONDO_SHARE/autorun . 2>> $LOGFILE
[747]1627 if [ "$ARCH" != "ia64" ] ; then
[940]1628 mkisofs -U -J -r -o $CACHE_LOC/mindi.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table . > /dev/null 2> $MINDI_TMP/mkisofs.log
[747]1629 else
[1282]1630 mkisofs -J -r -o $CACHE_LOC/mindi.iso -b images/mindi-bootroot.$BOOT_SIZE.img -c isolinux/boot.cat -no-emul-boot . > /dev/null 2> $MINDI_TMP/mkisofs.log
[747]1631 fi
1632 if [ "$?" -ne "0" ] ; then
[925]1633 echo "----------- mkisofs's errors --------------" >> $LOGFILE
[940]1634 cat $MINDI_TMP/mkisofs.log >> $LOGFILE
[925]1635 echo "mkisofs returned the following errors:-"
[940]1636 cat $MINDI_TMP/mkisofs.log
[963]1637 LogIt "Failed to create ISO image."
[747]1638 else
[925]1639 echo "Created bootable ISO image at $CACHE_LOC/mindi.iso" >> $LOGFILE
[747]1640 fi
[940]1641 rm -f $MINDI_TMP/mkisofs.log
[747]1642 cd $old_pwd
1643}
1644
1645
1646PluralOrNot() {
1647 [ "$1" -gt "1" ] && echo -en "s"
1648}
1649
1650
1651MakeMessageFile() {
1652 local disksize
1653 disksize=$1
1654 if [ "`grep -Fi "debian" /etc/issue.net 2> /dev/null`" ] ; then
1655 sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cut -d ' ' -f 3 /etc/issue.net` `hostname`"% | sed s/KKKKK/"Kernel `uname -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/
1656 else
1657 sed s/ZZZZZ/$MINDI_VERSION/ $MINDI_LIB/msg-txt | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`grep -i "linux" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`grep -i "kernel" /etc/issue.net | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' 'r' 'on' 'an' 'm/' '`uname -r`' 'on' 'an' '`uname -m`/
1658 fi
1659 if [ "$disksize" -gt "2880" ] ; then
[1335]1660 if [ _"$MONDO_SHARE" != _"" ] ; then
[925]1661 if [ "$CDRECOVERY" != "yes" ] ; then
[940]1662 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[925]1663 echo -en "Press <enter> to continue.\n"
[940]1664 elif [ ! "$MINDI_TMP" ] ; then
[925]1665 echo -en "FYI, this is _not_ a Mondo Rescue CD.\n"
1666 else
1667 echo -en "$BOOT_MEDIA_MESSAGE"
1668 fi
[747]1669 fi
1670 fi
1671 fi
1672 if [ "$CDRECOVERY" = "yes" ] ; then
1673 echo -en "\
1674To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
1675CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n"
1676 fi
1677 echo -en "\n\n\n"
1678}
1679
1680
1681write_full_floppy_of_kernel() {
1682 local mtpt image old_pwd res disksize
1683
1684 res=0
1685 old_pwd=`pwd`
1686 KERN_DISK_MADE=1
1687 disksize=$3
1688 rand1=$RANDOM
1689 rand2=$RANDOM
[940]1690 image=$MINDI_TMP/$rand1.$rand2.img
1691 mtpt=$MINDI_TMP/$rand1.$rand2.mtpt
[963]1692 dd if=/dev/zero of=$image bs=1k count=$disksize &> /dev/null
[964]1693 mke2fs -N 26 -F $image &> /dev/null
[747]1694 mkdir -p $mtpt
1695 mount -o loop $image $mtpt
1696 cd $mtpt
1697 mkdir -p {dev,tmp,boot}
[963]1698 cp -f $1 vmlinuz 2>> $LOGFILE
[747]1699 if [ "$?" -ne "0" ] ; then
[963]1700 LogIt "Failed to copy $1 to ramdisk"
[747]1701 cd $old_pwd
1702 umount $mtpt
1703 rmdir $mtpt
1704 rm $image
1705 return 1
1706 fi
1707
1708 rdev vmlinuz 2,0
1709 rdev -R vmlinuz 0
1710 rdev -r vmlinuz 49152
1711
[963]1712 tar -zxf $MINDI_LIB/dev.tgz || LogIt "Cannot untar dev.tgz"
[1311]1713 # BERLIOS : Useless and generating errors on CentOS ? (losetup miss a param)
[1301]1714 #losetup /dev/loop0 > /dev/null 2> /dev/null
1715 #[ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing 'losetup /dev/loop0 -d'.\nReboot if necessary."
[747]1716 CopyBootBFile $mtpt/boot.b
1717
1718 MakeLiloConfFile $disksize >> bdlilo.conf
1719
1720 chmod 644 bdlilo.conf
1721 MakeMessageFile $disksize > message
1722 lilo -v -C bdlilo.conf -r $mtpt
1723 res=$?
1724
1725 cd $old_pwd
1726 umount $mtpt
1727 mv -f $image $2
1728 rmdir $mtpt
1729
1730 return $res
1731}
1732
1733
1734MakeLiloConfFile() {
1735 local disksize options i ooo
1736 disksize=$1
1737 options=""
[925]1738
1739 if [ "$ARCH" != "ia64" ] ; then
1740 echo -en "boot=/dev/loop0\ndisk=/dev/loop0\n"
1741 fi
1742 if [ "$disksize" -eq "2880" ] ; then
1743 echo -en "bios=0x00\nsectors=36\nheads=2\ncylinders=80\n"
1744 elif [ "$disksize" -eq "1722" ] ; then
1745 echo -en "bios=0x00\nsectors=21\nheads=2\ncylinders=82\n"
1746 elif [ "$disksize" -gt "2880" ] ; then
1747 /bin/true
1748 else
1749 echo -en "bios=0x00\nsectors=18\nheads=2\ncylinders=80\n"
1750 fi
1751 if [ "$ARCH" != "ia64" ] ; then
1752 echo -en "install=/boot.b\nmap=/boot.map\n"
1753 fi
[747]1754 if [ "$CDRECOVERY" = "yes" ] ; then
1755 echo -en "default=RESTORE\n"
[1335]1756 elif [ "$disksize" -gt "2880" ] && [ _"$MONDO_SHARE" != _"" ] ; then
[940]1757 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[747]1758 echo -en "default=iso\n"
1759 else
1760 echo -en "default=interactive\n"
1761 fi
1762 else
1763 echo -en "default=expert\n"
1764 fi
1765
1766 echo -en "prompt\n"
1767 if [ "$ARCH" != "ia64" ] ; then
1768 echo -en "vga=normal\nbackup=/dev/null\nmessage=/message\n"
1769 fi
1770 if [ "$CDRECOVERY" != "yes" ] ; then
[925]1771 echo -en "timeout=300\n"
[747]1772 fi
1773 echo -en "\n"
1774 if [ "$CDRECOVERY" = "yes" ] ; then
[925]1775 options="RESTORE expert"
[747]1776 elif [ "$disksize" -gt "2880" ] ; then
[1335]1777 if [ _"$MONDO_SHARE" != _"" ] ; then
[940]1778 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[747]1779 options="iso"
1780 else
1781 options="interactive expert compare iso nuke isonuke"
1782# hda hdb hdc hdd"
1783 fi
1784 else
1785 options="expert"
[925]1786 fi
[747]1787 else
1788 options="expert"
1789 fi
1790 for i in $options ; do
[925]1791 ooo=$i
1792 [ "$ooo" = "RESTORE" ] && ooo="nuke"
1793 if [ "$ARCH" = "ia64" ] ; then
1794 rootpart="root=/dev/ram0\n\t"
1795 else
1796 rootpart=""
1797 fi
[1230]1798 outstr="image=/vmlinuz\n\tlabel=$i\n\tinitrd=/mindi.rdz\n\t${rootpart}append=\" rw ramdisk=$ramdisksize ramdisk_size=$ramdisksize maxcpus=1 $ooo_mode $ADDITIONAL_BOOT_PARAMS"
[747]1799
[925]1800 outstr=$outstr" $ooo_mode"
1801 outstr=$outstr"\"\n"
1802 if [ "$disksize" = "1440" ] ; then
1803 echo -en "$outstr" | sed s/initrd=.*// | grep -v root=
1804 else
1805 echo -en "$outstr"
1806 fi
[747]1807 done
1808}
1809
1810
1811PrepareBootDiskImage_LILO() {
1812 local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf
1813 imagesdir=$1
1814 disksize=$2
1815 kernelpath=$3
1816 ramdisksize=$4
1817
1818 retval=0
1819 [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
1820 echo -en "Making "$disksize"KB boot disk..."
[940]1821 TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
[747]1822 if [ "$ARCH" != "ia64" ] ; then
[1282]1823 [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "$BOOT_SIZE" ] && Die "PDBI - disksize is $disksize - bad size"
[747]1824 fi
1825 echo -en "..."
1826 imagefile=$imagesdir/mindi-bootroot.$disksize.img
[940]1827 mountpoint=$MINDI_TMP/mountpoint.$$
[747]1828 mkdir -p $mountpoint
1829 dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
1830 if [ "$ARCH" = "ia64" ] ; then
[964]1831 mkdosfs $imagefile >> $LOGFILE 2>> $LOGFILE
1832 t=vfat
[747]1833 else
[964]1834 mke2fs -N 26 -m 0 -F $imagefile >> $LOGFILE 2>> $LOGFILE
1835 t=ext2
[747]1836 fi
[963]1837 mount -t $t -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)"
[964]1838 # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
[747]1839 mkdir -p $mountpoint/etc
1840 if [ "$ARCH" != "ia64" ] ; then
1841 liloconf=$mountpoint/etc/lilo.conf
1842 else
[925]1843 liloconf=$mountpoint/elilo.conf
[747]1844 fi
1845 old_pwd=`pwd`
1846 cd $mountpoint
1847 if [ "$ARCH" != "ia64" ] ; then
[963]1848 tar -zxf $MINDI_LIB/dev.tgz || LogIt "Cannot untar dev.tgz"
[747]1849 fi
1850 cd $old_pwd
[1311]1851 # BERLIOS : Useless and generating errors on CentOS ? (losetup miss a param)
1852 #losetup /dev/loop0 > /dev/null 2> /dev/null
1853 #[ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing 'losetup /dev/loop0 -d'.\nReboot if necessary."
[747]1854 CopyBootBFile $mountpoint/boot.b
1855
1856 MakeLiloConfFile $disksize > $liloconf
1857
[1230]1858 # Copy it so that CD-ROM menu entry is satisfied
1859 if [ "$ARCH" = "ia64" ] ; then
1860 mountefi=0
1861 df -T | grep /boot/efi | grep -q vfat
1862 if [ $? -ne 0 ]; then
1863 mount /boot/efi
1864 if [ $? -ne 0 ]; then
1865 echo "You have to mount your EFI partition when using mindi"
1866 MindiExit -1
1867 fi
1868 mountefi=1
1869 fi
1870 cp /boot/efi/elilo.efi $mountpoint
1871 cp $liloconf $mountpoint/elilo.efi $mountpoint/efi/boot
1872 if [ $mountefi -eq 1 ]; then
1873 umount /boot/efi 2>&1 > /dev/null
1874 fi
1875 fi
1876
[940]1877 echo "Copying $MINDI_TMP/mindi.rdz to $mountpoint..." >> $LOGFILE
1878 cp -f $MINDI_TMP/mindi.rdz $mountpoint 2>> $LOGFILE
[747]1879 if [ "$?" -ne "0" ] ; then
[963]1880 LogIt "Failed to copy $MINDI_TMP/mindi.rdz to $mountpoint"
[940]1881 cat $MINDI_TMP/mtpt.$$ >> $LOGFILE
[963]1882 LogIt "Please unload some of your modules and try again."
[940]1883 rm -f $MINDI_TMP/mtpt.$$
[963]1884 LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)"
[747]1885 retval=$(($retval+1))
1886 fi
1887 MakeMessageFile $disksize > $mountpoint/message
1888
1889 mkdir -p $mountpoint/tmp
[940]1890 cp -f $MINDI_TMP/mondo-restore.cfg $mountpoint/tmp &> /dev/null
[747]1891 if [ -e "$MINDI_LIB/memtest.img" ] ; then
1892 echo -en "image=/memtest.bin\nlabel=memtest\nn" >> $liloconf
1893 echo -en "image=/memdisk\nlabel=memtest\nappend=\"initrd=memtest.img\"\n" >> $liloconf
1894# echo "Yep, this is a multi-function CD" > $mountpoint/MULTIFUNC
1895 fi
1896
[925]1897 # copy the kernel across
[1230]1898 [ "$mountpoint" != "" ] && rm -Rf $mountpoint/lost+found
[747]1899 dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
1900 free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
1901 cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2> /dev/null
1902 if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
[925]1903 echo "Files at mountpoint ($mountpoint) :-" >> $LOGFILE
1904 du -sk $mountpoint/* >> $LOGFILE
1905 echo "--- end of list of files ---" >> $LOGFILE
1906 echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n\
[747]1907Sorry, your kernel is too big for a boot/root floppy.\nI'll try the new boot/root two-disk thingy.\n" >> $LOGFILE
1908 rm -f $mountpoint/vmlinuz
[925]1909 cd $old_pwd
[747]1910 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
[963]1911 rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)"
[925]1912 # losetup /dev/loop0 -d
1913 res=0
[747]1914 write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
[925]1915 res=$(($res+$?))
[963]1916 cp -f $MINDI_TMP/mindi.rdz $imagesdir/mindi-root.1440.img 2>> $LOGFILE
[925]1917 res=$(($res+$?))
1918 rm -f $imagefile
1919 if [ "$res" -ne "0" ]; then
[963]1920 LogIt "WARNING - failed to create 1.44MB boot/root floppies"
[925]1921 rm -f $imagesdir/mindi-*.1440.img
1922 fi
1923 return $res
[747]1924 fi
1925 free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
1926 max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
1927 echo "Free space left on floppy = $free_space KB" >> $LOGFILE
1928 echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
1929# make it bootable
1930 rm -f $mountpoint/zero
[963]1931 [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint 2>> $LOGFILE
[747]1932 if [ "$disksize" -gt "2880" ] && [ ! "$KERN_DISK_MADE" ] ; then
1933 if [ "$ARCH" != "ia64" ] ; then
1934 $LILO_EXE $LILO_OPTIONS -r $mountpoint >> $LOGFILE 2>> $LOGFILE
1935 else
1936 /bin/true
1937 fi
1938 elif [ ! "$KERN_DISK_MADE" ] ; then
1939# 12/28/2001 - if 1.72MB floppy then don't use LILO's optimizations at all
[925]1940 $LILO_EXE -r $mountpoint >> $LOGFILE 2>> $LOGFILE
[747]1941 else
[925]1942 echo "Not running LILO. It's not that kind of disk." >> $LOGFILE
[747]1943 fi
[925]1944
1945 # BERLIOS does not test necessarily what it expects
[747]1946 if [ $? -ne "0" ] ; then
[925]1947 if [ "`grep -F "/tmp/dev.0" $LOGFILE`" ] ; then
[963]1948 LogIt "The '/tmp/dev.0' error is NOT Mindi's fault. It is LILO's."
1949 LogIt "Please reboot your PC as a workaround."
1950 Die "LILO sneezed and Mindi caught a cold. Please read the README / FAQ."
[925]1951 fi
1952 echo "$LILO_EXE -r $mountpoint ...failed."
1953 echo -en "Press ENTER to continue."; read line
[963]1954 LogIt "Cannot run lilo on $mountpoint\nPlease upgrade/downgrade your version of LILO. It has a bug."
[925]1955 retval=$(($retval+1))
[747]1956 fi
[963]1957 cp -f $liloconf $MINDI_TMP/lilo.conf 2>> $LOGFILE
[747]1958 if [ "$ARCH" = "ia64" ] ; then
[963]1959 cp `dirname $kernelpath`/*.efi $mountpoint 2>> $LOGFILE
[747]1960 fi
1961 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
1962 echo -en "..."
[963]1963 rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)"
[747]1964 if [ "$retval" -eq "0" ] ; then
1965 echo -en "...$DONE\r"
1966 if [ "$KERN_DISK_MADE" ] ; then
1967 LogIt "... $disksize KB boot disks were created OK\r"
1968 fi
1969 else
1970 echo -en "...failed\r"
1971 LogIt $disksize"KB boot disk was NOT created\r"
1972 rm -f $imagefile
1973 fi
[963]1974 [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero"
[747]1975 return $retval
1976}
1977
1978
1979PrepareBootDiskImage_SYSLINUX() {
1980 local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage
1981 imagesdir=$1
1982 disksize=$2
1983 kernelpath=$3
1984 ramdisksize=$4
1985 do_boot_root_thingy=""
1986 local retval old_pwd
1987 retval=0
[925]1988
[747]1989 [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
1990 echo -en "Making "$disksize"KB boot disk..."
[940]1991 TurnTgzIntoRdz $MINDI_LIB/rootfs $MINDI_TMP/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
[1282]1992 [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "$BOOT_SIZE" ] && Die "PDBI - disksize is $disksize - bad size"
[747]1993 echo -en "..."
1994 imagefile=$imagesdir/mindi-bootroot.$disksize.img
[940]1995 mountpoint=$MINDI_TMP/mountpoint.$$
[747]1996 mkdir -p $mountpoint
1997# If I format a 1722KB data file & run syslinux on it, the resultant image
1998# won't boot. So, I have formatted a floppy, called syslinux on/to it, and
1999# used 'dd' to copy it to sys-disk.raw (zipped to sys-disk.raw.gz).
2000# If I extract it, mount it, copy my files to it, etc. then the resultant
2001# image _is_ bootable. I don't know why syslinux and/or mkfs.vfat won't
2002# play nicely and I don't care. :) I have worked around the problem. -Hugo, 06/27/2002
2003 if [ "$disksize" = "1722" ] ; then
2004 gzip -dc $MINDI_LIB/sys-disk.raw.gz > $imagefile || Die "Cannot dd blank file"
2005 else
2006 dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
[964]2007 mkfs.vfat $imagefile >> $LOGFILE 2>> $LOGFILE
2008 syslinux $imagefile >> $LOGFILE 2>> $LOGFILE
[747]2009 fi
[963]2010 mount -t vfat -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)"
[925]2011
2012 # copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
[747]2013 old_pwd=`pwd`
2014 MakeSyslinuxMessageFile $mountpoint/message.txt
2015 cd $mountpoint
2016 [ -e "$sys_cfg_file" ] || Die "Obi Wan, word up?"
2017 cat $sys_cfg_file | HackSyslinuxFile $ramdisk_size $mountpoint > syslinux.cfg || Die "Cannot copy syslinux.cfg from mindi_home to tmp_root"
[940]2018 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[747]2019 mv syslinux.cfg syslinux.cfg.orig
2020 sed s/interactive/iso/ syslinux.cfg.orig > syslinux.cfg
2021 fi
2022 cd $old_pwd
[940]2023 echo "Copying $MINDI_TMP/mindi.rdz to $mountpoint/initrd.img..." >> $LOGFILE
2024 cp -f $MINDI_TMP/mindi.rdz $mountpoint/initrd.img 2>> $LOGFILE
[747]2025 if [ "$?" -ne "0" ] ; then
[963]2026 LogIt "Failed to copy $MINDI_TMP/mindi.rdz to $mountpoint"
[940]2027 cat $MINDI_TMP/mtpt.$$ >> $LOGFILE
[963]2028 LogIt "Please unload some of your modules and try again."
[940]2029 rm -f $MINDI_TMP/mtpt.$$
[963]2030 LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)"
[747]2031 retval=$(($retval+1))
2032 fi
2033
2034 mkdir -p $mountpoint/tmp
[940]2035 cp -f $MINDI_TMP/mondo-restore.cfg $mountpoint/tmp &> /dev/null
[747]2036
[925]2037 # copy the kernel across
[1230]2038 [ "$mountpoint" != "" ] && rm -Rf $mountpoint/lost+found
[747]2039 dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
2040 free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
2041 cp -f $kernelpath $mountpoint/vmlinuz &> /dev/null
2042 if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
2043 echo "Files at mountpoint ($mountpoint) :-" >> $LOGFILE
2044 du -sk $mountpoint/* >> $LOGFILE
2045 echo "--- end of list of files ---" >> $LOGFILE
2046 echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n\
2047Sorry, your kernel is too big for a boot/root floppy.\nI'll try the new boot/root two-disk thingy.\n" >> $LOGFILE
2048 rm -f $mountpoint/vmlinuz
2049 cd $old_pwd
2050 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
[963]2051 rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)"
[747]2052
2053 res=0
2054 write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
2055 res=$(($res+$?))
[963]2056 cp -f $MINDI_TMP/mindi.rdz $imagesdir/mindi-root.1440.img 2>> $LOGFILE
[747]2057 res=$(($res+$?))
2058 rm -f $imagefile
2059 if [ "$res" -ne "0" ]; then
[963]2060 LogIt "WARNING - failed to create 1.44MB boot/root floppies"
[747]2061 rm -f $imagesdir/mindi-*.1440.img
2062 fi
2063 return $res
2064 fi
2065 free_space=`df -k -P $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
2066 max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
2067 echo "Free space left on floppy = $free_space KB" >> $LOGFILE
2068 echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
[925]2069
2070 # make it bootable
[747]2071 rm -f $mountpoint/zero
2072 mkdir -p $mountpoint/etc
[963]2073 [ -e "$MINDI_LIB/memdisk" ] && cp -f $MINDI_LIB/memdisk $mountpoint 2>> $LOGFILE
[747]2074 umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
2075 echo -en "..."
[963]2076 rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)"
[747]2077
2078 if [ "$retval" -eq "0" ] ; then
2079 echo -en "...$DONE\r"
2080 if [ "$KERN_DISK_MADE" ] ; then
2081 rm -f $imagefile
2082 LogIt "... $disksize KB boot disks were created OK\r"
2083 fi
2084 else
2085 echo -en "...failed\r"
2086 LogIt $disksize"KB boot disk was NOT created\r"
2087 rm -f $imagefile
2088 fi
[963]2089 [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero"
[747]2090 return $retval
2091}
2092
2093
2094PrepareDataDiskImages() {
2095 local needlist bigdir minidir_root tardir diskdir imagesdir res i j k old_pwd lines
2096
2097 imagesdir=$1
2098 rm -f $imagesdir/mindi-*.img $imagesdir/[0-9]*.tar.gz $imagesdir/mindi.iso
[940]2099 needlist=$MINDI_TMP/what-we-need.txt
2100 bigdir=$MINDI_TMP/bigdir
2101 minidir_root=$MINDI_TMP/minidir
[747]2102 mkdir -p $minidir_root
2103 mkdir -p $bigdir/usr/bin
[940]2104 tardir=$MINDI_TMP/tardir
[747]2105
2106 lines=`grep -vx " *#.*" $MINDI_CONF/deplist.txt | grep -vx "" | wc -l`
2107 cat $MINDI_CONF/deplist.txt | GenerateGiantDependencyList $needlist $lines
2108 res=$?
2109 if [ "$YOUR_KERNEL_SUCKS" ]; then
[925]2110 pwd=`pwd`
[940]2111 cd $MINDI_TMP
[747]2112 for i in `ListKernelModulePaths | HackPathsToFailsafe` ; do
[963]2113 cp --parents -pRdf ./$i $bigdir 2>> $LOGFILE || Die "PDDI can't cp $i->$bigdir"
[925]2114 if [ "`du -sk $i | cut -f1`" -lt "$(($CHOPSIZE*2))" ] ; then
[963]2115 cp --parents -pRdf $i $bigdir 2>> $LOGFILE
[925]2116 else
2117 ChopUpAndCopyFile $i $bigdir $CHOPSIZE $BIGNO
2118 BIGNO=$(($BIGNO+1))
2119 fi
[747]2120 done
[925]2121 for i in $EXTRA_MODS ; do
2122 j=`find lib/modules/$FAILSAFE_KVER -name $i.*o 2> /dev/null`
[963]2123 [ ! "$j" ] && echo "WARNING - cannot find failsafe module $i.o" >> $LOGFILE
[925]2124 for k in $j ; do
2125 if [ "`du -sk $k | cut -f1`" -lt "$CHOPSIZE" ] ; then
[963]2126 cp --parents -pRdf $k $bigdir 2>> $LOGFILE
[925]2127 else
2128 ChopUpAndCopyFile $k $bigdir $CHOPSIZE $BIGNO
2129 BIGNO=$(($BIGNO+1))
2130 fi
2131 echo "Added failsafe module $k to ramdisk" >> $LOGFILE
2132 done
2133 done
2134 cd $pwd
[747]2135 else
[925]2136 ListKernelModulePaths >> $needlist
[747]2137 fi
2138 if [ "$res" -ne "0" ] ; then
2139 Die "You have $res file`PluralOrNot $res` present in dependency list\nbut absent from filesystem."
2140 fi
2141 FindAndAddUserKeyboardMappingFile
2142 mkdir -p $bigdir/tmp
[1335]2143 if [ _"$MONDO_SHARE" != _"" ] ; then
[940]2144 MakeMondoConfigFile $MINDI_TMP/mondo-restore.cfg
2145 cp -f $MINDI_TMP/mondo-restore.cfg $bigdir/tmp &> /dev/null
[747]2146 fi
2147 [ -d "/mnt/.boot.d" ] && echo "Oh Jebus" > $bigdir/tmp/DUMBASS-GENTOO
2148 DropOptimizedLibraries $needlist $bigdir
2149 echo -en "Assembling dependency files"
2150 CopyDependenciesToDirectory < $needlist $bigdir
2151
[925]2152 # also copy io.sys and msdos.sys, if we can find them
[747]2153 for i in `mount | cut -d' ' -f3` ; do
[925]2154 for j in io.sys msdos.sys ; do
[963]2155 [ -e "$i/$j" ] && cp -f $i/$j $bigdir 2>> $LOGFILE
[925]2156 done
[747]2157 done
2158
[925]2159 # master boot record, too
[940]2160 i=`cat $MINDI_TMP/BOOTLOADER.DEVICE 2> /dev/null`
[747]2161 if [ "$i" ] ; then
[963]2162 LogIt "Backing up $i's MBR"
[925]2163 dd if=$i of=$bigdir/BOOTLOADER.MBR bs=446 count=1 >> $LOGFILE 2>> $LOGFILE
2164 sleep 1
2165 sync
2166 j=$i
2167 [ -h "$j" ] && j=`readlink -f $j`
[963]2168 LogIt "Creating /dev/boot_device ($j)"
[925]2169 mkdir -p $bigdir/dev
[953]2170 cp -pRdf $j $bigdir/dev/boot_device 2> /dev/null || Die "Unable to create /dev/boot_device on ramdisk"
[747]2171 fi
2172
2173 old_pwd=`pwd`
2174 cd $bigdir
2175
2176 [ -e "$MINDI_LIB/aux-tools" ] || Die "aux-tools not found in Mindi's home dir. Do you have multiple copies of Mindi lying around? Please delete them. No, don't e-mail me and ask how. ;) Use 'rm'."
[963]2177 cp -Rdf $MINDI_LIB/aux-tools/* . 2>> $LOGFILE || LogIt "WARNING - error occurred while unzipping aux-tools"
[747]2178 if [ -e "$MINDI_LIB/x11-tools.tgz" ] ; then
[963]2179 tar -zxf $MINDI_LIB/x11-tools.tgz 2>> $LOGFILE || LogIt "WARNING - error occurred while unzipping x11-tools.tgz"
[747]2180 fi
2181 if [ -e "$MONDO_SHARE/restore-scripts" ] ; then
2182 cp -Rdf $MONDO_SHARE/restore-scripts/* . 2>> $LOGFILE
[1335]2183 [ "$?" -ne "0" ] && [ _"$MONDO_SHARE" != _"" ] && Die "Cannot find/install $MONDO_SHARE/restore-scripts"
[747]2184 fi
[963]2185 [ -d "/lib/dev-state" ] && cp --parents -pRdf /lib/dev-state . 2>> $LOGFILE
[747]2186 cd $old_pwd
2187 echo -e "$DONE"
2188 TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`
2189 SplitDirectoryIntoMinidirs $bigdir $minidir_root
2190 noof_disks=$?
2191 [ "$noof_disks" -eq "0" ] && Die "Too much stuff!"
2192# if [ "$noof_disks" -ge "8" ] ; then
2193# LogIt "You are putting a ludicrously large amount of data on these disks."
2194# LogIt "I shall therefore double EXTRA_SPACE, just in case your ramdisk is too small."
2195# EXTRA_SPACE=$(($EXTRA_SPACE*2))
2196# fi
[940]2197 MakeMountlist $MINDI_TMP/mountlist.txt
[747]2198 mkdir -p $minidir_root/$noof_disks/tmp
[953]2199 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"
[1335]2200 [ _"$MONDO_SHARE" != _"" ] && cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MINDI_TMP/. 2>> $LOGFILE
[964]2201 [ $LVM != "false" ] && $MINDI_LIB/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm || LVM="false"
[747]2202 cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE
2203 ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks
2204 CreateDataDiskImagesFromTarballs $tardir $imagesdir $noof_disks
2205 FRIENDLY_OUTSTRING="Boot and data disk images were created."
[925]2206 # One 1.72MB boot disk, one 2.88MB boot disk and $noof_disks data disk images
[747]2207 rmdir $tardir $bigdir
2208 rm -f $needlist
2209 return $noof_disks
2210}
2211
2212
2213ProcessLDD() {
2214 local main_fname incoming j i fname f newf
2215 main_fname=$1
2216 read incoming
2217 while [ "$incoming" != "" ] ; do
[859]2218 # We take the full path name of the dyn. lib. we want
2219 incoming=`echo "$incoming" | sed '/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*(.*/d ; s/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*\(\/.*\)/\1/ ; s/[[:blank:]]*\(\/.*\)[[:blank:]]*(.*/\1/'`
2220 for f in `echo "$incoming"` ; do
[862]2221 echo "$f `ReadAllLink $f`"
[747]2222 done
2223 read incoming
2224 done
2225}
2226
2227
2228Prompt() {
2229 echo -en "$1"
2230 read line
2231}
2232
2233
2234ReadLine() {
2235 local i incoming
2236 read incoming
2237 i=0
2238 while [ "$i" -le "32" ] && [ "$incoming" = "" ] ; do
[925]2239 i=$(($i+1))
2240 read incoming
[747]2241 done
2242 echo "$incoming"
2243}
2244
2245
2246RejigHyperlinks() {
2247 local minidir_root noof_disks fname path diskno old_pwd awk_loc gawk_loc dir i
2248 minidir_root=$1
2249 noof_disks=$2
2250
2251 old_pwd=`pwd`
2252 diskno=1
2253 while [ "$diskno" -le "$noof_disks" ] ; do
[859]2254 mkdir -p $minidir_root/$diskno
[747]2255 cd $minidir_root/$diskno
2256 for fname in `find -type d -o -print` ; do
2257 [ -h "$minidir_root/$diskno/$fname" ] && MoveHyperlinkSensibly $fname $minidir_root $diskno $noof_disks
2258 done
[925]2259 diskno=$(($diskno+1))
[747]2260 done
2261
2262 cd $old_pwd
2263 return
2264}
2265
2266
2267ReplaceIndividualLine() {
2268 local orig_file new_file lino newstring lines_total lines_remaining
[925]2269
[747]2270 orig_file=$1.orig
2271 mv -f $1 $orig_file || Die "Cannot move $1 to $orig_file"
2272 new_file=$1
2273 lino=$2
2274 newstring="$3"
2275 if [ "$lino" = "" ] || [ "$lino" -lt "1" ] ; then
[925]2276 echo "Can't find string" >> $LOGFILE
2277 return 1
[747]2278 fi
[963]2279 lines_total=`wc -l $orig_file | $AWK '{print $1;}'`
[747]2280 lines_remaining=$(($lines_total-$lino))
2281 head -n$(($lino-1)) $orig_file > $new_file
2282 echo "$newstring" >> $new_file
2283 echo "# The above line was added by Mindi, at the user's instruction" >> $new_file
2284 tail -n$lines_remaining $orig_file >> $new_file
2285 echo "Replace line $lino of $new_file with user-specified line, '$newstring'" >> $LOGFILE
2286 [ -x "$orig_file" ] && chmod +x $new_file
2287 rm -f $orig_file
2288 return 0
2289}
2290
2291
2292ScanCDandTape() {
2293 local i
2294
2295 for i in /dev/st0 /dev/ht0 /dev/cdrom /dev/cdrom0 /dev/cdrom 1 ; do
2296 dd if=$i of=/dev/null bs=64k count=1 &> /dev/null
2297 done
2298}
2299
2300
2301SizeOfPartition() {
2302 local devpath drive res stub
2303 device=$1
2304 if [ "`echo "$device" | grep -F "/dev/md"`" != "" ] ; then
[925]2305 res=`SizeOfRaidPartition $device`
2306 [ "$res" = "" ] && Die "Cannot find $device's size - is your /etc/raidtab sane?"
2307 echo "$res"
2308 return 0
[747]2309 fi
[925]2310 # patch from Bill <bill@iwizard.biz> - 2003/08/25
[960]2311 res=`$FDISK -s $device 2>> $LOGFILE`
[925]2312 # end patch
[747]2313 [ "$res" = "" ] && res=`df -k -P -x supermount | tr -s '\t' ' ' | grep -F "$device " | cut -d' ' -f2`
2314 [ "$res" = "" ] && res="-1"
2315 echo $res
2316 return 0
2317}
2318
2319
2320SizeOfRaidPartition() {
2321 local real_dev smallest_size silly tmp
2322
2323 silly=999999999
2324 smallest_size=$silly
2325
2326 for real_dev in `GetRaidDevMembers $1` ; do
[925]2327 tmp=`SizeOfPartition $real_dev`
2328 [ "$tmp" -lt "$smallest_size" ] && smallest_size=$tmp
[747]2329 done
2330
2331 if [ "$smallest_size" = "$silly" ] ; then
[925]2332 echo "-1"
2333 return 1
[747]2334 else
[925]2335 echo "$smallest_size"
2336 return 0
[747]2337 fi
2338}
2339
2340
2341StripComments()
2342{
2343 local tempfile
[925]2344
[940]2345 tempfile=$MINDI_TMP/$$.strip.txt
[963]2346 cp -f $1 $tempfile 2>> $LOGFILE
[747]2347 $AWK '{if (substr($0,0,1)!="#" || substr($0,0,3)=="#!/") {print $0;};}' $tempfile > $1
2348 rm -f $tempfile
2349 echo "Stripped comments from $2" >> $LOGFILE
2350}
2351
2352
2353SplitDirectoryIntoMinidirs() {
2354 local bigdir minidir_root i noof_disks old_pwd res
[925]2355
[747]2356 bigdir=$1
2357 minidir_root=$2
[1230]2358 [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*
[747]2359
2360 TryToFitDataIntoSeveralDirs $bigdir $minidir_root
2361 noof_disks=$?
2362 if [ "$noof_disks" -eq "0" ] ; then
[925]2363 echo "Failed to fit data into several dirs."
[747]2364 return 0
2365 fi
2366 RejigHyperlinks $minidir_root $noof_disks
[1230]2367 [ "$bigdir" != "" ] && rm -Rf $bigdir/*
[925]2368 return $noof_disks
[747]2369}
2370
2371
2372StripExecutable()
2373{
2374 local tmpfile
[925]2375
[940]2376 tmpfile=$MINDI_TMP/stripped.$$.dat
[747]2377 [ -d "$1" ] || [ -h "$1" ] && return
[963]2378 cp -f $1 $tmpfile 2>> $LOGFILE
[747]2379 strip $tmpfile 2> /dev/null
2380 if [ "$?" -eq "0" ] ; then
[963]2381 cp -f $tmpfile $1 2>> $LOGFILE
[925]2382 echo "Stripped binary $2" >> $LOGFILE
[747]2383 fi
2384 rm -f $tmpfile
2385}
2386
2387
2388TemporarilyCompressAllFiles() {
2389 local i orig_fname out_fname out_list
2390
2391 i=0
2392 out_list=$2/compressed/compressed.txt
2393 mkdir -p $2/compressed
2394 > $out_list
2395 for orig_fname in $1 ; do
2396 out_fname=$2/compressed/$orig_fname.gz
2397 mkdir -p $out_fname 2> /dev/null
2398 rmdir $out_fname 2> /dev/null
2399 gzip -c6 $orig_fname > $out_fname 2> /dev/null
2400 i=$(((($i+1))%15))
2401 [ "$i" -eq "0" ] && echo -en "."
2402 du -sk $out_fname >> $out_list
2403 done
2404}
2405
2406
2407TryToFindKernelPath() {
2408 local fname incoming res fkern_ver we_want_version possible_kernels noof_kernels kernelpath kdate duff_kernels
[925]2409
[747]2410 we_want_version=`uname -r`
2411 possible_kernels=""
2412 duff_kernels=""
2413
2414 if [ "$ARCH" = "ia64" ] ; then
2415 root="/boot/efi/efi"
2416 else
2417 root="/"
2418 fi
2419 for fname in `find $root -maxdepth 2 -type f | grep -F lin | grep -Ev '^/proc/|^/net/'` ; do
[925]2420 [ ! -e "$fname" ] && continue
[747]2421 [ "$fname" = "/boot/vmlinuz.shipped" ] && [ -f "/boot/vmlinuz" ] && continue; # ignore SuSE's extra kernel
[925]2422 file $fname | grep -q gzip
2423 if [ "$?" -eq "0" ] ; then
2424 # Used by ia64
[747]2425 fkern_ver=`gzip -cd $fname | strings 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
[925]2426 else
[747]2427 fkern_ver=`strings $fname 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
[925]2428 fi
[747]2429 [ "$fkern_ver" = "" ] && continue
2430 [ "`echo "$fkern_ver" |grep -F "$we_want_version "`" = "" ] && continue
[925]2431 [ -f "$fname" ] || continue
2432 [ -h "$fname" ] && continue
2433 kdate=`uname -v | $AWK '{for(i=1;i<NF;i++){if(index($i,":")){print $i;};};}' | $AWK '{print $NF;}'`
2434 file $fname | grep -q gzip
2435 if [ "$?" -eq "0" ] ; then
2436 # Used by ia64
2437 if [ "`gzip -cd $fname | strings 2> /dev/null | grep -F "$kdate"`" = "" ] ; then
[963]2438 LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting? Naughty but I'll allow it..."
[925]2439 duff_kernels="$fname $duff_kernels"
2440 else
[747]2441 [ "`echo "$fname" | grep -F "vmlinux"`" ] && continue
2442 possible_kernels="$fname $possible_kernels"
[925]2443 fi
[747]2444 else
[925]2445 if [ "`strings $fname 2> /dev/null | grep -F "$kdate"`" = "" ] ; then
[963]2446 LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting?\n Naughty but I'll allow it..."
[925]2447 duff_kernels="$fname $duff_kernels"
2448 else
[747]2449 [ "`echo "$fname" | grep -F "vmlinux"`" ] && continue
2450 possible_kernels="$fname $possible_kernels"
[925]2451 fi
[747]2452 fi
2453 done
2454 if [ ! "$possible_kernels" ] && uname -a | grep Knoppix > /dev/null ; then
[925]2455 possible_kernels=`find /boot/vmlinuz-2.* | tail -n1`
[747]2456 fi
2457 if [ ! "$possible_kernels" ] ; then
[963]2458 LogIt "No kernel matches exactly. Are there any duff kernels?"
[747]2459 possible_kernels="$duff_kernels"
2460 if [ ! "$possible_kernels" ] ; then
[963]2461 LogIt "Sorry, no duff kernels either"
[747]2462 else
[963]2463 LogIt "I bet you're running Debian or Gentoo, aren't you?"
2464 LogIt "Your kernel doesn't have a sane builddate. Oh well..."
[747]2465 fi
2466 fi
2467 possible_kernels=`echo "$possible_kernels" | tr -s ' ' '\n' | sort -u | tr '\n' ' '`
2468 noof_kernels=`CountItemsIn "$possible_kernels"`
2469 if [ "$noof_kernels" -eq "0" ] ; then
[963]2470 LogIt "Could not find your kernel."
[925]2471 if [ -e "/boot/vmlinuz" ] ; then
[963]2472 LogIt "Using /boot/vmlinuz as a last resort."
[925]2473 output=/boot/vmlinuz
[747]2474 else
[925]2475 output=""
2476 fi
[747]2477 elif [ "$noof_kernels" -eq "1" ] ; then
2478 kernelpath=`echo "$possible_kernels" | sed s/' '//`
2479 echo "Your kernel is $kernelpath (v`uname -r`)" >> $LOGFILE
2480 output="$kernelpath"
2481 else
2482 for i in $possible_kernels ; do
2483 if echo $i | grep "`uname -r`" ; then
[925]2484 LogIt "OK, I used my initiative and found that "
[963]2485 LogIt "$i is probably your kernel. "
[925]2486 output="$i"
2487 return
2488 fi
[747]2489 done
[925]2490 if echo " $possible_kernels " | grep -F "/boot/vmlinuz " &> /dev/null ; then
2491 output=/boot/vmlinuz
2492 echo "Schlomo, this one's for you." >> $LOGFILE
2493 else
[963]2494 LogIt "Two or more possible kernels found. You may specify any one of them and the "
2495 LogIt "boot disks will still work, probably. If one does not work, try another."
2496 LogIt "$possible_kernels"
[747]2497 echo ""
[925]2498 fi
[747]2499 fi
2500 echo "$output" | tr -s ' ' '\n' | sort -u | tr '\n' ' '
2501}
2502
2503
2504TryToFitDataIntoSeveralDirs() {
2505 local bigdir minidir_root noof_disks diskno list_of_files filename old_pwd progress
2506 local i retval noof_disks total_files list_of_devs
[925]2507
[747]2508 bigdir=$1
2509 minidir_root=$2
2510 BIG_CLUNKY_SIZE_COUNTER=0
2511 retval=0
2512 noof_disks=1
2513
2514 echo -en "\r \rDividing data into several groups..."
2515 old_pwd=`pwd`
2516 cd $bigdir
2517 list_of_files=`GetFileSizeList . | sort -nr | cut -f2 | grep -Fv "/dev/"`
2518 progress=0
2519 total_files=`CountItemsIn "$list_of_files"`
2520 if [ "`echo "$filename" | grep -x "/dev/.*"`" ] ; then
2521 filesize=1
2522 fi
2523 mkdir -p $minidir_root/$noof_disks
2524 if [ -e "dev" ] ; then
2525 echo "Copying dev/* to $minidir_root/$noof_disks" >> $LOGFILE
[963]2526 cp --parents -pRdf dev $minidir_root/$noof_disks 2>> $LOGFILE
[747]2527 fi
2528 TemporarilyCompressAllFiles "$list_of_files" $minidir_root
2529 for filename in $list_of_files ; do
2530 AddFileToDir $filename $minidir_root $noof_disks
[925]2531 i=$?
2532 if [ "$i" -gt "$noof_disks" ] ; then
2533 noof_disks=$i
2534 echo -en "\r\t\t\t\t\t\t($noof_disks disks)"
2535 fi
2536 if [ "$i" -eq "0" ] ; then
[963]2537 LogIt "Cannot add file $filename to minidir $minidir_root"
[925]2538 retval=$(($retval+1))
2539 fi
[747]2540 progress=$(($progress+1))
[925]2541 echo -en "\r\t\t\t\t\t\t\t\t$(($progress*100/$total_files))% complete\r"
[747]2542 done
2543 cd $old_pwd
2544 echo -en "\rThe files have been subdivided into $noof_disks directories. \r"
[1230]2545 [ "$minidir_root" != "" ] && rm -Rf $minidir_root/compressed
[747]2546 if [ "$retval" -gt "0" ] ; then
[925]2547 return 0
[747]2548 else
[925]2549 return $noof_disks
[747]2550 fi
2551}
2552
2553
2554TurnTgzIntoRdz() {
2555 local tgz_dir_fname rdz_fname ramdisksize tempfile mountpoint old_pwd nodes disksize kernelsize maxsize res currsize not_copied j k floppy_modules s w
[925]2556
[747]2557 tgz_dir_fname=$1
2558 rdz_fname=$2
2559 ramdisksize=$3
2560 disksize=$4
2561 kernelsize=$5
2562 maxsize=$(($disksize-$kernelsize))
2563 maxsize=$(($maxsize*2)); # to allow for compression of 50%
[940]2564 tempfile=$MINDI_TMP/temp.rd
2565 mountpoint=$MINDI_TMP/mnt1
[747]2566 res=0
2567 echo -en "..."
2568 dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (TurnTgzIntoRdz)"
2569 echo -en "..."
2570 mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE
2571 echo -en "..."
2572 mkdir -p $mountpoint
2573 mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint! The reason may be missing support for loopfs or ext2 (or both) in the running kernel."
2574 echo -en "..."
2575 old_pwd=`pwd`
2576 cd $mountpoint
[959]2577 cp -Rdf $tgz_dir_fname/* . 2>&1 >> $LOGFILE
[747]2578 tar -zxf symlinks.tgz || Die "Cannot untar symlinks.tgz"
2579 cd dev || Die "Can't cd to dev"
2580 tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz"
2581 rm -f dev-entries.tgz
2582 cd ..
2583
2584 for w in insmod.static insmod.static.old ; do
[925]2585 s=`which $w 2> /dev/null`
2586 if [ -e "$s" ] ; then
[963]2587 cp --parents -af $s . 2>> $LOGFILE
[925]2588 fi
[747]2589 done
2590
2591 mkdir -p tmp
2592 [ -e "/dev/.devfsd" ] && echo "/dev/.devfsd found" > tmp/USE-DEVFS
2593 for w in cdrom floppy groovy-stuff ; do
2594 mkdir -p mnt/$w
2595 done
[925]2596 #if [ "$RUN_AFTER_INITIAL_BOOT_PHASE" ] ; then
2597 #ReplaceIndividualLine sbin/init `grep -n "#WHOLIVESINAPINEAPPLEUNDERTHESEA#" sbin/init | cut -d':' -f1` "$RUN_AFTER_INITIAL_BOOT_PHASE"
2598 #fi
[747]2599 if [ "$RUN_AFTER_BOOT_PHASE_COMPLETE" ] ; then
[925]2600 ReplaceIndividualLine sbin/init `grep -n "#ABSORBENTANDYELLOWANDPOROUSISHE#" sbin/init | cut -d':' -f1` "$RUN_AFTER_BOOT_PHASE_COMPLETE"
[747]2601 fi
2602
2603 cp --parents -Rdf /dev/fd0*[1,2][4,7,8]* . 2> /dev/null
2604 cd $old_pwd
2605 echo -en "..."
2606 MakeModuleLoadingScript $TMPMODPROBE_FLAG $mountpoint/sbin/insert-all-my-modules
2607 echo -en "..."
2608 old_pwd=`pwd`
2609 if [ "$YOUR_KERNEL_SUCKS" ] ; then
[940]2610 cd $MINDI_TMP
[747]2611 floppy_modules_path=lib/modules/$FAILSAFE_KVER
2612 else
2613 cd /
2614###
2615### Sq-Modification... Use kernel name in module path if specified.
2616###
2617 #floppy_modules_path=lib/modules/`uname -r`
2618 if [ "${kernelname}" != "" ]
2619 then
2620 floppy_modules_path=lib/modules/${kernelname}
2621 else
2622 floppy_modules_path=lib/modules/`uname -r`
2623 fi
2624###
2625### Sq-Modification end
2626###
2627 fi
2628 floppy_modules=""
2629 if [ "$disksize" -lt "2880" ] ; then
[1354]2630 list_of_groovy_mods="$FLOPPY_MODS $FORCE_MODS $IDE_MODS ide-scsi sr_mod cdrom isocd isofs `WhichOfTheseModulesAreLoaded "$SCSI_MODS"`"
[747]2631 else
[1354]2632 list_of_groovy_mods="$CDROM_MODS $FORCE_MODS `WhichOfTheseModulesAreLoaded "$SCSI_MODS"`"
[747]2633 fi
[940]2634 if [ -e "$MINDI_TMP/NFS-DEV" ] ; then
[747]2635 # For PXE boot
2636 list_of_groovy_mods="$list_of_groovy_mods $NET_MODS"
2637 fi
[963]2638 [ -e "$floppy_modules_path" ] || LogIt "path $floppy_modules_path does not exist.\n If you're not using a modular kernel then you're NUTS."
[747]2639 for i in $list_of_groovy_mods ; do
2640 floppy_modules="$floppy_modules `FindSpecificModuleInPath $floppy_modules_path $i`"
2641 done
2642 for i in $floppy_modules ; do
2643 [ -e "$i" ] && s=`du -sk $i | cut -f1` || s=""
[940]2644 [ "$YOUR_KERNEL_SUCKS" ] && i=$MINDI_TMP/$i
[747]2645 echo "Adding $i ($s KB) to the rootfs" >> $LOGFILE
[963]2646 cp -df $i $mountpoint/ 2>/dev/null || LogIt "Unable to copy $i to $mountpoint"
[747]2647 [ "`echo "$i" | grep -F ".gz"`" ] && gunzip -f $mountpoint/`basename $i`
2648 done
2649 if [ ! -e "/sbin/devfsd" ] || [ "$disksize" -lt "2880" ] || [ "$kernelpath" = "$MINDI_LIB/vmlinuz" ] ; then
2650 echo "Deleting devfsd daemon from ramdisk" >> $LOGFILE
2651 [ ! -e "/sbin/devfsd" ] && echo "...because /sbin/devfsd not found" >> $LOGFILE
2652 [ "$disksize" -lt "2880" ] && echo "...because disksize = $disksize" >> $LOGFILE
2653 [ "$kernelpath" = "$MINDI_LIB/vmlinuz" ] && echo "...because kernel is failsafe" >> $LOGFILE
2654 rm -f $mountpoint/sbin/devfsd
2655 fi
2656 cd $old_pwd
2657 [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $mountpoint/tmp/TAPEDEV-LIVES-HERE
2658 dd if=/dev/zero of=$mountpoint/zero &> /dev/null
2659 rm -f $mountpoint/zero
[1335]2660 if [ _"$MONDO_SHARE" != _"" ] ; then
[747]2661 MakeMondoConfigFile $mountpoint/tmp/mondo-restore.cfg
[940]2662 cp -f $mountpoint/tmp/mondo-restore.cfg $MINDI_TMP &> /dev/null
[953]2663 cp -f $MINDI_TMP/mountlist.txt $mountpoint/tmp/ 2>/dev/null || Die "Cannot copy mountlist to ramdisk"
[747]2664 echo -en "$FILES_IN_FILELIST" > $mountpoint/tmp/FILES-IN-FILELIST
2665 echo -en "$LAST_FILELIST_NUMBER" > $mountpoint/tmp/LAST-FILELIST-NUMBER
2666 [ "$USE_LZO" = "yes" ] && echo -en "Pras 4 Pres 2004" >> $mountpoint/tmp/USING-LZO
[998]2667 [ "$USE_GZIP" = "yes" ] && echo -en "YES" >> $mountpoint/tmp/USING-GZIP
[747]2668 [ "$USE_COMP" = "yes" ] && echo -en "Compression, yep" >> $mountpoint/tmp/USING-COMP
2669 [ "$USE_STAR" = "yes" ] && echo -en "Using star. Hooray." >> $mountpoint/tmp/USING-STAR
2670 fi
2671 mkdir -p $mountpoint/tmp
2672 mkdir -p $mountpoint/proc
2673 echo "$disksize" > $mountpoint/tmp/$disksize.siz
2674 find $mountpoint -name CVS -exec rm -rf '{}' \;
[1230]2675 # Determine what filesystem to use for initrd image
2676 echo "Call GetInitrdFilesystemToUse() with parameter ${kernelpath} to get filesystem to use for initrd." >> $LOGFILE
2677 gvFileSystem=`GetInitrdFilesystemToUse ${kernelpath}`
2678 [ -z gvFileSystem ] && Die "GetFilesystemToUse() failed. Terminating."
2679 case "$gvFileSystem" in
2680 "ext2fs")
2681 # say what will be used
2682 echo "Creating an ext2 initrd image..." >> $LOGFILE
2683 # kernel expects linuxrc in ext2 filesystem
2684 ( cd $mountpoint && ln -sf sbin/init linuxrc )
2685 # unmount loop filesystem and create image file using the standard approach
2686 umount $mountpoint || Die "Cannot unmount $tempfile"
2687 dd if=$tempfile bs=1k 2> /dev/null | gzip -v9 > $rdz_fname 2> /dev/null
2688 # log that we are done
2689 echo "...done." >> $LOGFILE
2690 ;;
2691 "initramfs")
2692 # say what will be used
2693 echo "Creating a gzip'ed cpio (AKA initramfs) initrd image..." >> $LOGFILE
2694 # make sure that cpio is there
2695 which cpio &> /dev/null; [ $? -eq 0 ] || Die "cpio not found. Please install package cpio and try again."
2696 # go into filesystem
2697 cd $mountpoint
2698 # kernel expects init in cpio filesystem
2699 ln -sf sbin/init init
2700 # create cpio image file and unmount loop filesystem
2701 find . -print | cpio -o -H newc | gzip -9 > $old_pwd/$rdz_fname 2> /dev/null
2702 cd $old_pwd
2703 umount $mountpoint || Die "Cannot unmount $tempfile"
2704 # log that we are done
2705 echo "...done." >> $LOGFILE
2706 ;;
2707 *)
2708 Die "Filesystem $gvFileSystem not supported for initrd image. Terminating."
2709 ;;
2710 esac
[747]2711 if [ "$res" -eq "0" ] ; then
2712 echo -en "..."
2713 else
2714 echo -en "\rMade an rdz WITH ERRORS. \n"
2715 fi
2716 return 0
2717}
2718
2719
2720WhichOfTheseModulesAreLoaded() {
2721 local modname loaded_modules
[1399]2722 loaded_modules="$MODULES"
[747]2723 for modname in $1 ; do
[925]2724 [ "`echo "$loaded_modules" | grep -F " $modname "`" ] && echo "$modname"
[747]2725 done
2726}
2727
2728
2729ZipMinidirsIntoTarballs() {
2730 local minidir_root tardir noof_disks diskno old_pwd i
2731 minidir_root=$1
2732 tardir=$2
2733 noof_disks=$3
2734
2735 echo -en "Tarring and zipping the group`PluralOrNot $noof_disks`..."
2736 mkdir -p $tardir
2737 mkdir -p $minidir_root/all
2738 old_pwd=`pwd`
2739 diskno=1
2740 while [ "$diskno" -le "$noof_disks" ] ; do
[963]2741 cd $minidir_root/$diskno || LogIt "WARNING - cannot cd to $minidir_root/$diskno"
[747]2742 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."
2743 diskno=$(($diskno+1))
2744 echo -n "..."
[963]2745 cp -pRdf * $minidir_root/all 2>> $LOGFILE
[747]2746 done
2747 mkdir -p $minidir_root/all/tmp
2748 cd $minidir_root/all
2749 size_of_all_tools=`du -sk . | cut -f1`
[1335]2750 if [ _"$MONDO_SHARE" != _"" ] ; then
[747]2751 for q in filelist.full.gz biggielist.txt ; do
[940]2752 [ ! -e "$MINDI_TMP/$q" ] && Die "Cannot find $MINDI_TMP/$q"
[963]2753 cp -pRdf $MINDI_TMP/$q tmp/ 2>> $LOGFILE
[747]2754 done
2755 mkdir -p $minidir_root/all/tmp
2756 echo -en "$FILES_IN_FILELIST" > $minidir_root/all/tmp/FILES-IN-FILELIST 2> /dev/null
2757 echo -en "$LAST_FILELIST_NUMBER" > $minidir_root/all/tmp/LAST-FILELIST-NUMBER 2> /dev/null
2758 fi
2759 tar -b 4096 -cf - * 2> /dev/null | gzip -9 > $tardir/all.tar.gz
2760 dd if=/dev/zero bs=1k count=64 >> $imagesdir/all.tar.gz 2> /dev/null
2761 [ "`du -sm $imagesdir/all.tar.gz | cut -f1`" -ge "30" ] && Die "You have too many tools in your shed"
2762 cd $old_pwd
[1230]2763 [ "$minidir_root" != "" ] && rm -Rf $minidir_root
[747]2764 echo -e "$DONE"
2765}
2766
2767
2768##############################################################################
[1021]2769#----------------------------------- Main -----------------------------------#
[747]2770##############################################################################
2771
2772
2773> $LOGFILE
2774echo "mindi v$MINDI_VERSION" >> $LOGFILE
2775echo "$ARCH architecture detected" >> $LOGFILE
2776echo "mindi called with the following arguments:" >> $LOGFILE
2777echo "$@" >> $LOGFILE
[800]2778echo "Start date : `date`" >> $LOGFILE
[747]2779
2780if [ -e "/etc/conf.modules" ] && [ ! -e "/etc/modules.conf" ] ; then
[963]2781 LogIt "WARNING - Ancient distro detected." 1
[747]2782 ln -sf /etc/conf.modules /etc/modules.conf
2783fi
2784[ -e "/sbin/mkdosfs" ] && [ ! -e "/sbin/mkfs.vfat" ] && ln -sf /sbin/mkdosfs /sbin/mkfs.vfat
2785
[1010]2786# Log some capital variables
2787[ "$MINDI_PREFIX" = "XXX" ] && Die "Mindi has not been installed correctly."
2788echo "MINDI_LIB = $MINDI_LIB" >> $LOGFILE
2789echo "MINDI_SBIN = $MINDI_SBIN" >> $LOGFILE
2790[ "$MINDI_CONF" = "YYY" ] && Die "Mindi has not been installed correctly."
2791echo "MINDI_CONF = $MINDI_CONF" >> $LOGFILE
2792echo "MONDO_SHARE = $MONDO_SHARE" >> $LOGFILE
2793
[747]2794trap AbortHere SIGTERM SIGHUP SIGQUIT SIGKILL SIGABRT SIGINT
[1010]2795
2796# Sanity checks
2797which which > /dev/null 2> /dev/null || Die "Please install 'which'."
2798which strings > /dev/null 2> /dev/null || Die "Please install binutils and libbinutils; you have no 'strings' executable."
2799which gawk > /dev/null 2> /dev/null || Die "Gawk is missing from your computer. Please install gawk. You may find the package on Debian's website. How did I know you're running Debian? Because only Debian would be stupid enough not to include gawk in your distribution."
2800which gawk > /dev/null 2> /dev/null && AWK=`which gawk 2>/dev/null` || AWK="`which awk 2>/dev/null`"
2801if which awk &> /dev/null ; then
2802 if ! which gawk &> /dev/null ; then
2803 LogIt "You have awk but not gawk.\nPlease note that mindi works fine with a _sane_ awk binary.\nIf your awk binary misbehaves then please contact your vendor\nor distribution's mailing list for technical support.\n"
2804 fi
2805fi
2806which mke2fs > /dev/null 2> /dev/null || Die "Please put mke2fs in system path"
2807[ ! -e "$FDISK" ] && Die "Cannot find (s)fdisk"
2808
[747]2809[ "`uname -r | grep "2.4.[0-6]" | grep -v "2.4.[0-9][0-9]"`" != "" ] && echo "WARNING! Your kernel may have buggy loopfs code. Consider upgrading to 2.4.7"
2810# If we have a 2.6 kernel, the system uses module-init-tools which means that we
2811# may have the modprobe configuration spread out across multiple files in
2812# directory /etc/modprobe.d. If this is the case we concatenate these files into
2813# a temporary file for further processing. Otherwise we continue in the standard
2814# way. Note further that in case /etc/modprobe.d exists, we use it and ignore
2815# /etc/modprobe.conf which is exactly what module-init-tools does. The temporary
2816# modprobe.conf file is created in MakeModuleLoadingScript. AL041128.
[1342]2817if [ -d "/etc/modprobe.d" ] && [ `uname -r | cut -c1-3` = "2.6" ] ; then
[925]2818 TMPMODPROBE_FLAG="Y"
[747]2819else
[925]2820 TMPMODPROBE_FLAG="N"
2821 [ -e "/etc/modprobe.conf" ] && [ ! -e "/etc/modules.conf" ] && ln -sf /etc/modprobe.conf /etc/modules.conf
2822 [ ! -e "/etc/modules.conf" ] && Die "/etc/modules.conf not found; you may have to create a softlink from /etc/conf.modules to /etc/modules.conf; of course, all good distros use modules.conf anyway..."
[747]2823fi
[1010]2824
2825# Update the PATH variable if incomplete
2826if [ -e "/sbin/mkfs" ] && ! which mkfs &> /dev/null ; then
2827 PATH=$PATH:/sbin:/usr/sbin
2828 export PATH
2829 echo "Your PATH did not include /sbin or /usr/sbin. I have fixed that, temporarily." >> $LOGFILE
2830 echo "However, you may wish to ask your vendor to provide a permanent fix..." >> $LOGFILE
2831 echo " Or you might like to call 'su -' instead of 'su', for example." >> $LOGFILE
2832fi
2833
[747]2834[ -f "$MINDI_LIB/vmlinuz" ] && FAILSAFE_KVER=`strings $MINDI_LIB/vmlinuz 2> /dev/null | grep -E "2\.[46]" | cut -d' ' -f1`
[1010]2835
2836if ! which mkfs.vfat &> /dev/null ; then
2837 Die "mkfs.vfat missing from your filesystem - please install your dosfstools RPM or DEB package. Perhaps your PATH environmental variable is broken, too?"
2838fi
2839
[925]2840### BERLIOS
[747]2841### Fix as it's not mandatory on ia64
2842if [ "$ARCH" = "ia64" ] ; then
[1010]2843 if which elilo &> /dev/null ; then
2844 LILO_EXE=elilo
2845 else
2846 LILO_EXE=`which false`
2847 fi
[747]2848else
2849 FindIsolinuxBinary
2850 FindLiloBinary
2851fi
[925]2852# BERLIOS: Remove as too dangerous and now useless
[940]2853#grep -F " $MINDI_TMP " /proc/mounts | grep -F tmpfs > /dev/null 2> /dev/null && MINDI_TMP=/home/tmpmondo && mkdir -p $MINDI_TMP && LogIt "Changing MINDI_TMP to $MINDI_TMP because you're using tmpfs for /tmp\n" ; # tmpfs doesn't like Mindi and /tmp, for some reason
[747]2854trap "Aborted" SIGTERM
2855DONE="\r\t\t\t\t\t\t\t\tDone. "
2856CHOPSIZE=240
2857BIGNO=0
2858MAX_COMPRESSED_SIZE=1300
2859kernelpath=""
[1010]2860MONDO_ROOT=/var/cache/mondo
[747]2861mkdir -p $MONDO_ROOT
2862
2863if [ -d "/proc/lvm" ]; then
2864 # LVM v1
2865 LVMCMD=""
2866 LVM="v1"
2867elif [ -d "/dev/mapper" ]; then
2868 # LVM v2
2869 LVMCMD="lvm"
2870 LVM="v2"
2871else
2872 LVM="false"
2873fi
[1021]2874echo "LVM set to $LVM" >> $LOGFILE
2875echo "----------" >> $LOGFILE
2876echo "df result:" >> $LOGFILE
2877echo "----------" >> $LOGFILE
[1230]2878df -T >> $LOGFILE
[1021]2879echo "-------------" >> $LOGFILE
[1230]2880echo "mount result:" >> $LOGFILE
2881echo "-------------" >> $LOGFILE
2882mount >> $LOGFILE
2883echo "-------------" >> $LOGFILE
[1315]2884if [ -e /etc/raidtab ]; then
2885 echo "-------------" >> $LOGFILE
2886 echo "/etc/raidtab content:" >> $LOGFILE
2887 echo "-------------" >> $LOGFILE
2888 cat /etc/raidtab >> $LOGFILE
2889fi
2890echo "-------------" >> $LOGFILE
[1418]2891echo "cat /proc/cmdline:" >> $LOGFILE
2892echo "-------------" >> $LOGFILE
2893cat /proc/cmdline >> $LOGFILE
2894echo "-------------" >> $LOGFILE
[1021]2895echo "lsmod result:" >> $LOGFILE
2896echo "-------------" >> $LOGFILE
2897lsmod >> $LOGFILE
[1399]2898MODULES="`cat /proc/modules | awk '{print $1}'`"
[1021]2899echo "-------------" >> $LOGFILE
[1230]2900echo "Liste of extra modules is:" >> $LOGFILE
2901echo "$EXTRA_MODS" >> $LOGFILE
2902echo "-------------" >> $LOGFILE
[747]2903
2904if [ "$#" -ge "2" ] ; then
2905 if [ "$1" = "--max-compressed-size" ] ; then
2906 MAX_COMPRESSED_SIZE=$2
2907 shift; shift
2908 fi
2909fi
2910
2911FLOPPY_WAS_MOUNTED=""
2912for mtpt in /media/floppy /mnt/floppy /floppy ; do
2913 if mount | grep -w $mtpt &> /dev/null ; then
2914 FLOPPY_WAS_MOUNTED="$FLOPPY_WAS_MOUNTED $mtpt"
2915 umount $mtpt
2916 fi
2917done
2918
2919if [ "$#" -ne "0" ] ; then
2920 if [ "$1" = "--findkernel" ] ; then
2921 res=`TryToFindKernelPath`
[1336]2922 # Avoids logfile content for mondo
2923 export MONDO_SHARE=""
[747]2924 if [ "$res" = "" ] ; then
[925]2925 MindiExit -1
[747]2926 else
2927 echo "$res"
[925]2928 MindiExit 0
[747]2929 fi
2930 elif [ "$1" = "--makemountlist" ] ; then
2931 [ ! "$2" ] && Die "Please specify the output file"
2932 MakeMountlist $2
[1336]2933 # Avoids logfile content for mondo
2934 export MONDO_SHARE=""
[925]2935 MindiExit $?
2936 elif [ "$1" = "-V" ] || [ "$1" = "-v" ] || [ "$1" = "--version" ] || [ "$1" = "-version" ] ; then
2937 echo "Mindi v$MINDI_VERSION"
[1336]2938 # Avoids logfile content for mondo
2939 export MONDO_SHARE=""
[925]2940 MindiExit 0
[747]2941 elif [ "$#" -ge "9" ] && [ "$1" = "--custom" ] ; then
[940]2942 MONDO_TMP=$2
2943 # Change MINDI_TMP for the one provided by mondo
2944 # So that it can get back the built files
[1010]2945 mv $MINDI_TMP/* $MINDI_TMP/.??* $MONDO_TMP 2> /dev/null
2946 rmdir $MINDI_TMP
[940]2947 MINDI_TMP=$MONDO_TMP
[953]2948 mkdir -p $MINDI_TMP
[1010]2949 # This is the scratch dir in mondo
[938]2950 CACHE_LOC=$3
2951 if [ _"$CACHE_LOC" != _"" ]; then
2952 mkdir -p $CACHE_LOC
2953 fi
[925]2954 kernelpath=$4; [ "$kernelpath" = "(null)" ] && kernelpath=""
[747]2955###
2956### Sq-Modification...
2957### Attempt to locate kernel specific module path
2958### if module path is found then use it other wise use uname -r to set it...
2959###
2960 kernelname=`echo $kernelpath | cut -d'-' -f2-`
[963]2961 LogIt "kernelname = $kernelname"
2962 LogIt "kernelpath = $kernelpath"
[747]2963 if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
2964 then
[963]2965 LogIt "Module path for ${kernelpath} not found..."
2966 LogIt "using running kernel\'s modules."
[747]2967 kernelname=`uname -r`
2968 else
[963]2969 LogIt "Using modules for kernel: ${kernelname}"
[747]2970 fi
2971###
2972### end of Sq-Modification
2973###
[925]2974 TAPEDEV=$5
2975 TAPESIZE=$6
2976 FILES_IN_FILELIST=$7
2977 USE_LZO=$8
2978 CDRECOVERY=$9
[747]2979 if [ "${10}" = "(null)" ] || [ "${10}" = "" ] ; then
2980 IMAGE_DEVS=""
2981 else
2982 IMAGE_DEVS="`echo "${10}" | tr '|' ' '`"
2983 fi
[925]2984 if [ "${11}" ] ; then
2985 LILO_OPTIONS=""
2986 # LogIt "LILO will use conservative settings, to be compatible with older BIOSes."
2987 fi
2988 LAST_FILELIST_NUMBER=${12}
[747]2989 ESTIMATED_TOTAL_NOOF_SLICES=${13}
2990 EXCLUDE_DEVS="${14}"
2991 USE_COMP="${15}"
2992 USE_LILO="${16}"
[925]2993 USE_STAR="${17}"
2994 INTERNAL_TAPE_BLOCK_SIZE="${18}"
[747]2995 DIFFERENTIAL="${19}"
[998]2996 USE_GZIP="${20}"
2997 NOT_BOOT="${21}"
[747]2998 [ "$USE_COMP" = "" ] && USE_COMP=yes
[998]2999 [ "$USE_GZIP" = "" ] && USE_GZIP=no
[747]3000 [ "$NOT_BOOT" = "" ] && NOT_BOOT=no
[963]3001 [ "$TAPEDEV" ] && LogIt "This is a tape-based backup. Fine."
[925]3002 [ "$kernelpath" = "" ] && kernelpath=`TryToFindKernelPath`
[747]3003 kernelname=`echo $kernelpath | cut -d'-' -f2-`
3004 if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
3005 then
[963]3006 LogIt "Module path for ${kernelpath} not found..."
3007 LogIt "using running kernel\'s modules."
[747]3008 kernelname=`uname -r`
3009 else
[963]3010 LogIt "Using modules for kernel: ${kernelname}"
[747]3011 fi
[925]3012 [ "$CDRECOVERY" = "yes" ] && [ "$TAPEDEV" != "" ] && Die "Sorry, you can't use --cd-recovery and --write-tapes at the same time"
3013 MONDO_ROOT=`echo $CACHE_LOC | sed 's/\(.*\)\/.*/\1/'`
[938]3014 if [ _"$MONDO_ROOT" != _"" ]; then
3015 mkdir -p $MONDO_ROOT
3016 else
3017 Die "MONDO_ROOT is undefined"
3018 fi
[747]3019 else
[925]3020 echo "Syntax: mindi (--custom ....)" >> /dev/stderr
3021 MindiExit -1
[747]3022 fi
3023fi
3024#ScanCDandTape
3025[ "$CDRECOVERY" = "yes" ] || CDRECOVERY=no
3026if [ "$CDRECOVERY" = "yes" ] ; then
3027 iso_cfg_file=$MINDI_LIB/isolinux-H.cfg
3028 sys_cfg_file=$MINDI_LIB/syslinux-H.cfg
3029else
3030 iso_cfg_file=$MINDI_LIB/isolinux.cfg
3031 sys_cfg_file=$MINDI_LIB/syslinux.cfg
3032fi
3033
3034[ -e "$iso_cfg_file" ] || Die "Cannot find $iso_cfg_file"
[1335]3035if [ _"$MONDO_SHARE" = _"" ] ; then
[963]3036 LogIt "Mindi Linux mini-distro generator v$MINDI_VERSION"
3037 LogIt "Latest Mindi is available from http://www.mondorescue.org"
3038 LogIt "BusyBox sources are available from http://www.busybox.net"
[747]3039 LogIt "------------------------------------------------------------------------------"
3040else
[1315]3041 echo "You are using Mindi-Linux v$MINDI_VERSION to make boot+data disks" >> $LOGFILE
[747]3042fi
[1005]3043if [ -f $MINDI_LIB/rootfs/bin/busybox ]; then
3044 LogIt "Mindi-`$MINDI_LIB/rootfs/bin/busybox 2>&1 | head -1`"
3045else
3046 LogIt "Unable to find mindi-busybox, please install it"
3047 MindiExit -1
3048fi
[747]3049
3050# for Mandrake 9.2, which comes with two aes.o.gz modules :-/
3051insmod /lib/modules/`uname -r`/*/*/misc/aes.*o.gz >> $LOGFILE 2>> $LOGFILE
3052for i in loop cdrom ide-cd isofs linear raid0 raid1 raid5 ; do
3053 insmod $i >> $LOGFILE 2>> $LOGFILE
3054done
3055
3056KERN_DISK_MADE=""
3057
3058echo "DIFFERENTIAL = $DIFFERENTIAL" >> $LOGFILE
3059echo "INTERNAL TAPE BLOCK SIZE = $INTERNAL_TAPE_BLOCK_SIZE" >> $LOGFILE
3060echo "NOT_BOOT = '$NOT_BOOT'" >> $LOGFILE
3061if [ "$NOT_BOOT" != "" ] && [ "$NOT_BOOT" != "0" ] && [ "$NOT_BOOT" != "no" ] ; then
[963]3062 LogIt "Just creating mondo-restore.cfg and a small all.tar.gz for Mondo. Nothing else."
[940]3063 MakeMondoConfigFile $MINDI_TMP/mondo-restore.cfg
3064 MakeMountlist $MINDI_TMP/mountlist.txt
3065 mkdir -p $MINDI_TMP/small-all/tmp
3066 cd $MINDI_TMP/small-all
[953]3067 cp -f $MINDI_TMP/{mountlist.txt,mondo-restore.cfg,filelist.full.gz,biggielist.txt} tmp 2>/dev/null || Die "Cannot copy small all.tar.gz"
[940]3068 tar -cv tmp | gzip -9 > $MINDI_TMP/all.tar.gz || Die "Cannot make small all.tar.gz"
[747]3069 sleep 2
[963]3070 LogIt "Done. Exiting."
[925]3071 MindiExit 0
[747]3072fi
3073
3074if [ "$kernelpath" = "" ] ; then
[1335]3075 [ _"$MONDO_SHARE" != _"" ] && Die "Please use -k <path> to specify kernel."
[966]3076 echo -en "Do you want to use your own kernel to build the boot disk ([y]/n) ?"
3077 read ch
3078 if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
3079 USE_OWN_KERNEL="yes"
[747]3080 fi
3081 if [ "$USE_OWN_KERNEL" = "yes" ]; then
[925]3082 YOUR_KERNEL_SUCKS=""
3083 kernelpath=`TryToFindKernelPath`
3084 if [ "$kernelpath" = "" ] ; then
3085 echo -n "Please enter kernel path : "
3086 read kernelpath
3087 fi
[747]3088 else
[925]3089 YOUR_KERNEL_SUCKS="That's why you're using mine, dude. :-)"
[747]3090 fi
3091fi
[1335]3092if [ _"$MONDO_SHARE" = _"" ] ; then
[966]3093 echo -en "Would you like to use LILO (instead of syslinux)\nfor your boot CD/floppies (y/[n]) ?"
[747]3094 read ch
[966]3095 if [ "$ch" != "y" ] && [ "$ch" != "Y" ] ; then
3096 USE_LILO=no
3097 else
[747]3098 USE_LILO=yes
3099 fi
3100fi
3101if [ "$YOUR_KERNEL_SUCKS" != "" ] || [ "$kernelpath" = "" ] || [ "$kernelpath" = "SUCKS" ] || [ "$kernelpath" = "FAILSAFE" ] ; then
3102 kernelpath=$MINDI_LIB/vmlinuz
[963]3103 LogIt "I shall include Mindi's failsafe kernel, not your kernel, in the boot disks."
3104 LogIt "However, you are still running your kernel. If Mindi fails to create your"
3105 LogIt "disks then it may still be a result of a problem with your kernel."
[747]3106 pwd=`pwd`
[940]3107 cd $MINDI_TMP
[747]3108 bzip2 -dc $MINDI_LIB/lib.tar.bz2 | tar -x || Die "Cannot unzip lib.tar.bz2"
3109 cd $pwd
3110 YOUR_KERNEL_SUCKS="Your kernel sucks"
3111fi
[940]3112echo -e "Mindi's temp dir = $MINDI_TMP \nMindi's output dir=$CACHE_LOC" >> $LOGFILE
[963]3113[ "$(($RANDOM%64))" -eq "0" ] && LogIt "Dude, I've looked inside your computer and it's really dusty..."
[747]3114
[965]3115[ "$YOUR_KERNEL_SUCKS" ] && [ ! "$FAILSAFE_KVER" ] && Die "Please install mindi-kernel package. You need it.\nGo to http://www.mondorescue.org and download it, then install it."
[747]3116
[925]3117PrepareDataDiskImages $CACHE_LOC
[747]3118noof_disks=$?
3119ramdisk_size=$(($size_of_all_tools+$EXTRA_SPACE))
3120rds=$(($ramdisk_size-$((ramdisk_size%4096))))
3121ramdisk_size=$rds
3122
3123echo "Ramdisk will be $ramdisk_size KB" >> $LOGFILE
3124if [ "$USE_LILO" = "yes" ] ; then
3125 if [ "$ARCH" = "ia64" ] ; then
[1282]3126 PrepareBootDiskImage_LILO $CACHE_LOC $BOOT_SIZE $kernelpath $ramdisk_size || Die "Failed to create ia64 floppy disk image."
[747]3127 else
[925]3128 if ! PrepareBootDiskImage_LILO $CACHE_LOC 1722 $kernelpath $ramdisk_size ; then
[964]3129 LogIt "WARNING - failed to create 1.72MB boot image."
3130 LogIt "Please reduce your kernel's size if you want to make a 1.72MB floppy disk."
[747]3131 fi
[925]3132 if ! PrepareBootDiskImage_LILO $CACHE_LOC 2880 $kernelpath $ramdisk_size ; then
[963]3133 LogIt "WARNING - failed to create 2.88MB floppy disk image."
[964]3134 LogIt "Please reduce your kernel's size if you want to make a 2.88MB floppy disk."
[1282]3135 PrepareBootDiskImage_LILO $CACHE_LOC $BOOT_SIZE $kernelpath $ramdisk_size || Die "Failed to create 2.88MB floppy disk image."
[747]3136 fi
3137 fi
3138else
[925]3139 if ! PrepareBootDiskImage_SYSLINUX $CACHE_LOC 1722 $kernelpath $ramdisk_size ; then
[964]3140 LogIt "WARNING - failed to create 1.72MB boot image."
3141 LogIt "Please reduce your kernel's size if you want to make a 1.72MB floppy disk."
[925]3142 if ! PrepareBootDiskImage_SYSLINUX $CACHE_LOC 2880 $kernelpath $ramdisk_size ; then
[963]3143 LogIt "WARNING - failed to create 2.88MB floppy disk image."
[964]3144 LogIt "Please reduce your kernel's size if you want to make a 2.88MB floppy disk."
[1282]3145 PrepareBootDiskImage_SYSLINUX $CACHE_LOC $BOOT_SIZE $kernelpath $ramdisk_size || Die "Failed to create 5.76MB floppy disk image."
[747]3146 fi
3147 fi
3148fi
3149
3150[ -e "$MINDI_LIB/memtest.img" ] && BOOT_MEDIA_MESSAGE="$BOOT_MEDIA_MESSAGE\n\
3151...Or type 'memtest' to test your PC's RAM thoroughly.\n"
3152
[1335]3153if [ _"$MONDO_SHARE" = _"" ] ; then
[925]3154 ListImagesForUser $CACHE_LOC
[747]3155 boot_dev=/dev/fd0u1722
3156 [ ! -e "$boot_dev" ] && mknod $boot_dev b 2 60
3157 [ ! -e "$boot_dev" ] && boot_dev=/dev/fd0H1722
3158 [ ! -e "$boot_dev" ] && Die "Oh Lord, will you PLEASE tell the vendor to create the 1.72MB devices in /dev?"
3159 if [ "$PROMPT_WRITE_BOOT_FLOPPIES" = "yes" ]; then
[925]3160 OfferToCopyImagesToDisks $CACHE_LOC $boot_dev $FDDEVICE
[747]3161 fi
[925]3162 OfferToMakeBootableISO $CACHE_LOC
[963]3163 LogIt "Finished."
[747]3164elif [ "$TAPEDEV" ] ; then
[925]3165 OfferToMakeBootableISO $CACHE_LOC
3166 if [ -e "$CACHE_LOC/all.tar.gz" ] ; then
[963]3167 cp -f $CACHE_LOC/all.tar.gz $MINDI_TMP/ 2>> $LOGFILE
[747]3168 else
[925]3169 Die "Cannot find all.tar.gz, to be written to tape"
[747]3170 fi
3171else
[925]3172 OfferToMakeBootableISO $CACHE_LOC
[747]3173fi
3174# cleanup
[963]3175LogIt "$FRIENDLY_OUTSTRING"
[747]3176for mtpt in $FLOPPY_WAS_MOUNTED ; do
3177 mount $mtpt
3178done
[925]3179MindiExit 0
Note: See TracBrowser for help on using the repository browser.