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