source: MondoRescue/branches/2.2.2/mindi/mindi@ 1311

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

Suppress losetup usage in start-nfs (unreliable and doesn't work with QEMU

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