source: MondoRescue/branches/2.2.10/mindi/mindi@ 2596

Last change on this file since 2596 was 2596, checked in by Bruno Cornec, 14 years ago

r3737@localhost: bruno | 2010-03-14 20:57:44 +0100

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