source: MondoRescue/branches/3.2/mindi/mindi@ 3499

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