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