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