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