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