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