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

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

r3743@localhost: bruno | 2010-03-16 01:44:07 +0100

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