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