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