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