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