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