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