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