source: MondoRescue/trunk/mindi/mindi@ 463

Last change on this file since 463 was 463, checked in by andree, 18 years ago

Changed error messages in case loop mount of image files fails to point
to both lacking loopfs and ext2 support as reasons.

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