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