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