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