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