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