source: MondoRescue/branches/2.2.5/mindi/mindi@ 1864

Last change on this file since 1864 was 1864, checked in by Bruno Cornec, 16 years ago

-Fix pb in the previous commit (wrong test)

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