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