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