source: MondoRescue/branches/stable/mindi/mindi@ 1063

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