source: MondoRescue/trunk/mindi/mindi@ 1043

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

merge -r978:1042 $SVN_M/branches/stable

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