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