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

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