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