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