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