Changeset 135


Ignore:
Timestamp:
Nov 24, 2005, 1:43:32 AM (13 years ago)
Author:
bcornec
Message:

merge -r132:134 $SVN_M/branches/2.05

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mindi/mindi

    r125 r135  
    1515
    1616RUN_AFTER_INITIAL_BOOT_PHASE="echo \"Who lives in a pineapple under the sea?\" > /tmp/spongebob.squarepants.txt"
    17     # after booting from floppy/CD image but before
    18     # accessing auxiliary data disks (or the rest of
    19     # the CD), the initscript will run the above command.
     17    # after booting from floppy/CD image but before
     18    # accessing auxiliary data disks (or the rest of
     19    # the CD), the initscript will run the above command.
    2020
    2121RUN_AFTER_BOOT_PHASE_COMPLETE="ide-opt"
    22     # after the emergency boot process is complete but
    23     # before the init script runs mondorestore, it will
    24     # run this command.
     22    # after the emergency boot process is complete but
     23    # before the init script runs mondorestore, it will
     24    # run this command.
    2525
    2626MINDI_VERSION=1.04_berlios
     
    3131WRITE_BOOT_FLOPPIES="yes" ; # do you want to be prompted to write floppy images
    3232PROMPT_WRITE_BOOT_FLOPPIES="yes"
    33     # do you want to be prompted to write
    34     # floppy images out to floppy disks?
    35     # if 'no', images will not be written to floppies
     33    # do you want to be prompted to write
     34    # floppy images out to floppy disks?
     35    # if 'no', images will not be written to floppies
    3636
    3737PROMPT_MAKE_CD_IMAGE="yes"
    38     # Ask if you want to make a CD Image to be written?
    39     # if this is set to 'no', then the image will be created automatically
     38    # Ask if you want to make a CD Image to be written?
     39    # if this is set to 'no', then the image will be created automatically
    4040
    4141USE_OWN_KERNEL="no"
    42     # If set to "no", you will be prompted for whether or not
    43     # you want to use your own kernel, or the supplied default.
    44     # If "yes" mindi will automatically use your own kernel.
     42    # If set to "no", you will be prompted for whether or not
     43    # you want to use your own kernel, or the supplied default.
     44    # If "yes" mindi will automatically use your own kernel.
    4545MINDI_CONFIG="/etc/mindi/mindi.conf"
    4646if [ -f $MINDI_CONFIG ]; then
    47     . $MINDI_CONFIG
     47    . $MINDI_CONFIG
    4848fi
    4949MY_FSTAB=/etc/fstab
     
    7070To boot to a command-line prompt (expert mode), type 'expert' <enter>.\n\
    7171You may add one or more of the following parameters as well:-\n\n\
    72         donteject - mondorestore will not eject the CD; this is useful if, for\n\
    73                     instance, your PC's case has a concealed CD-ROM drive\n\
    74         noresize  - your mountlist will not be adjusted to use your unallocated\n\
    75                     hard disk space\n\
    76         textonly  - do not call any Newt library routines; this is unattractive\n\
    77                     but valuable if you find your Newt library has bugs in it\n\n\
     72        donteject - mondorestore will not eject the CD; this is useful if, for\n\
     73                    instance, your PC's case has a concealed CD-ROM drive\n\
     74        noresize  - your mountlist will not be adjusted to use your unallocated\n\
     75                    hard disk space\n\
     76        textonly  - do not call any Newt library routines; this is unattractive\n\
     77                    but valuable if you find your Newt library has bugs in it\n\n\
    7878e.g. Type 'nuke donteject textonly' if you have an unstable Newt library and \n\
    7979a PC whose CD-ROM drive tray would be damaged if it unexpectedly ejected.\n\
     
    8787
    8888AbortHere() {
    89     [ "$mountpoint" ] && umount $mountpoint 2>> $LOGFILE
    90     Die "Program is terminating in response to signal received from OS/user"
     89    [ "$mountpoint" ] && umount $mountpoint 2>> $LOGFILE
     90    Die "Program is terminating in response to signal received from OS/user"
    9191}
    9292
     
    9494
    9595HackSyslinuxFile() {
    96     local incoming
    97     incoming=`ReadLine`
    98     while [ "$incoming" ] ; do
    99         echo -en "$incoming" | sed s/24000/$1/
    100         if [ "`echo "$incoming" | grep append`" ] ; then
    101             echo -en " $ADDITIONAL_BOOT_PARAMS"
    102         fi
    103         echo -en "\n"
    104         incoming=`ReadLine`
    105     done
    106     if [ -e "$MINDI_HOME/memtest.img" ] ; then
     96    local incoming
     97    incoming=`ReadLine`
     98    while [ "$incoming" ] ; do
     99        echo -en "$incoming" | sed s/24000/$1/
     100        if [ "`echo "$incoming" | grep append`" ] ; then
     101            echo -en " $ADDITIONAL_BOOT_PARAMS"
     102        fi
     103        echo -en "\n"
     104        incoming=`ReadLine`
     105    done
     106    if [ -e "$MINDI_HOME/memtest.img" ] ; then
    107107#        echo -en "label memtest\n  kernel memtest.bin\n\n"
    108         echo -en "label memtest\n  kernel memdisk\n  append initrd=memtest.img\n\n"
     108        echo -en "label memtest\n  kernel memdisk\n  append initrd=memtest.img\n\n"
    109109#        echo "Yep, this is a multi-function CD" > $2/MULTIFUNC
    110     fi
     110    fi
    111111}
    112112
     
    114114
    115115AbortIfYourDistroIsAPieceOfStercus() {
    116     which which > /dev/null 2> /dev/null || Die "Please install 'which'."
    117     which strings > /dev/null 2> /dev/null || Die "Please install binutils and libbinutils; you have no 'strings' executable."
    118     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."
    119     which gawk > /dev/null 2> /dev/null && AWK=`which gawk 2>/dev/null` || AWK="`which awk 2>/dev/null`"
    120     if which awk &> /dev/null ; then
     116    which which > /dev/null 2> /dev/null || Die "Please install 'which'."
     117    which strings > /dev/null 2> /dev/null || Die "Please install binutils and libbinutils; you have no 'strings' executable."
     118    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."
     119    which gawk > /dev/null 2> /dev/null && AWK=`which gawk 2>/dev/null` || AWK="`which awk 2>/dev/null`"
     120    if which awk &> /dev/null ; then
    121121    if ! which gawk &> /dev/null ; then
    122         LogIt "You have awk but not gawk. Please note that mindi works fine with a _sane_ awk binary. If your awk binary misbehaves then please contact your vendor or distribution's mailing list for technical support."
    123     fi
    124     fi
    125     which mke2fs > /dev/null 2> /dev/null || Die "Please put mke2fs in system path"
    126     which afio > /dev/null 2> /dev/null || LogIt "afio not found... mindi doesn't need afio but Mondo does... Be aware...\n"
    127     [ ! -e "/etc/issue.net" ] && > /etc/issue.net
    128     FDISK=$MINDI_HOME/parted2fdisk.pl
    129     FDISKLOG=/tmp/parted2fdisk.log
    130     touch $FDISKLOG
     122        LogIt "You have awk but not gawk. Please note that mindi works fine with a _sane_ awk binary. If your awk binary misbehaves then please contact your vendor or distribution's mailing list for technical support."
     123    fi
     124    fi
     125    which mke2fs > /dev/null 2> /dev/null || Die "Please put mke2fs in system path"
     126    which afio > /dev/null 2> /dev/null || LogIt "afio not found... mindi doesn't need afio but Mondo does... Be aware...\n"
     127    [ ! -e "/etc/issue.net" ] && > /etc/issue.net
     128    FDISK=$MINDI_HOME/parted2fdisk.pl
     129    FDISKLOG=/tmp/parted2fdisk.log
     130    touch $FDISKLOG
    131131#    if [ "`cat /etc/issue.net 2> /dev/null | fgrep -i "debian"`" ] ; then
    132 #        LogIt "Warning! You are a Debian user. If mindi doesn't generate a good mountlist, it's because of a bug in YOUR awk binary. Don't tell me about it. Tell awk.deb's maintainer about it."
     132#        LogIt "Warning - You are a Debian user. If mindi doesn't generate a good mountlist, it's because of a bug in YOUR awk binary. Don't tell me about it. Tell awk.deb's maintainer about it."
    133133#    fi
    134     [ ! -e "$FDISK" ] && Die "Cannot find (s)fdisk"
     134    [ ! -e "$FDISK" ] && Die "Cannot find (s)fdisk"
    135135}
    136136
     
    139139AbortIfMkfsVfatMissing() {
    140140    #if fgrep "vfat" /etc/fstab &> /dev/null ; then
    141         if ! which mkfs.vfat &> /dev/null ; then
    142             Die "mkfs.vfat missing from your filesystem - please install your dosfstools RPM or DEB package. Perhaps your PATH environmental variable is broken, too?"
    143         fi
     141        if ! which mkfs.vfat &> /dev/null ; then
     142            Die "mkfs.vfat missing from your filesystem - please install your dosfstools RPM or DEB package. Perhaps your PATH environmental variable is broken, too?"
     143        fi
    144144    #fi
    145145}
     
    150150
    151151Aborted() {
    152     trap SIGHUP SIGTERM SIGTRAP SIGINT
    153     [ "$imagesdir" != "" ] && rm -f $imagesdir/mindi*img $imagesdir/*gz $imagesdir/mindi.iso
    154     [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*
    155     Die "User abort."
     152    trap SIGHUP SIGTERM SIGTRAP SIGINT
     153    [ "$imagesdir" != "" ] && rm -f $imagesdir/mindi*img $imagesdir/*gz $imagesdir/mindi.iso
     154    [ "$minidir_root" != "" ] && rm -Rf $minidir_root/*
     155    Die "User abort."
    156156}
    157157
    158158
    159159AddFileToCfgIfExists() {
    160     [ -e "$1" ] && echo -en "$2 `cat $1`\n" >> $3
     160    [ -e "$1" ] && echo -en "$2 `cat $1`\n" >> $3
    161161}
    162162
     
    164164
    165165AddFileToDir() {
    166     local filename minidir_root noof_disks diskno res filesize disksize would_occupy zipsize complevel cutoff compressed_fname siz
    167     filename=$1
    168     minidir_root=$2
    169     noof_disks=$3
     166    local filename minidir_root noof_disks diskno res filesize disksize would_occupy zipsize complevel cutoff compressed_fname siz
     167    filename=$1
     168    minidir_root=$2
     169    noof_disks=$3
    170170
    171171#    diskno=1
    172     diskno=$noof_disks
    173     mkdir -p $minidir_root/$diskno
    174     [ "$LAST_COMPRESSED_SIZE" = "" ] && LAST_COMPRESSED_SIZE=0
    175     if [ ! -e "$filename" ] ; then
     172    diskno=$noof_disks
     173    mkdir -p $minidir_root/$diskno
     174    [ "$LAST_COMPRESSED_SIZE" = "" ] && LAST_COMPRESSED_SIZE=0
     175    if [ ! -e "$filename" ] ; then
    176176    if [ -h "$filename" ] ; then
    177         cp --parents -pRdf $filename $minidir_root/$diskno
    178         return $noof_disks
    179     else
    180         Die "AddFileToDir asked me to add $filename, which does not exist. Oops! Did you run out of disk space or is your Linux distro severely broken?"
    181     fi
    182     fi
     177        cp --parents -pRdf $filename $minidir_root/$diskno
     178        return $noof_disks
     179    else
     180        Die "AddFileToDir asked me to add $filename, which does not exist. Oops! Did you run out of disk space or is your Linux distro severely broken?"
     181    fi
     182    fi
    183183# move to the disk that has room on it (or end up using the last, if all full)
    184     while [ "$diskno" -lt "40" ] ; do
     184    while [ "$diskno" -lt "40" ] ; do
    185185    mkdir -p $minidir_root/$diskno
    186         filesize=`du -sk $filename | cut -f1`
     186        filesize=`du -sk $filename | cut -f1`
    187187    cp --parents -Rdf $filename $minidir_root/$diskno
    188         if [ "$filesize" -le "4" ] ; then
    189             siz=$filesize
    190         elif [ ! -f "$filename" ] ; then
    191             siz=0
    192         else
    193             siz=`grep -m 1 "$filename.gz$" $minidir_root/compressed/compressed.txt | cut -f1`
    194             [ "$siz" = "" ] && Die "FIXME - can't find $filename's size."
    195             siz=$(($siz-2));# to allow for sectors & the fact that they round up
    196         fi
     188        if [ "$filesize" -le "4" ] ; then
     189            siz=$filesize
     190        elif [ ! -f "$filename" ] ; then
     191            siz=0
     192        else
     193            siz=`grep -m 1 "$filename.gz$" $minidir_root/compressed/compressed.txt | cut -f1`
     194            [ "$siz" = "" ] && Die "FIXME - can't find $filename's size."
     195            siz=$(($siz-2));# to allow for sectors & the fact that they round up
     196        fi
    197197    [ ! "$siz" ] && siz=4
    198198    [ "$siz" -lt "0" ] && siz=0
    199         LAST_COMPRESSED_SIZE=$(($LAST_COMPRESSED_SIZE+$siz))
     199        LAST_COMPRESSED_SIZE=$(($LAST_COMPRESSED_SIZE+$siz))
    200200    [ "$LAST_COMPRESSED_SIZE" -le "$MAX_COMPRESSED_SIZE" ] &&return $diskno
    201201    echo "disk=$diskno siz=$LAST_COMPRESSED_SIZE" >> $LOGFILE
    202202    LAST_COMPRESSED_SIZE=0
    203203    rm -f $minidir_root/$diskno/$filename
    204         diskno=$(($diskno+1))
    205     done
    206     return 0 ; # failed
     204        diskno=$(($diskno+1))
     205    done
     206    return 0 ; # failed
    207207}
    208208
     
    211211
    212212AddKeyboardMappingFile() {
    213     local mappath r included_list included_item i res ii sss
    214     mappath=$1
    215     KBDEPTH=$(($KBDEPTH+1))
    216     [ "$KBDEPTH" -gt "128" ] && Die "Edit $MINDI_HOME/mindi and disable FindAndAddUserKeyboardMappingFile (line 1170, approx.)"
    217     if [ -e "$bigdir/$mappath" ] ; then
     213    local mappath r included_list included_item i res ii sss
     214    mappath=$1
     215    KBDEPTH=$(($KBDEPTH+1))
     216    [ "$KBDEPTH" -gt "128" ] && Die "Edit $MINDI_HOME/mindi and disable FindAndAddUserKeyboardMappingFile (line 1170, approx.)"
     217    if [ -e "$bigdir/$mappath" ] ; then
    218218    echo "$mappath already added" >> $LOGFILE
    219219    return
    220     elif [ -d "$bigdir/$mappath" ] ; then
    221         echo "Cannot add $mappath: it's a directory. Sorry."
    222         return
    223     fi
    224     echo "Added kbd map $mappath" >> $LOGFILE
    225     if [ ! -e "$mappath" ] ; then
    226         mappath=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
    227         if [ ! -e "$mappath" ] ; then
    228             LogIt "Cannot add $mappath: kbd map file not found"
    229             return
    230         fi
    231     else
     220    elif [ -d "$bigdir/$mappath" ] ; then
     221        echo "Cannot add $mappath: it's a directory. Sorry."
     222        return
     223    fi
     224    echo "Added kbd map $mappath" >> $LOGFILE
     225    if [ ! -e "$mappath" ] ; then
     226        mappath=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
     227        if [ ! -e "$mappath" ] ; then
     228            LogIt "Cannot add $mappath: kbd map file not found"
     229            return
     230        fi
     231    else
    232232    echo -en "`basename $mappath | tr '.' '#' | sed s/#kmap#gz// | sed s/#inc#gz//` " | tr '#' '.'
    233     fi
    234 
    235     mkdir -p $bigdir/etc
    236     cp --parents -pRdf $mappath $bigdir || LogIt "AKMF -- Could not copy $mappath to $bigdir"
    237     if [ "`echo $mappath | fgrep ".gz"`" ] ; then
    238         included_list=`gzip -dc $mappath | fgrep -i include | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
    239     else
    240         included_list=`cat $mappath | fgrep -i include | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
    241     fi
    242     for included_item in $included_list ; do
     233    fi
     234
     235    mkdir -p $bigdir/etc
     236    cp --parents -pRdf $mappath $bigdir || LogIt "AKMF -- Could not copy $mappath to $bigdir"
     237    if [ "`echo $mappath | fgrep ".gz"`" ] ; then
     238        included_list=`gzip -dc $mappath | fgrep -i include | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
     239    else
     240        included_list=`cat $mappath | fgrep -i include | sed s/'"'// | sed s/'"'// | cut -d' ' -f2`
     241    fi
     242    for included_item in $included_list ; do
    243243    if [ ! -e "$included_item" ] ; then
    244             sss=`find $KEYDIR/keymaps | fgrep "${included_item}.inc"`
    245         [ "$sss" = "" ] && sss=`find $KEYDIR/keymaps | fgrep "$included_item"`
    246         for ii in $sss ; do
    247                 [ -e "$ii" ] && AddKeyboardMappingFile $ii
    248         done
    249     else
    250         AddKeyboardMappingFile $included_item
    251     fi
    252     done
     244            sss=`find $KEYDIR/keymaps | fgrep "${included_item}.inc"`
     245        [ "$sss" = "" ] && sss=`find $KEYDIR/keymaps | fgrep "$included_item"`
     246        for ii in $sss ; do
     247                [ -e "$ii" ] && AddKeyboardMappingFile $ii
     248        done
     249    else
     250        AddKeyboardMappingFile $included_item
     251    fi
     252    done
    253253}
    254254
     
    260260
    261261ChopUpAndCopyFile() {
    262     local filename slicesize outdir res biggienumber filesize sliceno noof_slices testfile scratchfile
    263     filename=$1
    264     outdir=$2
    265     slicesize=$3
    266     biggienumber=$4
    267 
    268     [ -d "$filename" ] && Die "Cannot chop up $filename: it's a directory. Please amend deplist.txt accordingly."
    269     mkdir -p $outdir
    270 
    271     sliceno=0
    272     scratchfile=$TMP_ROOT/blah.$$.dat
    273     cp -f $filename $scratchfile || Die "CUACF -- cannot copy $filename to $scratchfile - did you run out of disk space?"
    274     [ "`head $scratchfile -n1 | fgrep "bin/sh"`" != "" ] && StripComments $scratchfile "-$filename-"
    275     [ "`echo "$filename" | fgrep "etc/termcap"`" != "" ] && StripComments $scratchfile "-$filename-"
    276     if [ "`echo "$filename" | fgrep "lib/modules/" | grep "\.*o\.gz"`" != "" ] ; then
     262    local filename slicesize outdir res biggienumber filesize sliceno noof_slices testfile scratchfile
     263    filename=$1
     264    outdir=$2
     265    slicesize=$3
     266    biggienumber=$4
     267
     268    [ -d "$filename" ] && Die "Cannot chop up $filename: it's a directory. Please amend deplist.txt accordingly."
     269    mkdir -p $outdir
     270
     271    sliceno=0
     272    scratchfile=$TMP_ROOT/blah.$$.dat
     273    cp -f $filename $scratchfile || Die "CUACF -- cannot copy $filename to $scratchfile - did you run out of disk space?"
     274    [ "`head $scratchfile -n1 | fgrep "bin/sh"`" != "" ] && StripComments $scratchfile "-$filename-"
     275    [ "`echo "$filename" | fgrep "etc/termcap"`" != "" ] && StripComments $scratchfile "-$filename-"
     276    if [ "`echo "$filename" | fgrep "lib/modules/" | grep "\.*o\.gz"`" != "" ] ; then
    277277    mv $scratchfile $scratchfile.gz
    278278    gunzip -f $scratchfile || LogIt "Cannot gunzip $scratchfile.gz"
    279279    filename=`echo "$filename" | tr '.' '#' | sed s/#o#gz/#o/ | sed s/#ko#gz/#ko/ | tr '#' '.'`
    280     fi
    281     filesize=`du -sk $scratchfile | cut -f1`
    282     noof_slices=$(($filesize/$slicesize))
    283     echo "$filename" > $outdir/slice-$biggienumber.name
    284     echo "$filesize" > $outdir/slice-$biggienumber.size
    285     [ -x "$scratchfile" ] && StripExecutable $scratchfile "-$filename-"
    286     while [ "$sliceno" -le "$noof_slices" ] ; do
    287         dd if=$scratchfile skip=$(($sliceno*$slicesize)) of=$outdir/slice-$biggienumber.`printf "%03d" $sliceno` bs=1k count=$slicesize 2> /dev/null
    288         sliceno=$(($sliceno+1))
    289     done
    290     rm -f $scratchfile
     280    fi
     281    filesize=`du -sk $scratchfile | cut -f1`
     282    noof_slices=$(($filesize/$slicesize))
     283    echo "$filename" > $outdir/slice-$biggienumber.name
     284    echo "$filesize" > $outdir/slice-$biggienumber.size
     285    [ -x "$scratchfile" ] && StripExecutable $scratchfile "-$filename-"
     286    while [ "$sliceno" -le "$noof_slices" ] ; do
     287        dd if=$scratchfile skip=$(($sliceno*$slicesize)) of=$outdir/slice-$biggienumber.`printf "%03d" $sliceno` bs=1k count=$slicesize 2> /dev/null
     288        sliceno=$(($sliceno+1))
     289    done
     290    rm -f $scratchfile
    291291}
    292292
    293293
    294294CopyBootBFile() {
    295     local copy_to copy_from possible_locations liloc
    296     copy_to=$1
    297     copy_from=/boot/boot.b
    298     liloc=`which lilo.real 2>/dev/null`
    299     [ $liloc ] || liloc=`which lilo 2>/dev/null`
    300     if [ $liloc ]; then
    301         if ! [ `strings $liloc | grep "boot\.b"` ]; then
    302             LogIt "boot.b files built into lilo; I'll create a dummy."
    303             > $copy_to
    304             return 0
    305         fi
    306     fi
    307     if [ ! -f "$copy_from" ] ; then
    308         LogIt "OK, you don't have a /boot/boot.b file, which is odd because most _good_ Linux distributions come with one, even if it's only a softlink"
    309         copy_from=`cat /etc/lilo.conf | grep install= | grep "\.b" | cut -d'=' -f2`
    310         if [ ! -f "$copy_from" ] ; then
    311             LogIt "Nor can I find it from your /etc/lilo.conf file. This is very odd."
    312             copy_from=`FindSensibleBootBFile`
    313             LogIt "I'm going to use '$copy_from'"
    314         fi
    315     fi
    316     cp -f $copy_from $copy_to || LogIt "CBBF -- warning -- cannot find your boot.b file. That's it, I quit... (j/k)"
     295    local copy_to copy_from possible_locations liloc
     296    copy_to=$1
     297    copy_from=/boot/boot.b
     298    liloc=`which lilo.real 2>/dev/null`
     299    [ $liloc ] || liloc=`which lilo 2>/dev/null`
     300    if [ $liloc ]; then
     301        if ! [ `strings $liloc | grep "boot\.b"` ]; then
     302            LogIt "boot.b files built into lilo; I'll create a dummy."
     303            > $copy_to
     304            return 0
     305        fi
     306    fi
     307    if [ ! -f "$copy_from" ] ; then
     308        LogIt "OK, you don't have a /boot/boot.b file, which is odd because most _good_ Linux distributions come with one, even if it's only a softlink"
     309        copy_from=`cat /etc/lilo.conf | grep install= | grep "\.b" | cut -d'=' -f2`
     310        if [ ! -f "$copy_from" ] ; then
     311            LogIt "Nor can I find it from your /etc/lilo.conf file. This is very odd."
     312            copy_from=`FindSensibleBootBFile`
     313            LogIt "I'm going to use '$copy_from'"
     314        fi
     315    fi
     316    cp -f $copy_from $copy_to || LogIt "CBBF -- warning -- cannot find your boot.b file. That's it, I quit... (j/k)"
    317317}
    318318
     
    321321
    322322CopyDependenciesToDirectory() {
    323     local outdir incoming fname filesize counter
    324     outdir=$1
    325     mkdir -p $outdir
    326     incoming=`ReadLine`
    327     counter=0
    328     while [ "$incoming" != "" ] ; do
     323    local outdir incoming fname filesize counter
     324    outdir=$1
     325    mkdir -p $outdir
     326    incoming=`ReadLine`
     327    counter=0
     328    while [ "$incoming" != "" ] ; do
    329329    if [ -d "$incoming" ] ; then
    330             find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir
    331         elif [ -e "$incoming" ] ; then
    332             filesize=`du -sk $incoming | cut -f1`
    333             if [ "$filesize" -gt "$(($CHOPSIZE*2))" ] && [ ! -h "$incoming" ] ; then
    334                 ChopUpAndCopyFile $incoming $outdir $CHOPSIZE $BIGNO
    335                 BIGNO=$(($BIGNO+1))
    336             else
    337                 cp --parents -Rdf $incoming $outdir || Die "Cannot copy $incoming to $outdir - did you run out of disk space?"
     330            find $incoming/* -maxdepth 0 2> /dev/null | CopyDependenciesToDirectory $outdir
     331        elif [ -e "$incoming" ] ; then
     332            filesize=`du -sk $incoming | cut -f1`
     333            if [ "$filesize" -gt "$(($CHOPSIZE*2))" ] && [ ! -h "$incoming" ] ; then
     334                ChopUpAndCopyFile $incoming $outdir $CHOPSIZE $BIGNO
     335                BIGNO=$(($BIGNO+1))
     336            else
     337                cp --parents -Rdf $incoming $outdir || Die "Cannot copy $incoming to $outdir - did you run out of disk space?"
    338338        if [ "`echo "$incoming" | grep "lib/modules/.*\..*o\.gz"`" != "" ] ; then
    339339            gunzip -f $outdir/$incoming || LogIt "Cannot gunzip $outdir/$incoming"
    340340        fi
    341341        [ -x "$outdir" ] && StripExecutable $outdir "-$filename-"
    342             fi
    343         counter=$(($counter+1))
    344         if [ "$counter" -ge "5" ] ; then
     342            fi
     343        counter=$(($counter+1))
     344        if [ "$counter" -ge "5" ] ; then
    345345        counter=0
    346             echo -en "."
    347         fi
    348         fi
    349         incoming=`ReadLine`
    350     done
     346            echo -en "."
     347        fi
     348        fi
     349        incoming=`ReadLine`
     350    done
    351351}
    352352
     
    354354
    355355CopyImageToDisk() {
    356     local image dev procno res comment
    357     image=$1
    358     dev=$2
    359     comment=$3
    360     [ ! -f "$image" ] && [ ! -b "$image" ] && Die "Image $image does not exist. Did you run out of disk space?"
    361     Prompt "About to write $comment. Please press ENTER."
    362     echo -en "Formatting disk..."
    363     if which fdformat > /dev/null ; then
     356    local image dev procno res comment
     357    image=$1
     358    dev=$2
     359    comment=$3
     360    [ ! -f "$image" ] && [ ! -b "$image" ] && Die "Image $image does not exist. Did you run out of disk space?"
     361    Prompt "About to write $comment. Please press ENTER."
     362    echo -en "Formatting disk..."
     363    if which fdformat > /dev/null ; then
    364364    fdformat -n $dev > /dev/null 2> /dev/null || Die "Cannot format $dev - is your Linux distro broken?"
    365     elif which superformat > /dev/null ; then
     365    elif which superformat > /dev/null ; then
    366366    superformat $dev > /dev/null 2> /dev/null || Die "Cannot format $dev - is your Linux distro broken?"
    367     else
     367    else
    368368    Die "Please install either fdformat or superformat."
    369     fi
    370     echo -en "\rWriting $comment"
    371     if echo $image | grep "mindi-[r|b]oot\.1440" &> /dev/null ; then
     369    fi
     370    echo -en "\rWriting $comment"
     371    if echo $image | grep "mindi-[r|b]oot\.1440" &> /dev/null ; then
    372372    cat $image > $dev &
    373     else
     373    else
    374374    dd if=$image of=$dev &> /dev/null &
    375     fi
    376     procno=$!
    377     ps $procno > /dev/null 2> /dev/null
    378     while [ "$?" -eq "0" ] ; do
    379         sleep 3
    380         echo -en "."
    381         ps $procno > /dev/null 2> /dev/null
    382     done
    383     echo -e "$DONE"
    384     LogIt "$comment has been written."
     375    fi
     376    procno=$!
     377    ps $procno > /dev/null 2> /dev/null
     378    while [ "$?" -eq "0" ] ; do
     379        sleep 3
     380        echo -en "."
     381        ps $procno > /dev/null 2> /dev/null
     382    done
     383    echo -e "$DONE"
     384    LogIt "$comment has been written."
    385385}
    386386
     
    390390
    391391CountItemsIn() {
    392     local r
    393     r=0
    394     for q in $1 ; do
     392    local r
     393    r=0
     394    for q in $1 ; do
    395395    r=$(($r+1))
    396     done
    397     echo $r
     396    done
     397    echo $r
    398398}
    399399
     
    404404
    405405CreateDataDiskImagesFromTarballs() {
    406     local tardir outdir diskno noof_disks kp
    407     tardir=$1
    408     outdir=$2
    409     noof_disks=$3
    410 
    411     mkdir -p $outdir
    412     diskno=1
    413     echo -en "Creating data disk "
    414     while [ "$diskno" -le "$noof_disks" ] ; do
     406    local tardir outdir diskno noof_disks kp
     407    tardir=$1
     408    outdir=$2
     409    noof_disks=$3
     410
     411    mkdir -p $outdir
     412    diskno=1
     413    echo -en "Creating data disk "
     414    while [ "$diskno" -le "$noof_disks" ] ; do
    415415    echo -en "#$diskno..."
    416416    cp -f $tardir/$diskno.tar.gz $outdir || LogIt "[line 250] Cannot copy $tardir/$diskno.tar.gz to $outdir"
    417         CreateOneDataDiskImage $tardir/$diskno.tar.gz $outdir/mindi-data-$diskno.img $diskno $noof_disks
    418         diskno=$(($diskno+1))
    419     done
    420     mv -f $tardir/all.tar.gz $outdir
    421     du -sk $outdir/*gz >> $LOGFILE
    422     echo -e "$DONE"
     417        CreateOneDataDiskImage $tardir/$diskno.tar.gz $outdir/mindi-data-$diskno.img $diskno $noof_disks
     418        diskno=$(($diskno+1))
     419    done
     420    mv -f $tardir/all.tar.gz $outdir
     421    du -sk $outdir/*gz >> $LOGFILE
     422    echo -e "$DONE"
    423423}
    424424
     
    426426
    427427CreateOneDataDiskImage() {
    428     local tarball imagefile dev diskno noof_disks mountpoint
    429     tarball=$1
    430     imagefile=$2
    431     diskno=$3
    432     noof_disks=$4
    433 
    434     mountpoint=$TMP_ROOT/mountpoint.$$
    435     mkdir -p $mountpoint
    436     dd if=/dev/zero of=$imagefile bs=1k count=1440 &> /dev/null || LogIt "Cannot dd (CODI)\n"
    437     mke2fs -N 12 -F $imagefile > /tmp/mke2fs.$$ 2>> /tmp/mke2fs.$$
    438     [ "$?" -ne "0" ] && cat /tmp/mke2fs.$$
    439     rm -f /tmp/mke2fs.$$
    440     mount -t ext2 -o loop $imagefile $mountpoint || Die "Can't loopmount $mountpoint; does your kernel support loopfs? If not, please recompile your kernel. Your Linux distro is broken."
    441     mv $tarball $mountpoint/
    442     if [ "$?" -ne "0" ] ; then
     428    local tarball imagefile dev diskno noof_disks mountpoint
     429    tarball=$1
     430    imagefile=$2
     431    diskno=$3
     432    noof_disks=$4
     433
     434    mountpoint=$TMP_ROOT/mountpoint.$$
     435    mkdir -p $mountpoint
     436    dd if=/dev/zero of=$imagefile bs=1k count=1440 &> /dev/null || LogIt "Cannot dd (CODI)\n"
     437    mke2fs -N 12 -F $imagefile > /tmp/mke2fs.$$ 2>> /tmp/mke2fs.$$
     438    [ "$?" -ne "0" ] && cat /tmp/mke2fs.$$
     439    rm -f /tmp/mke2fs.$$
     440    mount -t ext2 -o loop $imagefile $mountpoint || Die "Can't loopmount $mountpoint; does your kernel support loopfs? If not, please recompile your kernel. Your Linux distro is broken."
     441    mv $tarball $mountpoint/
     442    if [ "$?" -ne "0" ] ; then
    443443    umount $mountpoint
    444444    Die "Tarball $tarball is too big for disk! (CODI)\nTell Hugo to adjust MAX_COMPRESSED_SIZE"
    445     fi
    446     [ "$diskno" -eq "$noof_disks" ] && echo "This is the last disk ($diskno=$noof_disks)" >> $mountpoint/LAST-DISK
    447     umount $mountpoint || LogIt "Cannot umount (CODI)\n"
    448     rmdir $mountpoint || LogIt "Cannot rmdir (CODI)\n"
     445    fi
     446    [ "$diskno" -eq "$noof_disks" ] && echo "This is the last disk ($diskno=$noof_disks)" >> $mountpoint/LAST-DISK
     447    umount $mountpoint || LogIt "Cannot umount (CODI)\n"
     448    rmdir $mountpoint || LogIt "Cannot rmdir (CODI)\n"
    449449}
    450450
     
    452452
    453453DidMondoCallMe() {
    454     local res
    455 
    456     res=0
    457     [ "`ps ax | fgrep "mondoarchive" | grep -v "grep"`" ] && res=$(($res+1))
    458     [ -f "/var/run/monitas-mondo.pid" ] && res=$(($res+1))
    459     [ "$res" -gt "1" ] && echo "yes"
     454    local res
     455
     456    res=0
     457    [ "`ps ax | fgrep "mondoarchive" | grep -v "grep"`" ] && res=$(($res+1))
     458    [ -f "/var/run/monitas-mondo.pid" ] && res=$(($res+1))
     459    [ "$res" -gt "1" ] && echo "yes"
    460460}
    461461
     
    464464
    465465Die() {
    466     local my_partitions i
    467     echo "MINDI_VERSION is $MINDI_VERSION" >> $LOGFILE
    468     if [ "$1" = "" ] ; then
     466    local my_partitions i
     467    echo "MINDI_VERSION is $MINDI_VERSION" >> $LOGFILE
     468    if [ "$1" = "" ] ; then
    469469    LogIt "Fatal error\n"
    470     else
     470    else
    471471    LogIt "Fatal error. $1\n"
    472     fi
    473     sync
    474     cd /
    475 
    476     my_partitions=`mount | fgrep $$ | cut -f1 -d' '`
    477     [ "$my_partitions" != "" ] && umount $my_partitions
    478     [ "$TMP_ROOT" != "/tmp" ] && rm -Rf $TMP_ROOT
    479     cd /tmp
    480     mkdir -p mindi.err
    481     for i in /tmp/mindi-needlist.txt /etc/fstab /etc/lilo.conf /etc/raidtab $LOGFILE /var/log/mondo-archive.log /tmp/mountlist.txt.$$ ; do
    482     [ -e "$i" ] && cp -f $i mindi.err/
    483     done
    484     rm -f mindi.err.*.tgz
    485     tar -c mindi.err -f- | gzip -9 > mindi.err.$$.tgz
    486     cd /
    487     rm -Rf mindi.err /tmp/mountlist.txt.$$
    488     LogIt "Please e-mail a copy of /tmp/mindi.err.$$.tgz to the mailing list."
    489     LogIt "See http://www.mondorescue.org for more information."
    490     LogIt "WE CANNOT HELP unless you enclose that file."
    491     exit 1
     472    fi
     473    sync
     474    cd /
     475
     476    my_partitions=`mount | fgrep $$ | cut -f1 -d' '`
     477    [ "$my_partitions" != "" ] && umount $my_partitions
     478    [ "$TMP_ROOT" != "/tmp" ] && rm -Rf $TMP_ROOT
     479    cd /tmp
     480    mkdir -p mindi.err
     481    for i in /etc/fstab /etc/lilo.conf /etc/raidtab $LOGFILE /var/log/mondo-archive.log /tmp/mountlist.txt.$$ $FDISKLOG ; do
     482        [ -e "$i" ] && cp -f $i mindi.err/
     483    done
     484    rm -f mindi.err.*.tgz
     485    tar -cf - mindi.err | gzip -9 > mindi.err.$$.tgz
     486    rm -Rf mindi.err /tmp/mountlist.txt.$$ mindilinux $FDISKLOG
     487    LogIt "Please e-mail a copy of /tmp/mindi.err.$$.tgz to the mailing list."
     488    LogIt "See http://www.mondorescue.org for more information."
     489    LogIt "WE CANNOT HELP unless you enclose that file."
     490    exit 1
    492491}
    493492
     
    496495
    497496DropOptimizedLibraries() {
    498     local outdir filelist list_of_optimized_libraries optimized_lib_name vanilla_lib_name reason msg resolved res
    499     filelist=$1
    500     outdir=$2
    501 
    502     list_of_optimized_libraries=`cat $filelist | grep "lib/i[5-7]86/"`
    503     if [ "$list_of_optimized_libraries" = "" ] ; then
     497    local outdir filelist list_of_optimized_libraries optimized_lib_name vanilla_lib_name reason msg resolved res
     498    filelist=$1
     499    outdir=$2
     500
     501    list_of_optimized_libraries=`cat $filelist | grep "lib/i[5-7]86/"`
     502    if [ "$list_of_optimized_libraries" = "" ] ; then
    504503    return 0
    505     fi
    506     echo -en "Dropping i686-optimized libraries if appropriate"
    507     for optimized_lib_name in $list_of_optimized_libraries ; do
     504    fi
     505    echo -en "Dropping i686-optimized libraries if appropriate"
     506    for optimized_lib_name in $list_of_optimized_libraries ; do
    508507    echo -en "."
    509508    reason=""
     
    513512    echo "Adding $resolved to filelist" >> $LOGFILE
    514513    while [ -h "$resolved" ] ; do
    515         resolved=`ls $resolved -l|tr -s ' ' '\t'|$AWK '{printf $NF;}'`
    516         LocateFile $resolved >> $filelist
    517         echo "Adding $resolved to filelist" >> $LOGFILE
     514        resolved=`ls $resolved -l|tr -s ' ' '\t'|$AWK '{printf $NF;}'`
     515        LocateFile $resolved >> $filelist
     516        echo "Adding $resolved to filelist" >> $LOGFILE
    518517    done
    519518    mkdir -p $outdir$optimized_lib_name > /dev/null 2> /dev/null
     
    525524    echo "$vanilla_lib_name" >> $filelist.tmp
    526525    mv -f $filelist.tmp $filelist
    527     done
    528     cat $filelist | sort | $AWK '{ print $1; }' | uniq > $filelist.tmp
    529     mv -f $filelist.tmp $filelist
    530     echo -e "$DONE"
     526    done
     527    cat $filelist | sort | $AWK '{ print $1; }' | uniq > $filelist.tmp
     528    mv -f $filelist.tmp $filelist
     529    echo -e "$DONE"
    531530}
    532531
     
    535534
    536535FindAndAddUserKeyboardMappingFile() {
    537     local r res mapfile mappath included_item included_list keyfile mp locale
    538     LogIt "Analyzing your keyboard's configuration."
    539     KEYDIR=/lib/kbd
    540     [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share/kbd     # Slackware
    541     [ ! -e "$KEYDIR" ] && KEYDIR=/usr/lib/kbd
    542     [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share
    543     if [ ! -e "$KEYDIR" ] ; then
     536    local r res mapfile mappath included_item included_list keyfile mp locale
     537    LogIt "Analyzing your keyboard's configuration."
     538    KEYDIR=/lib/kbd
     539    [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share/kbd     # Slackware
     540    [ ! -e "$KEYDIR" ] && KEYDIR=/usr/lib/kbd
     541    [ ! -e "$KEYDIR" ] && KEYDIR=/usr/share
     542    if [ ! -e "$KEYDIR" ] ; then
    544543    LogIt "Keyboard mapping directory not found. I shall use default map at boot-time."
    545544    return 0
    546     fi
    547     if [ -e "/etc/sysconfig/keyboard" ] ; then
     545    fi
     546    if [ -e "/etc/sysconfig/keyboard" ] ; then
    548547    echo "Red Hat-style config detected." >> $LOGFILE
    549548    keyfile=/etc/sysconfig/keyboard
    550     elif [ -e "/etc/rc.d/rc.keymap" ] ; then
     549    elif [ -e "/etc/rc.d/rc.keymap" ] ; then
    551550    echo "Slackware-style config detected." >> $LOGFILE
    552551    keyfile=/etc/rc.d/rc.keymap
    553     elif [ -e "/etc/rc.config" ] ; then
    554         echo "Debian-style config detected." >> $LOGFILE
     552    elif [ -e "/etc/rc.config" ] ; then
     553        echo "Debian-style config detected." >> $LOGFILE
    555554    keyfile=/etc/rc.config
    556     elif [ -e "/etc/console/boottime.kmap.gz" ] ; then
    557         echo "Debian-style config detected." >> $LOGFILE
     555    elif [ -e "/etc/console/boottime.kmap.gz" ] ; then
     556        echo "Debian-style config detected." >> $LOGFILE
    558557    echo -en "Adding the following keyboard mapping tables: "
    559558    mkdir -p $bigdir/tmp
     
    564563    echo -e "$DONE"
    565564    return 0
    566     else
     565    else
    567566    echo -en "Searching for rc.config ..."
    568567    keyfile=`find /etc -name rc.config | head -n1`
    569568    if [ "$keyfile" = "" ] || [ ! -e "$keyfile" ] ; then
    570         LogIt "Unknown config detected. Default keyboard map will be used."
    571         return
    572     else
    573         echo "Found $keyfile" >> $LOGFILE
    574     fi
    575     fi
    576     if [ ! -e "$KEYDIR/keymaps" ] ; then
    577         LogIt "Keyboard mapping directory not found. Default keyboard map will be used."
    578         return
    579     fi
    580     echo "keyfile=$keyfile" >> $LOGFILE
    581     locale=`cat "$keyfile" |fgrep KEYTABLE | tr -d '"' |cut -d'=' -f2`
    582     [ ! "$locale" ] && locale=`cat "$keyfile" | grep '.map$' | sed 's/^.* //'`      # Slackware
    583     echo "locale=$locale" >> $LOGFILE
    584     mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | fgrep "${locale}." | grep -vx " *#.*"`
    585     [ ! "$mp" ] && mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
    586     for i in $mp ; do
    587         mappath=$i
    588         [ -e "$i" ] && [ ! -d "$i" ] && break
    589     done
    590     if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
    591        mappath=$(locate */kbd/keymaps/*/$locale)
    592     fi
    593     echo "mappath = $mappath" >> $LOGFILE
    594     if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
     569        LogIt "Unknown config detected. Default keyboard map will be used."
     570        return
     571    else
     572        echo "Found $keyfile" >> $LOGFILE
     573    fi
     574    fi
     575    if [ ! -e "$KEYDIR/keymaps" ] ; then
     576        LogIt "Keyboard mapping directory not found. Default keyboard map will be used."
     577        return
     578    fi
     579    echo "keyfile=$keyfile" >> $LOGFILE
     580    locale=`cat "$keyfile" |fgrep KEYTABLE | tr -d '"' |cut -d'=' -f2`
     581    [ ! "$locale" ] && locale=`cat "$keyfile" | grep '.map$' | sed 's/^.* //'`      # Slackware
     582    echo "locale=$locale" >> $LOGFILE
     583    mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | fgrep "${locale}." | grep -vx " *#.*"`
     584    [ ! "$mp" ] && mp=`find $KEYDIR/keymaps | grep "i[3-8]86" | grep "$locale[^r][^/]" | grep -vx " *#.*"`
     585    for i in $mp ; do
     586        mappath=$i
     587        [ -e "$i" ] && [ ! -d "$i" ] && break
     588    done
     589    if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
     590       mappath=$(locate */kbd/keymaps/*/$locale)
     591    fi
     592    echo "mappath = $mappath" >> $LOGFILE
     593    if [ ! -e "$mappath" ] || [ -d "$mappath" ] ; then
    595594    LogIt "Keyboard mapping file not found. Default keyboard map will be used."
    596595    return
    597     fi
    598     echo -en "Adding the following keyboard mapping tables: "
    599     mkdir -p $bigdir/tmp
    600     echo "$mappath" > $bigdir/tmp/KEYMAP-LIVES-HERE
    601     KBDEPTH=0
    602     AddKeyboardMappingFile $mappath
    603     echo -e "$DONE"
    604     return 0
     596    fi
     597    echo -en "Adding the following keyboard mapping tables: "
     598    mkdir -p $bigdir/tmp
     599    echo "$mappath" > $bigdir/tmp/KEYMAP-LIVES-HERE
     600    KBDEPTH=0
     601    AddKeyboardMappingFile $mappath
     602    echo -e "$DONE"
     603    return 0
    605604}
    606605
     
    612611# nice patch from Martin Fürstenau
    613612    for mh in /usr/lib /usr/opt /usr/share /usr/local /usr/local/share /usr/share/local /opt /opt/share /usr /ramdisk/usr/local/share /ramdisk/usr/share ; do
    614         if [ ! -L $mh ] ; then
    615            MH_PATH=$mh
    616            SYMLINK=0
    617            while [ $MH_PATH != "/" ] ; do
    618            MH_PATH=`dirname $MH_PATH`
    619                if [ -L $MH_PATH ] ; then
     613        if [ ! -L $mh ] ; then
     614           MH_PATH=$mh
     615           SYMLINK=0
     616           while [ $MH_PATH != "/" ] ; do
     617           MH_PATH=`dirname $MH_PATH`
     618               if [ -L $MH_PATH ] ; then
    620619          SYMLINK=1
    621            fi
    622            done
    623 
    624            if [ $SYMLINK -ne 1 ] ; then
    625               if [ -d "$mh/mindi" ] && [ -e "$mh/mindi/aux-tools" ] ; then
     620           fi
     621           done
     622
     623           if [ $SYMLINK -ne 1 ] ; then
     624              if [ -d "$mh/mindi" ] && [ -e "$mh/mindi/aux-tools" ] ; then
    626625              [ "$MINDI_HOME" ] && Die "You have multiple instances of Mindi - one at $MINDI_HOME and one at $mh/mindi"
    627                       MINDI_HOME=$mh/mindi
    628               fi
     626                      MINDI_HOME=$mh/mindi
     627              fi
    629628          if [ -d "$mh/mondo" ] && [ -e "$mh/mondo/restore-scripts" ] ; then
    630629              [ "$MONDO_HOME" ] && Die "You have multiple instances of Mondo - one at $MONDO_HOME and one at $mh/mondo"
    631630              MONDO_HOME=$mh/mondo
    632631          fi
    633            fi
    634         fi
     632           fi
     633        fi
    635634    done
    636635# end patch
     
    672671
    673672FindLiloBinary() {
    674     if which lilo &> /dev/null ; then
     673    if which lilo &> /dev/null ; then
    675674    if which lilo.real > /dev/null 2> /dev/null ; then
    676         LILO_EXE=lilo.real
    677         LogIt "lilo.real found; will be used instead of lilo (*grumble* *mutter*)"
    678     else
    679         LILO_EXE=lilo
     675        LILO_EXE=lilo.real
     676        LogIt "lilo.real found; will be used instead of lilo (*grumble* *mutter*)"
     677    else
     678        LILO_EXE=lilo
    680679    fi
    681680    $LILO_EXE -V | fgrep "21.6" > /dev/null && Die "Please upgrade LILO. Your verison has a serious bug. If you're not _using_ LILO, fine, uninstall it. :)"
    682     else
     681    else
    683682    LILO_EXE=`which false`
    684     fi
     683    fi
    685684}
    686685
    687686FindELiloBinary() {
    688     if which elilo &> /dev/null ; then
     687    if which elilo &> /dev/null ; then
    689688    LILO_EXE=elilo
    690     else
     689    else
    691690    LILO_EXE=`which false`
    692     fi
     691    fi
    693692}
    694693
    695694
    696695FixPathIfBroken() {
    697         if [ -e "/sbin/mkfs" ] && ! which mkfs &> /dev/null ; then
    698         PATH=$PATH:/sbin:/usr/sbin
    699         export PATH
    700         echo "Your PATH did not include /sbin or /usr/sbin. I have fixed that, temporarily." >> $LOGFILE
    701         echo "However, you may wish to ask your vendor to provide a permanent fix..." >> $LOGFILE
    702         echo "You might like to call 'su -' instead of 'su', for example." >> $LOGFILE
     696        if [ -e "/sbin/mkfs" ] && ! which mkfs &> /dev/null ; then
     697        PATH=$PATH:/sbin:/usr/sbin
     698        export PATH
     699        echo "Your PATH did not include /sbin or /usr/sbin. I have fixed that, temporarily." >> $LOGFILE
     700        echo "However, you may wish to ask your vendor to provide a permanent fix..." >> $LOGFILE
     701        echo "You might like to call 'su -' instead of 'su', for example." >> $LOGFILE
    703702    fi
    704703}
     
    707706
    708707FindSensibleBootBFile() {
    709     local i out last
    710     out=""
    711     last=""
    712     for i in `find /boot -type f | grep -v chain | grep -v os2 | sort -u` ; do
     708    local i out last
     709    out=""
     710    last=""
     711    for i in `find /boot -type f | grep -v chain | grep -v os2 | sort -u` ; do
    713712    if [ "`strings $i 2> /dev/null | head -n1`" = "LILO" ] ; then
    714         out="$out $i"
    715             last="$i"
    716     fi
    717     done
    718     echo "$last"
     713        out="$out $i"
     714            last="$i"
     715    fi
     716    done
     717    echo "$last"
    719718}
    720719
     
    722721
    723722FindSpecificModuleInPath() {
    724     local modpaths pwd line
    725     pwd=`pwd`
    726     if [ "$YOUR_KERNEL_SUCKS" ] ; then
     723    local modpaths pwd line
     724    pwd=`pwd`
     725    if [ "$YOUR_KERNEL_SUCKS" ] ; then
    727726    cd $TMP_ROOT
    728     else
     727    else
    729728    cd /
    730     fi
    731     if [ ! -e "$1" ] ; then
     729    fi
     730    if [ ! -e "$1" ] ; then
    732731    LogIt "Warning - cannot search specific path '$1'"
    733732    return 1
    734     fi
    735     modpaths=`find $1 -name $2.*o -type f`
    736     [ "$?" -ne "0" ] && Die "find $1 -name $2.o -type f --- failed"
    737     [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.o.gz -type f`
    738     [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.ko.gz -type f`
    739     [ "$modpaths" = "" ] && modpaths=`find $1 -name $2 -type f`
    740     echo "$modpaths"
    741     cd $pwd
     733    fi
     734    modpaths=`find $1 -name $2.*o -type f`
     735    [ "$?" -ne "0" ] && Die "find $1 -name $2.o -type f --- failed"
     736    [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.o.gz -type f`
     737    [ "$modpaths" = "" ] && modpaths=`find $1 -name $2.ko.gz -type f`
     738    [ "$modpaths" = "" ] && modpaths=`find $1 -name $2 -type f`
     739    echo "$modpaths"
     740    cd $pwd
    742741}
    743742
     
    745744
    746745GenerateGiantDependencyList() {
    747     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
    748 
    749     echo -en "Analyzing dependency requirements"
    750     outfile=$1
    751     tempfile=$TMP_ROOT/$$.txt
    752     incoming=`ReadLine`
    753 
    754     > $tempfile
    755     progress=0
    756     res=0
    757     noof_lines=$2
    758     while [ "$incoming" != "" ] ; do
     746    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
     747
     748    echo -en "Analyzing dependency requirements"
     749    outfile=$1
     750    tempfile=$TMP_ROOT/$$.txt
     751    incoming=`ReadLine`
     752
     753    > $tempfile
     754    progress=0
     755    res=0
     756    noof_lines=$2
     757    while [ "$incoming" != "" ] ; do
    759758    if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
    760759#       echo "Skipping '$incoming'"
    761         incoming=`ReadLine`
    762         continue
     760        incoming=`ReadLine`
     761        continue
    763762    fi
    764763    if [ "$incoming" = "LVMFILES:" ] ; then
     
    767766#   echo "Processing '$incoming'."
    768767#   sleep 1
    769         filelist=`GenerateListForFile "$incoming"`
    770         r=$?
    771         [ "$r" -ne "0" ] && LogIt "$incoming not found\n"
    772         res=$(($res+$r))
     768        filelist=`GenerateListForFile "$incoming"`
     769        r=$?
     770        [ "$r" -ne "0" ] && LogIt "$incoming not found\n"
     771        res=$(($res+$r))
    773772#   echo "'$incoming' generates filelist '$filelist'" >> $LOGFILE
    774         for fname in $filelist ; do
    775             [ "$fname" != "" ] && echo "$fname" >> $tempfile
     773        for fname in $filelist ; do
     774            [ "$fname" != "" ] && echo "$fname" >> $tempfile
    776775    done
    777776    progress=$(($progress+1))
     
    786785    [ "$modres" -eq "2" ] && echo -en "\t\\"
    787786    [ "$modres" -eq "3" ] && echo -en "\t|"
    788         incoming=`ReadLine`
    789     done
    790     if  [ "$incoming" = "LVMFILES:" ] ; then
     787        incoming=`ReadLine`
     788    done
     789    if  [ "$incoming" = "LVMFILES:" ] ; then
    791790    incoming=`ReadLine`
    792791    lvmversion=""
    793792    while [ "$incoming" != "" ] ; do
    794         if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
     793        if echo "$incoming" | grep -x " *#.*" &> /dev/null ; then
    795794#       echo "Skipping '$incoming'"
    796795        incoming=`ReadLine`
    797796        continue
    798         fi
    799         filelist=`GenerateListForFile "$incoming"`
    800         for tool in $filelist ; do
    801             lvmresolved=`ResolveSoftlink $tool`
    802             if echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
     797        fi
     798        filelist=`GenerateListForFile "$incoming"`
     799        for tool in $filelist ; do
     800            lvmresolved=`ResolveSoftlink $tool`
     801            if echo "$lvmresolved" | grep "lvmiopversion" &> /dev/null ; then
    803802            if [ "$lvmversion" = "" ] ; then
    804803            lvmversion=`$lvmresolved`
     
    822821            echo "$tool" >> $tempfile
    823822        fi
    824         done
    825         progress=$(($progress+1))
    826         echo -en "\r\t\t\t\t\t\t\t\t"
    827         i=$(($progress*100))
    828         i=$(($i/$noof_lines))
    829         echo -en "$i"
    830         echo -en "%"
    831         modres=$(($progress%4))
    832         [ "$modres" -eq "0" ] && echo -en "\t/"
    833         [ "$modres" -eq "1" ] && echo -en "\t-"
    834         [ "$modres" -eq "2" ] && echo -en "\t\\"
    835         [ "$modres" -eq "3" ] && echo -en "\t|"
    836         incoming=`ReadLine`
    837     done
    838     fi
    839     echo -en "$DONE\nMaking complete dependency list"
    840 
    841     cat $tempfile | tr -s '/' '/' | sort | uniq > $tempfile.new
    842     mv -f $tempfile.new $tempfile
    843     > $outfile.pre
    844     progress=0
    845     noof_lines=`cat $tempfile | wc -l`
    846     for fname in `cat $tempfile` ; do
    847         tempdepfile=`mktemp /tmp/mindilinux/tempdepfile.XXXXXX`
    848         LocateDeps $fname > $tempdepfile
     823        done
     824        progress=$(($progress+1))
     825        echo -en "\r\t\t\t\t\t\t\t\t"
     826        i=$(($progress*100))
     827        i=$(($i/$noof_lines))
     828        echo -en "$i"
     829        echo -en "%"
     830        modres=$(($progress%4))
     831        [ "$modres" -eq "0" ] && echo -en "\t/"
     832        [ "$modres" -eq "1" ] && echo -en "\t-"
     833        [ "$modres" -eq "2" ] && echo -en "\t\\"
     834        [ "$modres" -eq "3" ] && echo -en "\t|"
     835        incoming=`ReadLine`
     836    done
     837    fi
     838    echo -en "$DONE\nMaking complete dependency list"
     839
     840    cat $tempfile | tr -s '/' '/' | sort | uniq > $tempfile.new
     841    mv -f $tempfile.new $tempfile
     842    > $outfile.pre
     843    progress=0
     844    noof_lines=`cat $tempfile | wc -l`
     845    for fname in `cat $tempfile` ; do
     846        tempdepfile=`mktemp /tmp/mindilinux/tempdepfile.XXXXXX`
     847        LocateDeps $fname > $tempdepfile
    849848    echo "$fname" >> $outfile.pre
    850         cat $tempdepfile >> $outfile.pre
     849        cat $tempdepfile >> $outfile.pre
    851850#        echo "$fname ----> dependencies:-" >> $LOGFILE
    852851#        cat $tempdepfile | tr -s '/' '/' | sort | uniq >> $LOGFILE
    853852#        echo -en "(end of deplist of $fname)\n\n" >> $LOGFILE
    854         rm -f $tempdepfile
     853        rm -f $tempdepfile
    855854    progress=$(($progress+1))
    856         echo -en "\r\t\t\t\t\t\t\t\t"
    857         i=$(($progress*100))
    858         i=$(($i/$noof_lines))
    859         echo -en "$i"
    860         echo -en "%"
     855        echo -en "\r\t\t\t\t\t\t\t\t"
     856        i=$(($progress*100))
     857        i=$(($i/$noof_lines))
     858        echo -en "$i"
     859        echo -en "%"
    861860    modres=$(($progress%4))
    862         [ "$modres" -eq "0" ] && echo -en "\t/"
    863         [ "$modres" -eq "1" ] && echo -en "\t-"
    864         [ "$modres" -eq "2" ] && echo -en "\t\\"
    865         [ "$modres" -eq "3" ] && echo -en "\t|"
    866     done
    867     if [ "`DidMondoCallMe`" ] ; then
     861        [ "$modres" -eq "0" ] && echo -en "\t/"
     862        [ "$modres" -eq "1" ] && echo -en "\t-"
     863        [ "$modres" -eq "2" ] && echo -en "\t\\"
     864        [ "$modres" -eq "3" ] && echo -en "\t|"
     865    done
     866    if [ "`DidMondoCallMe`" ] ; then
    868867    mkdir -p $bigdir/tmp
    869868    mkdir -p $bigdir/sbin
    870869    mkdir -p $bigdir/bin
    871870    if [ -e "$MONDO_TMP/post-nuke.tgz" ] ; then
    872         LogIt "\nIncorporating post-nuke tarball"
    873         old_pwd=`pwd`
    874         cd $bigdir
    875         tar -zxf $MONDO_TMP/post-nuke.tgz || LogIt "Error occurred when untarring post-nuke tarball"
    876         cd $old_pwd
     871        LogIt "\nIncorporating post-nuke tarball"
     872        old_pwd=`pwd`
     873        cd $bigdir
     874        tar -zxf $MONDO_TMP/post-nuke.tgz || LogIt "Error occurred when untarring post-nuke tarball"
     875        cd $old_pwd
    877876    fi
    878877    if cp -f $MONDO_TMP/mondo*restore $bigdir/usr/bin ; then
    879             LocateDeps $bigdir/usr/bin/mondo*restore >> $outfile.pre
    880     else
    881         LogIt "Cannot find mondo*restore in mondo's tempdir, $MONDO_TMP"
    882         LogIt "I bet you've got a spare copy of Mondo or Mindi floating around on your system."
    883             LogIt "If Mindi was called by Mondo then send me a bug report. It not, type 'ps ax' to see which Mondo-related process is still running; then kill it. :-) Finally, run Mindi again."
    884             Die "Odd."
    885         fi
    886         cp -f $MONDO_TMP/BOOTLOADER.* $bigdir 2> /dev/null || LogIt "\nMondo v1.2x defaults to LILO as the bootloader, BTW."
     878            LocateDeps $bigdir/usr/bin/mondo*restore >> $outfile.pre
     879    else
     880        LogIt "Cannot find mondo*restore in mondo's tempdir, $MONDO_TMP"
     881        LogIt "I bet you've got a spare copy of Mondo or Mindi floating around on your system."
     882            LogIt "If Mindi was called by Mondo then send me a bug report. It not, type 'ps ax' to see which Mondo-related process is still running; then kill it. :-) Finally, run Mindi again."
     883            Die "Odd."
     884        fi
     885        cp -f $MONDO_TMP/BOOTLOADER.* $bigdir 2> /dev/null || LogIt "\nMondo v1.2x defaults to LILO as the bootloader, BTW."
    887886    if [ -e "$MONDO_TMP/start-nfs" ] ; then
    888         LogIt "Incorporating NFS-related settings"
    889         cp -f $MONDO_TMP/start-nfs $bigdir/sbin || Die "Cannot find start-nfs"
    890         for r in NFS-SERVER-MOUNT NFS-SERVER-PATH NFS-DEV NFS-CLIENT-IPADDR NFS-SERVER-IPADDR ; do
     887        LogIt "Incorporating NFS-related settings"
     888        cp -f $MONDO_TMP/start-nfs $bigdir/sbin || Die "Cannot find start-nfs"
     889        for r in NFS-SERVER-MOUNT NFS-SERVER-PATH NFS-DEV NFS-CLIENT-IPADDR NFS-SERVER-IPADDR ; do
    891890        cp -f $MONDO_TMP/$r $bigdir/tmp || Die "Cannot copy $r - did you run out of disk space?"
    892                 echo "Copying $r to ramdisk" >> $LOGFILE
    893         done
    894     fi
    895     fi
    896      cat $outfile.pre | tr ' ' '\n' | tr '/' '/' -s | fgrep -vx "" | sort -u | egrep -v "/libX11|/libXext|/libXi|/libgtk|/libgdk" > $outfile
    897     rm -f $tempfile $outfile.pre
    898     [ "$res" -eq "0" ] && echo -e "\r\t\t\t\t\t\t\t\t$DONE" || echo "\nFailed."
    899     return $res
     891                echo "Copying $r to ramdisk" >> $LOGFILE
     892        done
     893    fi
     894    fi
     895     cat $outfile.pre | tr ' ' '\n' | tr -s '/' '/' | fgrep -vx "" | sort -u | egrep -v "/libX11|/libXext|/libXi|/libgtk|/libgdk" > $outfile
     896    rm -f $tempfile $outfile.pre
     897    [ "$res" -eq "0" ] && echo -e "\r\t\t\t\t\t\t\t\t$DONE" || echo "\nFailed."
     898    return $res
    900899}
    901900
     
    905904
    906905GenerateListForFile() {
    907     local files_found loc fname incoming i res
    908     incoming="$1"
    909     files_found=""
    910     res=0
    911 
    912     for fname in $incoming ; do
    913         files_found="$files_found `LocateFile $fname`"
    914     done
    915 
    916     echo "$files_found" | tr ' ' '\n' | sort -u | tr '\n' ' '
     906    local files_found loc fname incoming i res
     907    incoming="$1"
     908    files_found=""
     909    res=0
     910
     911    for fname in $incoming ; do
     912        files_found="$files_found `LocateFile $fname`"
     913    done
     914
     915    echo "$files_found" | tr ' ' '\n' | sort -u | tr '\n' ' '
    917916}
    918917
     
    922921
    923922GetAllRaidMembers() {
    924     $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*device/ if(\$2) {print \$2}" < /etc/raidtab
     923    $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*device/ if(\$2) {print \$2}" < /etc/raidtab
    925924}
    926925
    927926
    928927GetFileSizeList() {
    929     local i
    930     for i in `find $1 -type d -o -print` ; do
    931         du -sk $i
    932     done
     928    local i
     929    for i in `find $1 -type d -o -print` ; do
     930        du -sk $i
     931    done
    933932}
    934933
     
    936935
    937936GetHomeDir() {
    938     local res loc
    939     loc=`which $1 2>/dev/null`
    940     res=`file $loc | $AWK '{print $NF;}'`
    941     dirname $res
     937    local res loc
     938    loc=`which $1 2>/dev/null`
     939    res=`file $loc | $AWK '{print $NF;}'`
     940    dirname $res
    942941}
    943942
     
    950949
    951950GetParentRaidDev() {
    952     $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {dev=\$2} /^[[:space:]]*device/ {if(\$2==\"$1\") {print dev; exit}}" < /etc/raidtab
     951    $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {dev=\$2} /^[[:space:]]*device/ {if(\$2==\"$1\") {print dev; exit}}" < /etc/raidtab
    953952}
    954953
     
    959958
    960959GetRaidDevMembers() {
    961     $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {if(dev) exit; if(\$2 == \"$1\") dev=\$2} /^[[:space:]]*device/ {if(dev) {print \$2}}" < /etc/raidtab
     960    $AWK "/^[[:space:]]*#/ {next} /^[[:space:]]*raiddev/ {if(dev) exit; if(\$2 == \"$1\") dev=\$2} /^[[:space:]]*device/ {if(dev) {print \$2}}" < /etc/raidtab
    962961}
    963962
    964963
    965964HackAwk() {
    966     local pathname filename dir old_pwd new_fname
    967     pathname=$1
    968     filename=$2
    969     dir=`echo "$pathname" | sed s/$filename//`
    970     old_pwd=`pwd`
    971     cd $dir
    972     [ -f "$filename" ] || Die "Can't find $filename at $dir"
    973     new_fname="an.icky.icky.spider.ewww"
    974     [ "$filename" = "gawk" ] && new_fname="awk"
    975     [ "$filename" = "awk" ] && new_fname="gawk"
    976     ln -s $filename $new_fname
    977     cd $old_pwd
     965    local pathname filename dir old_pwd new_fname
     966    pathname=$1
     967    filename=$2
     968    dir=`echo "$pathname" | sed s/$filename//`
     969    old_pwd=`pwd`
     970    cd $dir
     971    [ -f "$filename" ] || Die "Can't find $filename at $dir"
     972    new_fname="an.icky.icky.spider.ewww"
     973    [ "$filename" = "gawk" ] && new_fname="awk"
     974    [ "$filename" = "awk" ] && new_fname="gawk"
     975    ln -s $filename $new_fname
     976    cd $old_pwd
    978977}
    979978
     
    982981
    983982HackMountlist() {
    984     local scratchdir outfile partlist pst partstr \
     983    local scratchdir outfile partlist pst partstr \
    985984res partition swapsize
    986     scratchdir=$TMP_ROOT
    987     outfile=$1
    988 
    989     mkdir -p $outfile
    990     rm -Rf $outfile
    991     > $outfile
    992     partlist=$(mount | cut -d' ' -f1,3,5 \
     985    scratchdir=$TMP_ROOT
     986    outfile=$1
     987
     988    mkdir -p $outfile
     989    rm -Rf $outfile
     990    > $outfile
     991    partlist=$(mount | cut -d' ' -f1,3,5 \
    993992    | egrep -v "((none|/tmp|/ISOs|/proc|/dev/root) )|/mnt/" \
    994993    | tr ' ' '|')
    995994
    996     echo -n "Modifying mountlist..."
    997 
    998     if [ ! -f "/mountlist.hacked" ] ; then
    999         Die "Can't find modified mountlist.hacked!"
    1000     else
    1001         cp /mountlist.hacked "$outfile"
    1002         LogIt "Done. (Created by auto-archive, I assume?)\n"
    1003     fi
     995    echo -n "Modifying mountlist..."
     996
     997    if [ ! -f "/mountlist.hacked" ] ; then
     998        Die "Can't find modified mountlist.hacked!"
     999    else
     1000        cp /mountlist.hacked "$outfile"
     1001        LogIt "Done. (Created by auto-archive, I assume?)\n"
     1002    fi
    10041003}
    10051004
     
    10081007
    10091008HackPathsToFailsafe() {
    1010     local incoming newpath kver stub i pwd
    1011     kver=`uname -r`
    1012     incoming=`ReadLine`
    1013     pwd=`pwd`
    1014     cd $TMP_ROOT
    1015     while [ "$incoming" != "" ] ; do
     1009    local incoming newpath kver stub i pwd
     1010    kver=`uname -r`
     1011    incoming=`ReadLine`
     1012    pwd=`pwd`
     1013    cd $TMP_ROOT
     1014    while [ "$incoming" != "" ] ; do
    10161015    stub=`basename $incoming`
    10171016    newpath=`FindSpecificModuleInPath lib/modules/$FAILSAFE_KVER $stub`
    10181017    for i in $newpath ; do
    1019         echo "$i"
     1018        echo "$i"
    10201019    done
    10211020    read incoming
    1022     done
    1023     cd $pwd
     1021    done
     1022    cd $pwd
    10241023}
    10251024
     
    10271026
    10281027ListAllPartitions() {
    1029     local res currline partition all_partitions ap_orig remaining i j
    1030 
    1031     cat $MY_FSTAB | grep -vx " *#.*" | grep -vx " *none.*" | $AWK '/^\/dev\/[imhs]d||LABEL\=\// && !/fdd|cdr|zip|floppy/ {print $1}'
     1028    local res currline partition all_partitions ap_orig remaining i j
     1029
     1030    cat $MY_FSTAB | grep -vx " *#.*" | grep -vx " *none.*" | $AWK '/^\/dev\/[imhs]d||LABEL\=\// && !/fdd|cdr|zip|floppy/ {print $1}'
    10321031#    for partition in `$FDISK -l | tr -s ' ' '\n' | grep /dev` ; do
    10331032#        [ -e "$i" ] && all_partitions=echo "$i"
    10341033#    done
    1035     [ -e "/etc/raidtab" ] && $AWK '/^ *device/ {print $2}' /etc/raidtab
    1036     return
     1034    [ -e "/etc/raidtab" ] && $AWK '/^ *device/ {print $2}' /etc/raidtab
     1035    return
    10371036}
    10381037
     
    10421041
    10431042ListImagesForUser() {
    1044     local path fname
    1045     path=$1
    1046     echo -en "In the directory '$path' you will find the images:-\n"
    1047     for fname in `ls $path | fgrep mindi-` ; do
    1048         printf "%19s " $fname
    1049     done
    1050     echo " "
     1043    local path fname
     1044    path=$1
     1045    echo -en "In the directory '$path' you will find the images:-\n"
     1046    for fname in `ls $path | fgrep mindi-` ; do
     1047        printf "%19s " $fname
     1048    done
     1049    echo " "
    10511050}
    10521051
     
    10541053
    10551054ListKernelModulePaths() {
    1056     local module_list module fname oss r kern
    1057     oss="/root/oss/modules"
    1058     module_list=`ListKernelModules`
     1055    local module_list module fname oss r kern
     1056    oss="/root/oss/modules"
     1057    module_list=`ListKernelModules`
    10591058###
    10601059### Sq-Modification ... Use kernelname for module search path if specified
    10611060###
    1062     # kern="`uname -r`"
    1063     if [ "${kernelname}" != "" -a "${kernelname}" != "FAILSAFE" ]
    1064     then
    1065       kern=${kernelname}
    1066     else
    1067       kern="`uname -r`"
    1068     fi
     1061    # kern="`uname -r`"
     1062    if [ "${kernelname}" != "" -a "${kernelname}" != "FAILSAFE" ]
     1063    then
     1064      kern=${kernelname}
     1065    else
     1066      kern="`uname -r`"
     1067    fi
    10691068###
    10701069### Sq-Mod End
    10711070###
    1072     for module in $module_list $EXTRA_MODS ; do
    1073         r=`find /lib/modules/$kern -type f | grep "/${module}\..*o" | tail -n1`
     1071    for module in $module_list $EXTRA_MODS ; do
     1072        r=`find /lib/modules/$kern -type f | grep "/${module}\..*o" | tail -n1`
    10741073    echo "module $module --> $r" >> $LOGFILE
    10751074    [ "$r" ] && echo "$r"
    10761075    [ -f "$oss" ] && find $oss | fgrep $module
    1077     done
    1078     find /lib/modules/$kern/modules.* -type f 2> /dev/null
    1079     [ -f "$oss" ] && find $oss.* 2> /dev/null
     1076    done
     1077    find /lib/modules/$kern/modules.* -type f 2> /dev/null
     1078    [ -f "$oss" ] && find $oss.* 2> /dev/null
    10801079}
    10811080
     
    10831082
    10841083ListKernelModules() {
    1085     local output q
    1086     output=""
    1087     for q in `lsmod | sed -n '2,$s/ .*//p'` ; do
     1084    local output q
     1085    output=""
     1086    for q in `lsmod | sed -n '2,$s/ .*//p'` ; do
    10881087    output="$q $output"
    1089     done
    1090     echo "$output"
     1088    done
     1089    echo "$output"
    10911090}
    10921091
     
    10941093
    10951094LocateDeps() {
    1096     local incoming fname deps
    1097     incoming="$1"
    1098     for fname in $incoming ; do
    1099         if [ ! -e "$fname" ] ; then
    1100             echo "Warning - $fname does not exist; cannot be LDD'd." >> $LOGFILE
    1101         if echo $fname | grep lvm &> /dev/null ; then
     1095    local incoming fname deps
     1096    incoming="$1"
     1097    for fname in $incoming ; do
     1098        if [ ! -e "$fname" ] ; then
     1099            echo "Warning - $fname does not exist; cannot be LDD'd." >> $LOGFILE
     1100        if echo $fname | grep lvm &> /dev/null ; then
    11021101        echo "This warning only affects you if you are using LVM." >> $LOGFILE
    11031102        if lsmod | grep lvm &> /dev/null ; then
     
    11071106            echo "I don't think you are, so don't worry about it." >> $LOGFILE
    11081107        fi
    1109         fi
    1110         elif [ -h "$fname" ] && [ -x "$fname" ] ; then
    1111         echo "$fname is softlink" >> $LOGFILE
     1108        fi
     1109        elif [ -h "$fname" ] && [ -x "$fname" ] ; then
     1110        echo "$fname is softlink" >> $LOGFILE
    11121111#            echo "$fname will not be LDD'd. It is a softlink to `WhatSoftlinkPointsTo $fname`, which should already be in queue to be analyzed." >> $LOGFILE
    11131112#            echo "$fname"
    1114         else
    1115             ldd $fname 2> /dev/null | ProcessLDD $fname
    1116         fi
    1117     done
     1113        else
     1114            ldd $fname 2> /dev/null | ProcessLDD $fname
     1115        fi
     1116    done
    11181117}
    11191118
     
    11211120
    11221121LocateFile() {
    1123     local i path fname_to_find location output resolved tmp stub cache_id loclist
    1124     fname_to_find="$1"
    1125     if [ "$FILE_CACHE" ] ; then
    1126         touch $FILE_CACHE
    1127         output=""; cache_id=`echo $fname_to_find | md5sum`
    1128         output=`sed -n -e "s/^$cache_id //p" $FILE_CACHE`
    1129         if [ ! "$output" = "" ] ; then
    1130             echo "$output"
    1131             return 0
    1132         fi
    1133     fi
    1134     if echo "$fname_to_find" | grep -x "/.*" ; then
     1122    local i path fname_to_find location output resolved tmp stub cache_id loclist
     1123    fname_to_find="$1"
     1124    if [ "$FILE_CACHE" ] ; then
     1125        touch $FILE_CACHE
     1126        output=""; cache_id=`echo $fname_to_find | md5sum`
     1127        output=`sed -n -e "s/^$cache_id //p" $FILE_CACHE`
     1128        if [ ! "$output" = "" ] ; then
     1129            echo "$output"
     1130            return 0
     1131        fi
     1132    fi
     1133    if echo "$fname_to_find" | grep -x "/.*" ; then
    11351134    output="$fname_to_find"
    11361135    location="$fname_to_find"
    11371136    while [ -h "$location" ] ; do
    1138         resolved=`WhatSoftlinkPointsTo $location`
    1139         location=$resolved
    1140         output="$location $output"
     1137        resolved=`WhatSoftlinkPointsTo $location`
     1138        location=$resolved
     1139        output="$location $output"
    11411140    done
    11421141    echo "$output"
    11431142    return 0
    1144     fi
    1145     output=""
    1146     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
     1143    fi
     1144    output=""
     1145    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
    11471146    [ ! -d "$path" ] && continue
    11481147    location=`echo "$path/$fname_to_find" | tr -s '/' '/'`
    11491148    if echo "$location" | grep "lib/lib" 2> /dev/null ; then
    1150         loclist=`find $path -maxdepth 1 | fgrep "$fname_to_find"`
    1151     else
    1152         loclist=$location
     1149        loclist=`find $path -maxdepth 1 | fgrep "$fname_to_find"`
     1150    else
     1151        loclist=$location
    11531152    fi
    11541153    for location in $loclist ; do
    1155         [ ! -e "$location" ] && continue
    1156         output="$location $output"
    1157         copies_found=$(($copies_found+1))
    1158         while [ -h "$location" ] ; do
    1159                 resolved=`WhatSoftlinkPointsTo $location`
    1160                 location=$resolved
    1161                 output="$location $output"
    1162             done
     1154        [ ! -e "$location" ] && continue
     1155        output="$location $output"
     1156        copies_found=$(($copies_found+1))
     1157        while [ -h "$location" ] ; do
     1158                resolved=`WhatSoftlinkPointsTo $location`
     1159                location=$resolved
     1160                output="$location $output"
     1161            done
    11631162#       resolved=`file $location | $AWK '{print $NF;}'`
    11641163#       if [ "`echo "$resolved" | fgrep "/"`" = "" ] ; then
     
    11681167#       fi
    11691168    done
    1170     done
    1171     if [ "$output" = "" ] ; then
     1169    done
     1170    if [ "$output" = "" ] ; then
    11721171#   echo "$fname_to_find not found" >> /dev/stderr
    11731172    return 1
    1174     fi
    1175     echo "$output"
    1176     [ "$FILE_CACHE" ] && echo -ne "$cache_id $output\n" >> $FILE_CACHE
    1177     return 0
     1173    fi
     1174    echo "$output"
     1175    [ "$FILE_CACHE" ] && echo -ne "$cache_id $output\n" >> $FILE_CACHE
     1176    return 0
    11781177}
    11791178
     
    11811180
    11821181LogIt() {
    1183     if [ -e /dev/stderr ] ; then
     1182    if [ -e /dev/stderr ] ; then
    11841183    echo -e "$1" >> /dev/stderr
    1185     elif [ -e /usr/bin/logger ] ; then
     1184    elif [ -e /usr/bin/logger ] ; then
    11861185    /usr/bin/logger -s $1
    1187     fi
    1188     echo -en "$1" >> $LOGFILE
     1186    fi
     1187    echo -en "$1" >> $LOGFILE
    11891188}
    11901189
     
    11981197
    11991198MakeMondoConfigFile() {
    1200     local outfile use_lzo use_comp use_star
    1201     outfile=$1
    1202     > $outfile
    1203     [ "$TAPESIZE" ]     && echo "media-size $TAPESIZE" >> $outfile
    1204     [ "$TAPEDEV" ]          && echo "media-dev $TAPEDEV" >> $outfile
    1205     [ "$FILES_IN_FILELIST" ]    && echo "files-in-filelist $FILES_IN_FILELIST" >> $outfile
    1206     [ "$LAST_FILELIST_NUMBER" ] && echo "last-filelist-number $LAST_FILELIST_NUMBER" >> $outfile
    1207     [ "$INTERNAL_TAPE_BLOCK_SIZE" ] && echo "internal-tape-block-size $INTERNAL_TAPE_BLOCK_SIZE" >> $outfile
    1208     use_lzo=$USE_LZO; [ "$use_lzo" = "" ] && use_lzo="no"
    1209     use_comp=$USE_COMP; [ "$use_comp" = "" ] && use_comp="yes"
    1210     use_star=$USE_STAR; [ "$use_star" = "" ] && use_star="no"
    1211     echo "use-lzo $use_lzo" >> $outfile
    1212     echo "use-star $use_star" >> $outfile
    1213     echo "use-comp $use_comp" >> $outfile
    1214     echo "datestamp `date`" >> $outfile
    1215     [ "$ESTIMATED_TOTAL_NOOF_SLICES" ] && echo "total-slices $ESTIMATED_TOTAL_NOOF_SLICES" >> $outfile
     1199    local outfile use_lzo use_comp use_star
     1200    outfile=$1
     1201    > $outfile
     1202    [ "$TAPESIZE" ]     && echo "media-size $TAPESIZE" >> $outfile
     1203    [ "$TAPEDEV" ]          && echo "media-dev $TAPEDEV" >> $outfile
     1204    [ "$FILES_IN_FILELIST" ]    && echo "files-in-filelist $FILES_IN_FILELIST" >> $outfile
     1205    [ "$LAST_FILELIST_NUMBER" ] && echo "last-filelist-number $LAST_FILELIST_NUMBER" >> $outfile
     1206    [ "$INTERNAL_TAPE_BLOCK_SIZE" ] && echo "internal-tape-block-size $INTERNAL_TAPE_BLOCK_SIZE" >> $outfile
     1207    use_lzo=$USE_LZO; [ "$use_lzo" = "" ] && use_lzo="no"
     1208    use_comp=$USE_COMP; [ "$use_comp" = "" ] && use_comp="yes"
     1209    use_star=$USE_STAR; [ "$use_star" = "" ] && use_star="no"
     1210    echo "use-lzo $use_lzo" >> $outfile
     1211    echo "use-star $use_star" >> $outfile
     1212    echo "use-comp $use_comp" >> $outfile
     1213    echo "datestamp `date`" >> $outfile
     1214    [ "$ESTIMATED_TOTAL_NOOF_SLICES" ] && echo "total-slices $ESTIMATED_TOTAL_NOOF_SLICES" >> $outfile
    12161215   AddFileToCfgIfExists $MONDO_TMP/NFS-CLIENT-IPADDR nfs-client-ipaddr $outfile
    12171216   AddFileToCfgIfExists $MONDO_TMP/NFS-SERVER-MOUNT  nfs-server-mount  $outfile
     
    12341233
    12351234MakeModuleLoadingScript() {
    1236     local module fname params modpath kver outerloop i modpaths kver searchpath list_to_echo j
    1237     tmpmodprobe_flag=$1
    1238     outfile=$2
    1239     > $outfile || Die "Cannot create empty $outfile"
    1240     echo -en "#\041/bin/sh\n\n" >> $outfile
    1241     echo "echo -en \"Loading your modules...\"" >> $outfile
    1242     if [ "$YOUR_KERNEL_SUCKS" ] ; then
     1235    local module fname params modpath kver outerloop i modpaths kver searchpath list_to_echo j
     1236    tmpmodprobe_flag=$1
     1237    outfile=$2
     1238    > $outfile || Die "Cannot create empty $outfile"
     1239    echo -en "#\041/bin/sh\n\n" >> $outfile
     1240    echo "echo -en \"Loading your modules...\"" >> $outfile
     1241    if [ "$YOUR_KERNEL_SUCKS" ] ; then
    12431242    kver=$FAILSAFE_KVER
    12441243    cd $TMP_ROOT
    12451244    searchpath=lib/modules/$kver
    1246     else
     1245    else
    12471246###
    12481247### Sq-Modification ... Use kernelname for module search path if specified
    12491248###
    1250         #kver=`uname -r`
    1251         if [ "${kernelname}" != "" ]
    1252         then
    1253           kver=${kernelname}
    1254         else
    1255           kver=`uname -r`
    1256         fi
     1249        #kver=`uname -r`
     1250        if [ "${kernelname}" != "" ]
     1251        then
     1252          kver=${kernelname}
     1253        else
     1254          kver=`uname -r`
     1255        fi
    12571256###
    12581257### Sq-Modification end
    12591258###
    12601259    searchpath=/lib/modules/$kver
    1261     fi
    1262    
    1263     echo -en "for outerloop in 1 2 3 4 5 ; do\necho -en \".\"\n" >> $outfile
    1264     list_to_echo="`ListKernelModules`"
     1260    fi
     1261   
     1262    echo -en "for outerloop in 1 2 3 4 5 ; do\necho -en \".\"\n" >> $outfile
     1263    list_to_echo="`ListKernelModules`"
    12651264#    LTE=`echo "$list_to_echo" | tr ' ' '\n' | grep -n "" | cut -d':' -f2,3,4 | tr '\n' ' '`
    12661265#    lte_old="$LTE"
     
    12701269#    done
    12711270#echo "LTE = '$LTE'" >> $LOGFILE
    1272     # Make temporary modprobe.conf file if we are told so
    1273     if [ $tmpmodprobe_flag == "Y" ] ; then
     1271    # Make temporary modprobe.conf file if we are told so
     1272    if [ $tmpmodprobe_flag == "Y" ] ; then
    12741273    infile="/tmp/modprobe.conf.mindi.$$"
    1275     cat `find /etc/modprobe.d -name "*" -xtype f -maxdepth 1` > $infile
    1276     else
     1274    cat `find /etc/modprobe.d -maxdepth 1 -name "*" -xtype f` > $infile
     1275    else
    12771276    infile="/etc/modules.conf"
    1278     fi
    1279     for module in $list_to_echo $EXTRA_MODS ; do
     1277    fi
     1278    for module in $list_to_echo $EXTRA_MODS ; do
    12801279    params=`sed -n "s/^options \\+$module \\+//p" $infile`
    12811280    modpaths=`FindSpecificModuleInPath $searchpath $module`
    12821281    for i in $modpaths ; do
    1283         echo "MyInsmod $i $params > /dev/null 2> /dev/null" \
     1282        echo "MyInsmod $i $params > /dev/null 2> /dev/null" \
    12841283            | tr '.' '#' \
    12851284            | sed s/#o#gz/#o/ \
     
    12871286            | sed s/#ko#gz/#ko/ \
    12881287            | sed s/#ko#gz/#ko/ \
    1289                 | tr '#' '.' >> $outfile
    1290 
    1291         echo -en "$i added to module list.\n" >> $LOGFILE
    1292     done
    1293     done
    1294     echo -en "done\n" >> $outfile
    1295     echo "echo \"Done.\"" >> $outfile
    1296     chmod +x $outfile
     1288                | tr '#' '.' >> $outfile
     1289
     1290        echo -en "$i added to module list.\n" >> $LOGFILE
     1291    done
     1292    done
     1293    echo -en "done\n" >> $outfile
     1294    echo "echo \"Done.\"" >> $outfile
     1295    chmod +x $outfile
    12971296#    cp $outfile /tmp/out.txt
    1298     cd /
    1299     # Remove temporary modprobe.conf file if we have created one
    1300     if [ $tmpmodprobe_flag == "Y" ] ; then
     1297    cd /
     1298    # Remove temporary modprobe.conf file if we have created one
     1299    if [ $tmpmodprobe_flag == "Y" ] ; then
    13011300    rm -f $infile
    1302     fi
     1301    fi
    13031302}
    13041303
     
    13081307
    13091308MakeMountlist() {
    1310     local scratchdir mountlist all_partitions current_partition \
     1309    local scratchdir mountlist all_partitions current_partition \
    13111310partition_size partition_format outstring partition_number \
    13121311partition_mountpt c_p lwm_info psz lvm_dev unofficial_outstring \
    13131312absolute_partition old_partition_fmt
    13141313
    1315     echo "Your raw fstab file looks like this:-" >> $LOGFILE
    1316     cat $MY_FSTAB >> $LOGFILE
    1317     echo "Your mountlist will look like this:-"
     1314    echo "Your raw fstab file looks like this:-" >> $LOGFILE
     1315    cat $MY_FSTAB >> $LOGFILE
     1316    echo "Your mountlist will look like this:-"
    13181317
    13191318# scratchdir, mountlist(OUT)
    1320     scratchdir=$TMP_ROOT
    1321     mountlist=$1
     1319    scratchdir=$TMP_ROOT
     1320    mountlist=$1
    13221321
    13231322# NB: partition = device
    13241323# NB: mountpt = where the device is mounted
    13251324
    1326     [ -e "$MY_FSTAB" ] || Die "Cannot find your fstab file ($MY_FSTAB)"
    1327 
    1328     rm -f $mountlist
    1329     mkdir -p $mountlist
    1330     rm -Rf $mountlist
    1331     > $mountlist
    1332     echo -en "\rHang on...\r"
    1333     all_partitions=""
    1334    
     1325    [ -e "$MY_FSTAB" ] || Die "Cannot find your fstab file ($MY_FSTAB)"
     1326
     1327    rm -f $mountlist
     1328    mkdir -p $mountlist
     1329    rm -Rf $mountlist
     1330    > $mountlist
     1331    echo -en "\rHang on...\r"
     1332    all_partitions=""
     1333   
    13351334# Workaround until fdisk2parted.pl is fixed
    1336     [ "$ARCH" != "ia64" ] && FDISK=`which fdisk`
     1335    [ "$ARCH" != "ia64" ] && FDISK=`which fdisk`
    13371336# End workaround - Hugo, 06/20/2004
    13381337
    1339     if [ -d "/proc/lvm" ] || [ -d "/dev/mapper" ]; then
     1338    if [ -d "/proc/lvm" ] || [ -d "/dev/mapper" ]; then
    13401339    echo -en "\rAnalyzing LVM...\r"
    13411340    all_partitions=`$MINDI_HOME/analyze-my-lvm | fgrep ">>>" | cut -d' ' -f2-32`
    1342     fi
    1343     all_partitions="$all_partitions `ListAllPartitions 2> /dev/null`"
     1341    fi
     1342    all_partitions="$all_partitions `ListAllPartitions 2> /dev/null`"
    13441343#    echo "all partitions = $all_partitions" > /dev/stderr
    1345     for i in $IMAGE_DEVS ; do
    1346         mount | fgrep "$i " > /dev/null 2> /dev/null && Die "Sorry, $i is already mounted! CANNOT DO IMAGEDEV on it if it's mounted."
    1347     done
    1348     [ "$IMAGE_DEVS" != "" ] && all_partitions="`echo "$all_partitions $IMAGE_DEVS" | tr ' ' '\n' | sort | uniq | tr '\n ' ' '`"
    1349     printf "        %-15s %-15s %-15s %-15s\n" DEVICE MOUNTPOINT FORMAT "SIZE (MB)"
    1350     for c_p in $all_partitions ; do
     1344    for i in $IMAGE_DEVS ; do
     1345        mount | fgrep "$i " > /dev/null 2> /dev/null && Die "Sorry, $i is already mounted! CANNOT DO IMAGEDEV on it if it's mounted."
     1346    done
     1347    [ "$IMAGE_DEVS" != "" ] && all_partitions="`echo "$all_partitions $IMAGE_DEVS" | tr ' ' '\n' | sort | uniq | tr '\n ' ' '`"
     1348    printf "        %-15s %-15s %-15s %-15s\n" DEVICE MOUNTPOINT FORMAT "SIZE (MB)"
     1349    for c_p in $all_partitions ; do
    13511350#        echo "c_p = $c_p" > /dev/stderr
    13521351    [ "`echo "/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" | fgrep "$c_p"`" != "" ] || [ "`echo "$c_p" | fgrep "/dev/scd"`" != "" ] || [ "`echo "$c_p" | fgrep "/dev/ram"`" != "" ] || [ "`echo "$c_p" | grep ":"`" != "" ] || [ "`echo "$c_p" | fgrep ":/"`" != "" ] && continue
    1353         [ "`echo "/dev/scd0 /dev/scd1 /dev/sr0 /dev/sr1 /dev/cdrom /dev/cdrom1" | fgrep "$c_p"`" ] && continue
     1352        [ "`echo "/dev/scd0 /dev/scd1 /dev/sr0 /dev/sr1 /dev/cdrom /dev/cdrom1" | fgrep "$c_p"`" ] && continue
    13541353    [ "`echo "$c_p" | grep -x "/dev/cdroms.*"`" ] && continue
    13551354    if [ -h "$c_p" ] && [ "`echo "$c_p" | fgrep "/dev/hd"`" = "" ] && [ "`echo "$c_p" | fgrep "/dev/sd"`" = "" ] && [ "`echo "$c_p" | fgrep "/dev/md"`" = "" ] ; then
    1356             current_partition=`ResolveSoftlink $c_p`
    1357         [ "`echo "$current_partition" | fgrep "/dev/mapper"`" != "" ] && current_partition="$c_p"
    1358             [ "`echo "/dev/scd0 /dev/scd1 /dev/sr0 /dev/sr1 /dev/cdrom /dev/cdrom1" | fgrep "$current_partition"`" ] && continue
    1359     else
    1360         current_partition="$c_p"
     1355            current_partition=`ResolveSoftlink $c_p`
     1356        [ "`echo "$current_partition" | fgrep "/dev/mapper"`" != "" ] && current_partition="$c_p"
     1357            [ "`echo "/dev/scd0 /dev/scd1 /dev/sr0 /dev/sr1 /dev/cdrom /dev/cdrom1" | fgrep "$current_partition"`" ] && continue
     1358    else
     1359        current_partition="$c_p"
    13611360    fi
    13621361    [ "$c_p" = "none" ] && continue
    1363         absolute_partition=`ResolveSoftlink $c_p`
     1362        absolute_partition=`ResolveSoftlink $c_p`
    13641363    partition_mountpt=`cat $MY_FSTAB | tr -s '\t' ' ' | grep -w "$current_partition" | grep -vx " *#.*" | $AWK '{print $2}' | head -n1`
    13651364    redhat_label=""
    13661365    if [ "`echo "$current_partition" | fgrep -i "LABEL="`" != "" ] ; then
    1367         str_to_find_fmt_with=$current_partition
    1368         redhat_label=`echo "$current_partition" | cut -d'=' -f2`
    1369         actual_dev=`mount -l | fgrep " [$redhat_label]" | cut -d' ' -f1`
     1366        str_to_find_fmt_with=$current_partition
     1367        redhat_label=`echo "$current_partition" | cut -d'=' -f2`
     1368        actual_dev=`mount -l | fgrep " [$redhat_label]" | cut -d' ' -f1`
    13701369#       partition_mountpt=$redhat_label
    1371         current_partition=$actual_dev
    1372     else
    1373         str_to_find_fmt_with=$current_partition
     1370        current_partition=$actual_dev
     1371    else
     1372        str_to_find_fmt_with=$current_partition
    13741373    fi
    13751374    partition_format=`$AWK '$1 == "'"$str_to_find_fmt_with"'" {print $3}' $MY_FSTAB`
    13761375    if [ -d "/proc/lvm" ] && [ "`lvdisplay $current_partition 2> /dev/null`" ] ; then
    1377         partition_size="lvm"
     1376        partition_size="lvm"
    13781377    elif [ -d "/dev/mapper" ] && [ "`lvm lvdisplay $current_partition 2> /dev/null`" ] ; then
    1379         partition_size="lvm"
    1380     else
    1381         partition_size=`SizeOfPartition $current_partition`
    1382         [ "`echo "$current_partition" | grep "[0-9]"`" = "" ] && continue
    1383         [ "`echo "$current_partition" | grep -c "^/"`" -ne "1" ] && continue
    1384         if [ "$partition_format" = "swap" ] || [ "$partition_mountpt" = "swap" ] ; then
     1378        partition_size="lvm"
     1379    else
     1380        partition_size=`SizeOfPartition $current_partition`
     1381        [ "`echo "$current_partition" | grep "[0-9]"`" = "" ] && continue
     1382        [ "`echo "$current_partition" | grep -c "^/"`" -ne "1" ] && continue
     1383        if [ "$partition_format" = "swap" ] || [ "$partition_mountpt" = "swap" ] ; then
    13851384        partition_size=`fgrep -v "Priority" /proc/swaps | tr -s '\t' ' ' | fgrep "$current_partition" | $AWK '{print $3}'`
    13861385        [ "$partition_mountpt" != "swap" ] && partition_mountpt="swap"
    1387                 [ "$partition_format" != "swap" ] && partition_format="swap"
     1386                [ "$partition_format" != "swap" ] && partition_format="swap"
    13881387        if [ "$partition_size" = "" ] ; then
    13891388            totalsize=0
     
    13931392            items=$(($items+1))
    13941393            done
    1395                     [ "$items" -gt "0" ] && partition_size=$(($totalsize/$items)) || partition_size=0
     1394                    [ "$items" -gt "0" ] && partition_size=$(($totalsize/$items)) || partition_size=0
    13961395            [ "$partition_size" -lt "125000" ] && partition_size=125000
    13971396            echo "I'm guessing $c_p is $(($partition_size/1024))MB" >> $LOGFILE
    13981397        fi
    1399         fi
     1398        fi
    14001399    fi
    14011400    [ "$partition_mountpt" = "swap" ] && partition_format="swap"
    14021401    [ "$partition_format" = "swap" ] && partition_mountpt="swap"
    14031402    if [ "$partition_mountpt" = "" ] ; then
    1404         if [ "`pvdisplay $current_partition 2> /dev/null`" != "" ] || [ "`lvm pvdisplay $current_partition 2> /dev/null`" != "" ] ; then
     1403        if [ "`pvdisplay $current_partition 2> /dev/null`" != "" ] || [ "`lvm pvdisplay $current_partition 2> /dev/null`" != "" ] ; then
    14051404        if  [ "`fgrep device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
    14061405            partition_mountpt="raid"
     
    14111410            partition_format="lvm"
    14121411        fi
    1413         fi
     1412        fi
    14141413    fi
    14151414    psz=$partition_size
     
    14171416    [ "$psz" != "lvm" ] && psz=$(($psz/1024))
    14181417    if [ "`echo " $IMAGE_DEVS " | fgrep " $current_partition "`" != "" ] ; then
    1419         partition_mountpt="image"
    1420             old_partition_fmt=$partition_format
     1418        partition_mountpt="image"
     1419            old_partition_fmt=$partition_format
    14211420#       partition_format="`$FDISK -l 2>> $LOGFILE | tr -s '\t' ' ' | grep -w "$absolute_partition" | $AWK 'x=$(NF-1}'`"
    1422         partition_format="`$FDISK -l 2>> $LOGFILE | tr '*' ' ' | tr '+' ' ' | tr -s ' ' '\t' | grep -w "$absolute_partition" | cut -f5`"
    1423             echo "------- $FDISK -l log ------------" >> $LOGFILE
    1424             cat $FDISKLOG >> $LOGFILE
    1425             echo "------- $FDISK log end ------------" >> $LOGFILE
    1426         partition_size=$(($partition_size+1)); # just in case
    1427             if [ "$partition_format" = "Linux" ] ; then
    1428                 echo "Are you imaging a mounted swap partition? Silly..." >> $LOGFILE
    1429                 echo "Reverting format from $old_partition_fmt to $partition_format" >> $LOGFILE
    1430                 partition_format=$old_partition_fmt
    1431             fi
    1432     fi
    1433         if [ "$EXCLUDE_DEVS" ] && [ "`echo " $EXCLUDE_DEVS " | fgrep " $current_partition "`" ] || [ "`echo " $EXCLUDE_DEVS " | grep " $current_partition "`" ] ; then
    1434             echo "Excluding $current_partition from mountlist" >> $LOGFILE
    1435             continue
    1436         fi
    1437         if [ ! "$partition_mountpt" ] ; then
    1438         for qq in "" `find /dev/ida/c*d* ! -name '*p*'` ; do
     1421        partition_format="`$FDISK -l 2>> $LOGFILE | tr '*' ' ' | tr '+' ' ' | tr -s ' ' '\t' | grep -w "$absolute_partition" | cut -f5`"
     1422            echo "------- $FDISK -l log ------------" >> $LOGFILE
     1423            cat $FDISKLOG >> $LOGFILE
     1424            echo "------- $FDISK log end ------------" >> $LOGFILE
     1425        partition_size=$(($partition_size+1)); # just in case
     1426            if [ "$partition_format" = "Linux" ] ; then
     1427                echo "Are you imaging a mounted swap partition? Silly..." >> $LOGFILE
     1428                echo "Reverting format from $old_partition_fmt to $partition_format" >> $LOGFILE
     1429                partition_format=$old_partition_fmt
     1430            fi
     1431    fi
     1432        if [ "$EXCLUDE_DEVS" ] && [ "`echo " $EXCLUDE_DEVS " | fgrep " $current_partition "`" ] || [ "`echo " $EXCLUDE_DEVS " | grep " $current_partition "`" ] ; then
     1433            echo "Excluding $current_partition from mountlist" >> $LOGFILE
     1434            continue
     1435        fi
     1436        if [ ! "$partition_mountpt" ] ; then
     1437        for qq in "" `find /dev/ida/c*d* ! -name '*p*'` ; do
    14391438        partition_format=`$FDISK -l $qq 2>> $LOGFILE | grep -w "$c_p" | sed 's/12/|/' | tr -s '\t' ' ' | cut -d'|' -f2 | cut -d' ' -f2-9`
    1440                 echo "------- $FDISK -l log ------------" >> $LOGFILE
    1441                 cat $FDISKLOG >> $LOGFILE
    1442                 echo "------- $FDISK log end ------------" >> $LOGFILE
     1439                echo "------- $FDISK -l log ------------" >> $LOGFILE
     1440                cat $FDISKLOG >> $LOGFILE
     1441                echo "------- $FDISK log end ------------" >> $LOGFILE
    14431442        [ "$partition_format" ] && break
    1444         done
    1445         if [ "$partition_format" = "Compaq diagnostics" ] ; then
     1443        done
     1444        if [ "$partition_format" = "Compaq diagnostics" ] ; then
    14461445        partition_format="compaq"
    1447         elif [ ! "`fgrep device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
     1446        elif [ ! "`fgrep device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
    14481447        LogIt "Unable to find mountpoint of $current_partition - ignoring"
    14491448        continue
    1450         fi
     1449        fi
    14511450    fi
    14521451    partition_format="`echo "$partition_format" | cut -d',' -f1`"; # in case user has ext3,ext2 or something dumb like that
     
    14541453    unofficial_outstring=`printf "\t%-15s %-15s %-15s %7s\n" $current_partition $partition_mountpt $partition_format $psz`
    14551454    if [ "$current_partition" = "" ] ; then
    1456         echo "Unknown partition (outstring = $unofficial_outstring)" >> $LOGFILE
     1455        echo "Unknown partition (outstring = $unofficial_outstring)" >> $LOGFILE
    14571456    elif [ "$partition_mountpt" = "" ] && [ -f "/etc/raidtab" ] ; then
    1458         if [ "`cat /etc/raidtab 2> /dev/null | fgrep device | fgrep $current_partition`" ] ; then
     1457        if [ "`cat /etc/raidtab 2> /dev/null | fgrep device | fgrep $current_partition`" ] ; then
    14591458        partition_mountpt=raid
    14601459        partition_format=raid
    1461             printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
    1462                 printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
    1463         else
     1460            printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
     1461                printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
     1462        else
    14641463        echo "Unknown mountpoint (outstring = $unofficial_outstring)" >> $LOGFILE
    1465         fi
    1466         elif [ "$partition_format" = "" ] ; then
    1467         echo "Unknown format (outstring = $unofficial_outstring)" >> $LOGFILE
     1464        fi
     1465        elif [ "$partition_format" = "" ] ; then
     1466        echo "Unknown format (outstring = $unofficial_outstring)" >> $LOGFILE
    14681467    elif [ "$partition_size" = "" ] ; then
    1469         echo "Unknown partition size (outstring = $unofficial_outstring)" >> $LOGFILE
     1468        echo "Unknown partition size (outstring = $unofficial_outstring)" >> $LOGFILE
    14701469    elif [ "$partition_mountpt" = "/proc" ] || [ "$partition_mountpt" = "/dev/pts" ] ; then
    1471         continue
    1472     else
    1473             if [ "$partition_format" = "dos" ] || [ "$partition_format" = "msdos" ] ; then
    1474                 echo "Stupid bastard..." >> $LOGFILE
    1475                 partition_format="vfat"
    1476             fi
    1477         printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
    1478         printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
    1479     fi
    1480     done
     1470        continue
     1471    else
     1472            if [ "$partition_format" = "dos" ] || [ "$partition_format" = "msdos" ] ; then
     1473                echo "Stupid bastard..." >> $LOGFILE
     1474                partition_format="vfat"
     1475            fi
     1476        printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
     1477        printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
     1478    fi
     1479    done
    14811480}
    14821481
     
    14871486
    14881487MakeSureNumberIsInteger() {
    1489     res=`echo "$1" | tr -s '\-[0-9]' ' '`
    1490     if [ "$res" != " " ] && [ "$res" != "" ] ; then
     1488    res=`echo "$1" | tr -s '\-[0-9]' ' '`
     1489    if [ "$res" != " " ] && [ "$res" != "" ] ; then
    14911490    echo "result = '$res'"
    1492         Die "$1 should be an integer"
    1493     fi
     1491        Die "$1 should be an integer"
     1492    fi
    14941493}
    14951494
     
    14991498
    15001499MakeSyslinuxMessageFile() {
    1501     mkdir -p $1
    1502     rmdir $1
    1503     echo -en "  " > $1
    1504     if [ "`cat /etc/issue.net 2> /dev/null | fgrep -i "debian"`" ] ; then
    1505         cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cat /etc/issue.net | cut -d ' ' -f 3` `hostname`"% | sed s/KKKKK/"Kernel `uname  -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ >> $1.tmp
    1506     else
    1507         cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`cat /etc/issue.net | grep -i "linux" | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`cat /etc/issue.net | grep -i "kernel" | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' '\\r' 'on' 'an' '\/' '`uname -r`' 'on' 'an' '`uname -m`/ >> $1.tmp
    1508     fi
    1509     cat $1.tmp | sed s/%r/"`uname -r`"/ | sed s/%t/"`hostname`"/ > $1
    1510     rm -f $1.tmp
    1511     if [ "$CDRECOVERY" != "yes" ] ; then
    1512         if [ -e "$MONDO_TMP/start-nfs" ] ; then
    1513             echo -en "Press <enter> to continue.\n" >> $1
    1514         elif [ ! "$MONDO_TMP" ] ; then
    1515             echo -en "FYI, this is _not_ a Mondo Rescue CD.\n" >> $1
    1516             if [ -e "$MINDI_HOME/memtest.img" ] ; then
    1517                 echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n" >> $1
    1518             fi
    1519         else
    1520             echo -en "$BOOT_MEDIA_MESSAGE" >> $1
    1521         fi
    1522     else
    1523         echo -en " \
     1500    mkdir -p $1
     1501    rmdir $1
     1502    echo -en "  " > $1
     1503    if [ "`cat /etc/issue.net 2> /dev/null | fgrep -i "debian"`" ] ; then
     1504        cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cat /etc/issue.net | cut -d ' ' -f 3` `hostname`"% | sed s/KKKKK/"Kernel `uname  -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ >> $1.tmp
     1505    else
     1506        cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`cat /etc/issue.net | grep -i "linux" | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`cat /etc/issue.net | grep -i "kernel" | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' '\\r' 'on' 'an' '\/' '`uname -r`' 'on' 'an' '`uname -m`/ >> $1.tmp
     1507    fi
     1508    cat $1.tmp | sed s/%r/"`uname -r`"/ | sed s/%t/"`hostname`"/ > $1
     1509    rm -f $1.tmp
     1510    if [ "$CDRECOVERY" != "yes" ] ; then
     1511        if [ -e "$MONDO_TMP/start-nfs" ] ; then
     1512            echo -en "Press <enter> to continue.\n" >> $1
     1513        elif [ ! "$MONDO_TMP" ] ; then
     1514            echo -en "FYI, this is _not_ a Mondo Rescue CD.\n" >> $1
     1515            if [ -e "$MINDI_HOME/memtest.img" ] ; then
     1516                echo -en "Type 'memtest' <Enter> to test your PC's memory intensively.\nJust press <Enter> to go to the main test menu.\n" >> $1
     1517            fi
     1518        else
     1519            echo -en "$BOOT_MEDIA_MESSAGE" >> $1
     1520        fi
     1521    else
     1522        echo -en " \
    15241523To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
    15251524CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n" >> $1
    1526     fi
     1525    fi
    15271526}
    15281527
     
    15311530
    15321531MoveHyperlinkSensibly() {
    1533     local filename minidir_root resides_on_diskno noof_disks old_diskno d old_pwd
    1534     filename=$1
    1535     minidir_root=$2
    1536     resides_on_diskno=$3
    1537     noof_disks=$4
    1538 
    1539     [ -h "$minidir_root/$resides_on_diskno/$filename" ] || Die "$filename isn't a softlink (or doesn't exist): how can I move it sensibly?"
    1540 
    1541     old_diskno=$resides_on_diskno
    1542     d=1
    1543     while [ "$d" -le "$noof_disks" ] ; do
    1544         if [ "$d" -ne "$old_diskno" ] ; then
    1545             old_pwd=`pwd`
    1546             cd $minidir_root/$old_diskno
    1547             cp --parents -Rdf $filename $minidir_root/$d/ || Die "Can't move $filename (sensibly) from $old_diskno to $d"
    1548             rm -f $filename
    1549             cd $old_pwd
    1550         fi
     1532    local filename minidir_root resides_on_diskno noof_disks old_diskno d old_pwd
     1533    filename=$1
     1534    minidir_root=$2
     1535    resides_on_diskno=$3
     1536    noof_disks=$4
     1537
     1538    [ -h "$minidir_root/$resides_on_diskno/$filename" ] || Die "$filename isn't a softlink (or doesn't exist): how can I move it sensibly?"
     1539
     1540    old_diskno=$resides_on_diskno
     1541    d=1
     1542    while [ "$d" -le "$noof_disks" ] ; do
     1543        if [ "$d" -ne "$old_diskno" ] ; then
     1544            old_pwd=`pwd`
     1545            cd $minidir_root/$old_diskno
     1546            cp --parents -Rdf $filename $minidir_root/$d/ || Die "Can't move $filename (sensibly) from $old_diskno to $d"
     1547            rm -f $filename
     1548            cd $old_pwd
     1549        fi
    15511550# when the softlink is resolvable, our work here is done
    1552         [ -e "$minidir_root/$d/$filename" ] && return 0
    1553         old_diskno=$d
    1554         d=$(($d+1))
    1555     done
    1556     return 1
     1551        [ -e "$minidir_root/$d/$filename" ] && return 0
     1552        old_diskno=$d
     1553        d=$(($d+1))
     1554    done
     1555    return 1
    15571556}
    15581557
     
    15601559
    15611560OfferToCopyImagesToDisks() {
    1562     local imagesdir i imagename dev count boot_dev data_dev
    1563     imagesdir=$1
    1564     boot_dev=$2
    1565     data_dev=$3
    1566     echo -en "Would you like to create boot+data floppy disks now (y/n) ?"
    1567     read i
    1568     [ "$i" != "y" ] && [ "$i" != "Y" ] && return
    1569     mount | fgrep /dev/fd > /dev/null && Die "Please unmount your floppies first."
    1570     echo "WARNING! THIS WILL ERASE YOUR FLOPPY DISKS."
    1571     [ ! -e "$boot_dev" ] && Die "Cannot find $boot_dev - is your Linux distro broken?"
    1572     [ ! -e "$data_dev" ] && Die "Cannot find $data_dev - is your Linux distro broken?"
    1573     i=`find $imagesdir -type f | fgrep "/mindi-root.1" 2> /dev/null`
    1574     j=`find $imagesdir -type f | fgrep "/mindi-boot" | fgrep -v 2880`
     1561    local imagesdir i imagename dev count boot_dev data_dev
     1562    imagesdir=$1
     1563    boot_dev=$2
     1564    data_dev=$3
     1565    echo -en "Would you like to create boot+data floppy disks now (y/n) ?"
     1566    read i
     1567    [ "$i" != "y" ] && [ "$i" != "Y" ] && return
     1568    mount | fgrep /dev/fd > /dev/null && Die "Please unmount your floppies first."
     1569    echo "WARNING! THIS WILL ERASE YOUR FLOPPY DISKS."
     1570    [ ! -e "$boot_dev" ] && Die "Cannot find $boot_dev - is your Linux distro broken?"
     1571    [ ! -e "$data_dev" ] && Die "Cannot find $data_dev - is your Linux distro broken?"
     1572    i=`find $imagesdir -type f | fgrep "/mindi-root.1" 2> /dev/null`
     1573    j=`find $imagesdir -type f | fgrep "/mindi-boot" | fgrep -v 2880`
    15751574#    echo "i=$i"
    15761575#    echo "j=$j"
    1577     if [ "$i" ] ; then
    1578         CopyImageToDisk $j $data_dev "boot disk"
    1579         CopyImageToDisk $i $data_dev "root disk"
    1580     else
    1581         CopyImageToDisk $j $boot_dev "boot/root disk"
    1582     fi
    1583     count=1
    1584     for i in `find $imagesdir | fgrep mindi-data` ; do
    1585         CopyImageToDisk $i $data_dev "data disk #$count"
    1586         count=$(($count+1))
    1587     done
     1576    if [ "$i" ] ; then
     1577        CopyImageToDisk $j $data_dev "boot disk"
     1578        CopyImageToDisk $i $data_dev "root disk"
     1579    else
     1580        CopyImageToDisk $j $boot_dev "boot/root disk"
     1581    fi
     1582    count=1
     1583    for i in `find $imagesdir | fgrep mindi-data` ; do
     1584        CopyImageToDisk $i $data_dev "data disk #$count"
     1585        count=$(($count+1))
     1586    done
    15881587}
    15891588
     
    15911590
    15921591OfferToMakeBootableISO() {
    1593     local i old_pwd
    1594     if [ "$PROMPT_MAKE_CD_IMAGE" = "yes" ] && [ ! "`DidMondoCallMe`" ] ; then
    1595         echo -en "Shall I make a bootable CD image? (y/n) "
    1596         read i
    1597         [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
    1598     fi
    1599     if [ ! "$MONDO_TMP" ] ; then
    1600         LogIt "NB: Mindi's bootable CD always uses isolinux."
    1601         LogIt "For a bootable CD w/LILO, please use Mondo."
    1602     fi
    1603     rm -Rf $TMP_ROOT/iso
    1604     mkdir -p $TMP_ROOT/iso/{images,archives,isolinux}
    1605     cp -f $1/*.img $1/*.gz $TMP_ROOT/iso/images || LogIt "[line 857] cannot copy $i to $TMP_ROOT/iso/images\n"
    1606     old_pwd=`pwd`
    1607     cd $TMP_ROOT/iso
    1608     mkdir -p $MONDO_ROOT/iso/isolinux
    1609     echo "mindi_home = $MINDI_HOME" >> $LOGFILE
    1610     cp $MINDI_HOME/mem{test,disk}* $MONDO_ROOT 2>> $LOGFILE
    1611     for i in memdisk memtest.bin memtest.img ; do
     1592    local i old_pwd
     1593    if [ "$PROMPT_MAKE_CD_IMAGE" = "yes" ] && [ ! "`DidMondoCallMe`" ] ; then
     1594        echo -en "Shall I make a bootable CD image? (y/n) "
     1595        read i
     1596        [ "$i" != "y" ] && [ "$i" != "Y" ] && return 0
     1597    fi
     1598    if [ ! "$MONDO_TMP" ] ; then
     1599        LogIt "NB: Mindi's bootable CD always uses isolinux."
     1600        LogIt "For a bootable CD w/LILO, please use Mondo."
     1601    fi
     1602    rm -Rf $TMP_ROOT/iso
     1603    mkdir -p $TMP_ROOT/iso/{images,archives,isolinux}
     1604    cp -f $1/*.img $1/*.gz $TMP_ROOT/iso/images || LogIt "OfferToMakeBootableISO: Cannot copy $i to $TMP_ROOT/iso/images\n"
     1605    old_pwd=`pwd`
     1606    cd $TMP_ROOT/iso
     1607    mkdir -p $MONDO_ROOT/iso/isolinux
     1608    echo "mindi_home = $MINDI_HOME" >> $LOGFILE
     1609    cp $MINDI_HOME/mem{test,disk}* $MONDO_ROOT 2>> $LOGFILE
     1610    for i in memdisk memtest.bin memtest.img ; do
    16121611    j=$MINDI_HOME/$i
    16131612    k=$TMP_ROOT/iso/isolinux
    16141613    if [ -e "$j" ] ; then
    1615         LogIt "Copying $j to $k"
    1616         cp -f $j $k || Die "Failed to copy $j to $k"
    1617         cp -f $j $TMP_ROOT || Die "Failed to copy $j to $k"
    1618     fi
    1619     done
    1620     MakeSyslinuxMessageFile $TMP_ROOT/iso/isolinux/message.txt
    1621     cp $kernelpath $TMP_ROOT/iso/isolinux/vmlinuz || Die "Cannot copy vmlinuz ($kernelpath) to mondo root ($MONDO_ROOT/isolinux/vmlinuz). Did you run out of disk space?"
    1622     cp $TMP_ROOT/mindi.rdz $TMP_ROOT/iso/isolinux/initrd.img
    1623     cp $TMP_ROOT/mindi.rdz $imagesdir/initrd.img
    1624     [ -e "$iso_cfg_file" ] || Die "FIXME - unable to find $iso_cfg_file - this should never occur"
    1625     cd $TMP_ROOT/iso/isolinux
    1626     cat $iso_cfg_file | HackSyslinuxFile $ramdisk_size $TMP_ROOT/iso > isolinux.cfg || Die "Cannot copy isolinux.cfg from mindi_home to tmp_root - did you run out of disk space?"
    1627     if [ -e "$MONDO_TMP/start-nfs" ] ; then
     1614        LogIt "Copying $j to $k"
     1615        cp -f $j $k || Die "Failed to copy $j to $k"
     1616        cp -f $j $TMP_ROOT || Die "Failed to copy $j to $k"
     1617    fi
     1618    done
     1619    MakeSyslinuxMessageFile $TMP_ROOT/iso/isolinux/message.txt
     1620    cp $kernelpath $TMP_ROOT/iso/isolinux/vmlinuz || Die "Cannot copy vmlinuz ($kernelpath) to mondo root ($MONDO_ROOT/isolinux/vmlinuz). Did you run out of disk space?"
     1621    cp $TMP_ROOT/mindi.rdz $TMP_ROOT/iso/isolinux/initrd.img
     1622    cp $TMP_ROOT/mindi.rdz $imagesdir/initrd.img
     1623    [ -e "$iso_cfg_file" ] || Die "FIXME - unable to find $iso_cfg_file - this should never occur"
     1624    cd $TMP_ROOT/iso/isolinux
     1625    cat $iso_cfg_file | HackSyslinuxFile $ramdisk_size $TMP_ROOT/iso > isolinux.cfg || Die "Cannot copy isolinux.cfg from mindi_home to tmp_root - did you run out of disk space?"
     1626    if [ -e "$MONDO_TMP/start-nfs" ] ; then
    16281627    mv isolinux.cfg isolinux.cfg.old
    16291628    cat isolinux.cfg.old | sed s/interactive/iso/ > isolinux.cfg
    1630     fi
    1631     if [ "$ARCH" != "ia64" ] ; then
    1632         cp $ISOLINUX isolinux.bin || Die "Cannot copy isolinux.bin from /usr/lib to tmp_root - did you run out of disk space?"
     1629    fi
     1630    if [ "$ARCH" != "ia64" ] ; then
     1631        cp $ISOLINUX isolinux.bin || Die "Cannot copy isolinux.bin ($ISOLINUX) to tmp_root - did you run out of disk space?"
    16331632    cp $ISOLINUX ../
    1634     fi
    1635     cd $TMP_ROOT/iso
    1636     if [ "$ARCH" != "ia64" ] ; then
    1637         cp -f $TMP_ROOT/iso/isolinux/{isolinux.cfg,initrd.img,vmlinuz,isolinux.bin,message.txt} $MONDO_ROOT || Die "Cannot copy core files to ramdisk for boot disk. Did you run out of disk space?"
    1638     fi
    1639     [ "$MONDO_HOME" ] && cp -f $MONDO_HOME/autorun .   
    1640     if [ -d "/home/MondoCD" ] ; then
     1633    fi
     1634    cd $TMP_ROOT/iso
     1635    if [ "$ARCH" != "ia64" ] ; then
     1636        cp -f $TMP_ROOT/iso/isolinux/{isolinux.cfg,initrd.img,vmlinuz,isolinux.bin,message.txt} $MONDO_ROOT || Die "Cannot copy core files to ramdisk for boot disk. Did you run out of disk space?"
     1637    fi
     1638    [ "$MONDO_HOME" ] && cp -f $MONDO_HOME/autorun .   
     1639    if [ -d "/home/MondoCD" ] ; then
    16411640    cp -pRdu /home/MondoCD/* .
    1642     fi
    1643     if [ "$ARCH" != "ia64" ] ; then
    1644         mkisofs -U -J -r -o $imagesdir/mindi.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table . > /dev/null 2> /tmp/$$.mk
    1645     else
    1646         mkisofs -J -r -o $imagesdir/mindi.iso -b images/mindi-bootroot.$IA64_BOOT_SIZE.img -c isolinux/boot.cat -no-emul-boot . > /dev/null 2> /tmp/$$.mk
    1647     fi
    1648     if [ "$?" -ne "0" ] ; then
     1641    fi
     1642    if [ "$ARCH" != "ia64" ] ; then
     1643        mkisofs -U -J -r -o $imagesdir/mindi.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table . > /dev/null 2> /tmp/$$.mk
     1644    else
     1645        mkisofs -J -r -o $imagesdir/mindi.iso -b images/mindi-bootroot.$IA64_BOOT_SIZE.img -c isolinux/boot.cat -no-emul-boot . > /dev/null 2> /tmp/$$.mk
     1646    fi
     1647    if [ "$?" -ne "0" ] ; then
    16491648    echo "----------- mkisofs's errors --------------" >> $LOGFILE
    16501649    cat /tmp/$$.mk >> $LOGFILE
     
    16521651    cat /tmp/$$.mk
    16531652    LogIt "Failed to create ISO image.\n"
    1654     else
     1653    else
    16551654    echo "Created bootable ISO image at $imagesdir/mindi.iso" >> $LOGFILE
    1656     fi
    1657     rm -f /tmp/$$.mk
    1658     cd $old_pwd
     1655    fi
     1656    rm -f /tmp/$$.mk
     1657    cd $old_pwd
    16591658}
    16601659
     
    16621661
    16631662PluralOrNot() {
    1664     [ "$1" -gt "1" ] && echo -en "s"
     1663    [ "$1" -gt "1" ] && echo -en "s"
    16651664}
    16661665
     
    16691668
    16701669MakeMessageFile() {
    1671     local disksize
    1672     disksize=$1
    1673     if [ "`cat /etc/issue.net 2> /dev/null | fgrep -i "debian"`" ] ; then
    1674         cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cat /etc/issue.net | cut -d ' ' -f 3` `hostname`"% | sed s/KKKKK/"Kernel `uname  -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/
    1675     else
    1676         cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`cat /etc/issue.net | grep -i "linux" | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`cat /etc/issue.net | grep -i "kernel" | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' 'r' 'on' 'an' 'm/' '`uname -r`' 'on' 'an' '`uname -m`/
    1677     fi
    1678     if [ "$disksize" -gt "2880" ] ; then
     1670    local disksize
     1671    disksize=$1
     1672    if [ "`cat /etc/issue.net 2> /dev/null | fgrep -i "debian"`" ] ; then
     1673        cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s%DDDDD%"Debian GNU\/`uname -s` `cat /etc/issue.net | cut -d ' ' -f 3` `hostname`"% | sed s/KKKKK/"Kernel `uname  -r` on a `uname -m`"/ | sed s/TTTTT/"`LC_TIME=C date`"/
     1674    else
     1675        cat $MINDI_HOME/msg-txt | sed s/ZZZZZ/$MINDI_VERSION/ | sed s/YYYYY/"Mondo Rescue"/ | sed s/XXXXX/"a cousin of"/ | sed s/DDDDD/"`cat /etc/issue.net | grep -i "linux" | head -n1 | tr -s ' ' ' '`"/ | sed s/KKKKK/"`cat /etc/issue.net | grep -i "kernel" | head -n1 | tr -s ' ' ' '`"/ | sed s/TTTTT/"`LC_TIME=C date`"/ | sed s/' 'r' 'on' 'an' 'm/' '`uname -r`' 'on' 'an' '`uname -m`/
     1676    fi
     1677    if [ "$disksize" -gt "2880" ] ; then
    16791678    if [ "`DidMondoCallMe`" ] ; then
    1680         if [ "$CDRECOVERY" != "yes" ] ; then
    1681                 if [ -e "$MONDO_TMP/start-nfs" ] ; then
    1682                     echo -en "Press <enter> to continue.\n"
     1679        if [ "$CDRECOVERY" != "yes" ] ; then
     1680                if [ -e "$MONDO_TMP/start-nfs" ] ; then
     1681                    echo -en "Press <enter> to continue.\n"
    16831682        elif [ ! "$MONDO_TMP" ] ; then
    16841683            echo -en "FYI, this is _not_ a Mondo Rescue CD.\n"
    1685                 else
    1686                     echo -en "$BOOT_MEDIA_MESSAGE"
    1687                 fi
    1688         fi
    1689     fi
    1690     fi
    1691     if [ "$CDRECOVERY" = "yes" ] ; then
    1692         echo -en "\
     1684                else
     1685                    echo -en "$BOOT_MEDIA_MESSAGE"
     1686                fi
     1687        fi
     1688    fi
     1689    fi
     1690    if [ "$CDRECOVERY" = "yes" ] ; then
     1691        echo -en "\
    16931692To restore your disk to factory defaults, type 'RESTORE' <enter>.\n\
    16941693CAUTION: THIS WILL ERASE YOUR WHOLE DISK !!!\n"
    1695     fi
    1696     echo -en "\n\n\n"
     1694    fi
     1695    echo -en "\n\n\n"
    16971696}
    16981697
     
    17011700
    17021701write_full_floppy_of_kernel() {
    1703     local mtpt image old_pwd res disksize
    1704 
    1705     res=0
    1706     old_pwd=`pwd`
    1707     KERN_DISK_MADE=1
    1708     disksize=$3
    1709     image=/tmp/$RANDOM.$RANDOM.img
    1710     mtpt=/tmp/$RANDOM.$RANDOM.mtpt
    1711     dd if=/dev/zero of=$image bs=1k count=$disksize
    1712     mke2fs -N 26 -F $image > /dev/null
    1713     mkdir -p $mtpt
    1714     mount -o loop $image $mtpt
    1715     cd $mtpt
    1716     mkdir -p {dev,tmp,boot}
    1717     cp -f $1 vmlinuz
    1718     if [ "$?" -ne "0" ] ; then
    1719     LogIt "Failed to copy $1 to ramdisk"
    1720     return 1
    1721     fi
    1722 
    1723     rdev vmlinuz 2,0
    1724     rdev -R vmlinuz 0
    1725     rdev -r vmlinuz 49152
    1726 
    1727     tar -zxf $MINDI_HOME/dev.tgz || LogIt "Cannot untar dev.tgz\n"
    1728     losetup /dev/loop0 > /dev/null 2> /dev/null
    1729     [ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/l\oop0 by typing 'losetup /dev/loop0 -d'.\nReboot if necessary.\n"
    1730     CopyBootBFile $mtpt/boot.b
     1702    local mtpt image old_pwd res disksize
     1703
     1704    res=0
     1705    old_pwd=`pwd`
     1706    KERN_DISK_MADE=1
     1707    disksize=$3
     1708    rand1=$RANDOM
     1709    rand2=$RANDOM
     1710    image=/tmp/$rand1.$rand2.img
     1711    mtpt=/tmp/$rand1.$rand2.mtpt
     1712    dd if=/dev/zero of=$image bs=1k count=$disksize
     1713    mke2fs -N 26 -F $image > /dev/null
     1714    mkdir -p $mtpt
     1715    mount -o loop $image $mtpt
     1716    cd $mtpt
     1717    mkdir -p {dev,tmp,boot}
     1718    cp -f $1 vmlinuz
     1719    if [ "$?" -ne "0" ] ; then
     1720        LogIt "Failed to copy $1 to ramdisk"
     1721        cd $old_pwd
     1722        umount $mtpt
     1723        rmdir $mtpt
     1724        rm $image
     1725        return 1
     1726    fi
     1727
     1728    rdev vmlinuz 2,0
     1729    rdev -R vmlinuz 0
     1730    rdev -r vmlinuz 49152
     1731
     1732    tar -zxf $MINDI_HOME/dev.tgz || LogIt "Cannot untar dev.tgz\n"
     1733    losetup /dev/loop0 > /dev/null 2> /dev/null
     1734    [ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing 'losetup /dev/loop0 -d'.\nReboot if necessary.\n"
     1735    CopyBootBFile $mtpt/boot.b
    17311736
    17321737#    echo "root=/dev/loop0" > bdlilo.conf
    1733     MakeLiloConfFile $disksize >> bdlilo.conf
     1738    MakeLiloConfFile $disksize >> bdlilo.conf
    17341739
    17351740#    cat bdlilo.conf > /tmp/bdlilo.conf
     
    17371742#    cat /home/mondostuff/bdlc > bdlilo.conf
    17381743
    1739     chmod 644 bdlilo.conf
    1740     MakeMessageFile $disksize > message
    1741     lilo -v -C bdlilo.conf -r $mtpt
    1742     res=$?
     1744    chmod 644 bdlilo.conf
     1745    MakeMessageFile $disksize > message
     1746    lilo -v -C bdlilo.conf -r $mtpt
     1747    res=$?
    17431748
    17441749#echo "lilo -v -C bdlilo.conf -r $mtpt"
    17451750#echo -en "Press enter"; read line
    17461751
    1747     cd $old_pwd
    1748     umount $mtpt
    1749     mv -f $image $2
    1750     rmdir $mtpt
    1751 
    1752     return $res
     1752    cd $old_pwd
     1753    umount $mtpt
     1754    mv -f $image $2
     1755    rmdir $mtpt
     1756
     1757    return $res
    17531758
    17541759# --- the kernel-only method NO LONGER WORKS. Not since Apr 2002.
     
    17761781
    17771782MakeLiloConfFile() {
    1778     local disksize options i ooo
    1779     disksize=$1
    1780     options=""
    1781         if [ "$ARCH" != "ia64" ] ; then
    1782         echo -en "boot=/dev/loop0\ndisk=/dev/loop0\n"
    1783         fi
    1784         if [ "$disksize" -eq "2880" ] ; then
    1785         echo -en "bios=0x00\nsectors=36\nheads=2\ncylinders=80\n"
    1786         elif [ "$disksize" -eq "1722" ] ; then
    1787         echo -en "bios=0x00\nsectors=21\nheads=2\ncylinders=82\n"
    1788         elif [ "$disksize" -gt "2880" ] ; then
    1789             /bin/true
    1790         else
    1791         echo -en "bios=0x00\nsectors=18\nheads=2\ncylinders=80\n"
    1792         fi
    1793         if [ "$ARCH" != "ia64" ] ; then
    1794             echo -en "install=/boot.b\nmap=/boot.map\n"
    1795         fi
    1796     if [ "$CDRECOVERY" = "yes" ] ; then
    1797         echo -en "default=RESTORE\n"
    1798     elif [ "$disksize" -gt "2880" ] && [ "`DidMondoCallMe`" ] ; then
     1783    local disksize options i ooo
     1784    disksize=$1
     1785    options=""
     1786        if [ "$ARCH" != "ia64" ] ; then
     1787        echo -en "boot=/dev/loop0\ndisk=/dev/loop0\n"
     1788        fi
     1789        if [ "$disksize" -eq "2880" ] ; then
     1790        echo -en "bios=0x00\nsectors=36\nheads=2\ncylinders=80\n"
     1791        elif [ "$disksize" -eq "1722" ] ; then
     1792        echo -en "bios=0x00\nsectors=21\nheads=2\ncylinders=82\n"
     1793        elif [ "$disksize" -gt "2880" ] ; then
     1794            /bin/true
     1795        else
     1796        echo -en "bios=0x00\nsectors=18\nheads=2\ncylinders=80\n"
     1797        fi
     1798        if [ "$ARCH" != "ia64" ] ; then
     1799            echo -en "install=/boot.b\nmap=/boot.map\n"
     1800        fi
     1801    if [ "$CDRECOVERY" = "yes" ] ; then
     1802        echo -en "default=RESTORE\n"
     1803    elif [ "$disksize" -gt "2880" ] && [ "`DidMondoCallMe`" ] ; then
    17991804    if [ -e "$MONDO_TMP/start-nfs" ] ; then
    1800         echo -en "default=iso\n"
    1801     else
    1802         echo -en "default=interactive\n"
    1803     fi
    1804     else
     1805        echo -en "default=iso\n"
     1806    else
     1807        echo -en "default=interactive\n"
     1808    fi
     1809    else
    18051810    echo -en "default=expert\n"
    1806     fi
    1807         echo -en "prompt\n"
    1808     if [ "$ARCH" != "ia64" ] ; then
    1809         echo -en "vga=normal\nbackup=/dev/null\nmessage=/message\n"
    1810     fi
    1811     if [ "$CDRECOVERY" != "yes" ] ; then
     1811    fi
     1812        echo -en "prompt\n"
     1813    if [ "$ARCH" != "ia64" ] ; then
     1814        echo -en "vga=normal\nbackup=/dev/null\nmessage=/message\n"
     1815    fi
     1816    if [ "$CDRECOVERY" != "yes" ] ; then
    18121817    echo -en "timeout=300\n"
    1813     fi
    1814     echo -en "\n"
    1815     if [ "$CDRECOVERY" = "yes" ] ; then
     1818    fi
     1819    echo -en "\n"
     1820    if [ "$CDRECOVERY" = "yes" ] ; then
    18161821    options="RESTORE expert"
    1817     elif [ "$disksize" -gt "2880" ] ; then
    1818         if [ "`DidMondoCallMe`" ] ; then
    1819             if [ -e "$MONDO_TMP/start-nfs" ] ; then
    1820                 options="iso"
    1821             else
    1822                 options="interactive expert compare iso nuke isonuke"
     1822    elif [ "$disksize" -gt "2880" ] ; then
     1823        if [ "`DidMondoCallMe`" ] ; then
     1824            if [ -e "$MONDO_TMP/start-nfs" ] ; then
     1825                options="iso"
     1826            else
     1827                options="interactive expert compare iso nuke isonuke"
    18231828# hda hdb hdc hdd"
    1824             fi
    1825         else
    1826             options="expert"
    1827     fi
    1828     else
     1829            fi
     1830        else
     1831            options="expert"
     1832    fi
     1833    else
    18291834    options="expert"
    1830     fi
    1831     for i in $options ; do
     1835    fi
     1836    for i in $options ; do
    18321837    ooo=$i
    18331838    [ "$ooo" = "RESTORE" ] && ooo="nuke"
    1834         if [ "$ARCH" = "ia64" ] ; then
     1839        if [ "$ARCH" = "ia64" ] ; then
    18351840        rootpart="root=/dev/ram0\n\t"
    18361841    else
     
    18421847    outstr=$outstr"\"\n"
    18431848    if [ "$disksize" = "1440" ] ; then
    1844         echo -en "$outstr" | sed s/initrd=.*// | grep -v root=
    1845     else
    1846         echo -en "$outstr"
    1847     fi
    1848     done
     1849        echo -en "$outstr" | sed s/initrd=.*// | grep -v root=
     1850    else
     1851        echo -en "$outstr"
     1852    fi
     1853    done
    18491854}
    18501855
     
    18621867
    18631868PrepareBootDiskImage_LILO() {
    1864     local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf
    1865     imagesdir=$1
    1866     disksize=$2
    1867     kernelpath=$3
    1868     ramdisksize=$4
    1869 
    1870     retval=0
    1871     [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
    1872     echo -en "Making "$disksize"KB boot disk..."
    1873     TurnTgzIntoRdz $MINDI_HOME/rootfs $TMP_ROOT/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
    1874     if [ "$ARCH" != "ia64" ] ; then
    1875         [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "5760" ] && Die "PDBI - disksize is $disksize - bad size"
    1876     fi
    1877     echo -en "..."
    1878     imagefile=$imagesdir/mindi-bootroot.$disksize.img
    1879     mountpoint=$TMP_ROOT/mountpoint.$$
    1880     mkdir -p $mountpoint
    1881     dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
    1882     if [ "$ARCH" = "ia64" ] ; then
    1883         mkdosfs $imagefile > /tmp/mke2fs.$$ 2>> /tmp/mke2fs.$$
     1869    local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size liloconf
     1870    imagesdir=$1
     1871    disksize=$2
     1872    kernelpath=$3
     1873    ramdisksize=$4
     1874
     1875    retval=0
     1876    [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
     1877    echo -en "Making "$disksize"KB boot disk..."
     1878    TurnTgzIntoRdz $MINDI_HOME/rootfs $TMP_ROOT/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
     1879    if [ "$ARCH" != "ia64" ] ; then
     1880        [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "5760" ] && Die "PDBI - disksize is $disksize - bad size"
     1881    fi
     1882    echo -en "..."
     1883    imagefile=$imagesdir/mindi-bootroot.$disksize.img
     1884    mountpoint=$TMP_ROOT/mountpoint.$$
     1885    mkdir -p $mountpoint
     1886    dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
     1887    if [ "$ARCH" = "ia64" ] ; then
     1888        mkdosfs $imagefile > /tmp/mke2fs.$$ 2>> /tmp/mke2fs.$$
    18841889    t=vfat
    1885     else
    1886         mke2fs -N 26 -m 0 -F $imagefile > /tmp/mke2fs.$$ 2>> /tmp/mke2fs.$$
     1890    else
     1891        mke2fs -N 26 -m 0 -F $imagefile > /tmp/mke2fs.$$ 2>> /tmp/mke2fs.$$
    18871892    t=ext2
    1888     fi
    1889     [ "$?" -ne "0" ] && cat /tmp/mke2fs.$$
    1890     rm -f /tmp/mke2fs.$$
    1891     mount -t $t -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)\n\n"
     1893    fi
     1894    [ "$?" -ne "0" ] && cat /tmp/mke2fs.$$
     1895    rm -f /tmp/mke2fs.$$
     1896    mount -t $t -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)\n\n"
    18921897# copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
    1893     mkdir -p $mountpoint/etc
    1894     if [ "$ARCH" != "ia64" ] ; then
    1895         liloconf=$mountpoint/etc/lilo.conf
    1896     else
     1898    mkdir -p $mountpoint/etc
     1899    if [ "$ARCH" != "ia64" ] ; then
     1900        liloconf=$mountpoint/etc/lilo.conf
     1901    else
    18971902    liloconf=$mountpoint/elilo.conf
    1898     fi
    1899     old_pwd=`pwd`
    1900     cd $mountpoint
    1901     if [ "$ARCH" != "ia64" ] ; then
    1902         tar -zxf $MINDI_HOME/dev.tgz || LogIt "Cannot untar dev.tgz\n"
    1903     fi
    1904     cd $old_pwd
    1905     losetup /dev/loop0 > /dev/null 2> /dev/null
    1906     [ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing   'losetup /dev/loop0 -d'.\nReboot if necessary.\n"
    1907     CopyBootBFile $mountpoint/boot.b
    1908 
    1909     MakeLiloConfFile $disksize > $liloconf
    1910 
    1911     echo "Copying $TMP_ROOT/mindi.rdz to $mountpoint..." >> $LOGFILE
    1912     cp -f $TMP_ROOT/mindi.rdz $mountpoint 2>> $LOGFILE
    1913     if [ "$?" -ne "0" ] ; then
     1903    fi
     1904    old_pwd=`pwd`
     1905    cd $mountpoint
     1906    if [ "$ARCH" != "ia64" ] ; then
     1907        tar -zxf $MINDI_HOME/dev.tgz || LogIt "Cannot untar dev.tgz\n"
     1908    fi
     1909    cd $old_pwd
     1910    losetup /dev/loop0 > /dev/null 2> /dev/null
     1911    [ "$?" -eq "0" ] || losetup /dev/loop0 -d || Die "Please free up /dev/loop0 by typing   'losetup /dev/loop0 -d'.\nReboot if necessary.\n"
     1912    CopyBootBFile $mountpoint/boot.b
     1913
     1914    MakeLiloConfFile $disksize > $liloconf
     1915
     1916    echo "Copying $TMP_ROOT/mindi.rdz to $mountpoint..." >> $LOGFILE
     1917    cp -f $TMP_ROOT/mindi.rdz $mountpoint 2>> $LOGFILE
     1918    if [ "$?" -ne "0" ] ; then
    19141919    LogIt "Failed to copy $TMP_ROOT/mindi.rdz to $mountpoint\n"
    19151920    cat $TMP_ROOT/mtpt.$$ >> $LOGFILE
     
    19171922    rm -f $TMP_ROOT/mtpt.$$
    19181923    LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)"
    1919         retval=$(($retval+1))
    1920     fi
    1921     MakeMessageFile $disksize > $mountpoint/message
    1922 
    1923     mkdir -p $mountpoint/tmp
    1924     cp -f $TMP_ROOT/mondo-restore.cfg $mountpoint/tmp &> /dev/null
    1925     if [ -e "$MINDI_HOME/memtest.img" ] ; then
    1926         echo -en "image=/memtest.bin\nlabel=memtest\nn" >> $liloconf
    1927         echo -en "image=/memdisk\nlabel=memtest\nappend=\"initrd=memtest.img\"\n" >> $liloconf
     1924        retval=$(($retval+1))
     1925    fi
     1926    MakeMessageFile $disksize > $mountpoint/message
     1927
     1928    mkdir -p $mountpoint/tmp
     1929    cp -f $TMP_ROOT/mondo-restore.cfg $mountpoint/tmp &> /dev/null
     1930    if [ -e "$MINDI_HOME/memtest.img" ] ; then
     1931        echo -en "image=/memtest.bin\nlabel=memtest\nn" >> $liloconf
     1932        echo -en "image=/memdisk\nlabel=memtest\nappend=\"initrd=memtest.img\"\n" >> $liloconf
    19281933#        echo "Yep, this is a multi-function CD" > $mountpoint/MULTIFUNC
    1929     fi
    1930     if [ -d "/home/MondoCD" ] ; then
     1934    fi
     1935    if [ -d "/home/MondoCD" ] ; then
    19311936    cp -pRdu /home/MondoCD/* . || Die "Cannot do kung pow"
    1932     fi
     1937    fi
    19331938
    19341939# copy the kernel across
    1935     rm -Rf $mountpoint/lost+found
    1936     dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
    1937     free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
    1938     cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2> /dev/null
    1939     if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
     1940    rm -Rf $mountpoint/lost+found
     1941    dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
     1942    free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
     1943    cp -f $kernelpath $mountpoint/vmlinuz > /dev/null 2> /dev/null
     1944    if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
    19401945    echo "Files at mountpoint ($mountpoint) :-" >> $LOGFILE
    19411946    du -sk $mountpoint/* >> $LOGFILE
     
    19431948    echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n\
    19441949Sorry, your kernel is too big for a boot/root floppy.\nI'll try the new boot/root two-disk thingy.\n" >> $LOGFILE
    1945         rm -f $mountpoint/vmlinuz
     1950        rm -f $mountpoint/vmlinuz
    19461951    cd $old_pwd
    1947         umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    1948         rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
     1952        umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
     1953        rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
    19491954#   losetup /dev/loop0 -d
    19501955    res=0
    1951         write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
     1956        write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
    19521957    res=$(($res+$?))
    1953         cp -f $TMP_ROOT/mindi.rdz $imagesdir/mindi-root.1440.img
     1958        cp -f $TMP_ROOT/mindi.rdz $imagesdir/mindi-root.1440.img
    19541959    res=$(($res+$?))
    19551960    rm -f $imagefile
     
    19571962    rm -f $imagesdir/mindi-*.1440.img
    19581963    return $res
    1959     fi
    1960     free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
    1961     max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
    1962     echo "Free space left on floppy = $free_space KB" >> $LOGFILE
    1963     echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
     1964    fi
     1965    free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
     1966    max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
     1967    echo "Free space left on floppy = $free_space KB" >> $LOGFILE
     1968    echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
    19641969# make it bootable
    1965     rm -f $mountpoint/zero
    1966     [ -e "$MINDI_HOME/memdisk" ] && cp -f $MINDI_HOME/memdisk $mountpoint
    1967     if [ "$disksize" -gt "2880" ] && [ ! "$KERN_DISK_MADE" ] ; then
    1968         if [ "$ARCH" != "ia64" ] ; then
    1969         $LILO_EXE $LILO_OPTIONS -r $mountpoint >> $LOGFILE 2>> $LOGFILE
    1970         else
    1971             /bin/true
    1972         fi
    1973     elif [ ! "$KERN_DISK_MADE" ] ; then
     1970    rm -f $mountpoint/zero
     1971    [ -e "$MINDI_HOME/memdisk" ] && cp -f $MINDI_HOME/memdisk $mountpoint
     1972    if [ "$disksize" -gt "2880" ] && [ ! "$KERN_DISK_MADE" ] ; then
     1973        if [ "$ARCH" != "ia64" ] ; then
     1974        $LILO_EXE $LILO_OPTIONS -r $mountpoint >> $LOGFILE 2>> $LOGFILE
     1975        else
     1976            /bin/true
     1977        fi
     1978    elif [ ! "$KERN_DISK_MADE" ] ; then
    19741979# 12/28/2001 - if 1.72MB floppy then don't use LILO's optimizations at all
    19751980    $LILO_EXE -r $mountpoint >> $LOGFILE 2>> $LOGFILE
    1976     else
     1981    else
    19771982    echo "Not running LILO. It's not that kind of disk." >> $LOGFILE
    1978     fi
    1979     if [ $? -ne "0" ] ; then
     1983    fi
     1984    if [ $? -ne "0" ] ; then
    19801985    if [ "`cat $LOGFILE | fgrep "/tmp/dev.0"`" ] ; then
    1981         LogIt "The '/tmp/dev.0' error is NOT Mindi's fault. It is LILO's.\n"
    1982         LogIt "Please reboot your PC as a workaround.\n"
    1983         Die "LILO sneezed and Mindi caught a cold. Please read the README / FAQ.\n"
     1986        LogIt "The '/tmp/dev.0' error is NOT Mindi's fault. It is LILO's.\n"
     1987        LogIt "Please reboot your PC as a workaround.\n"
     1988        Die "LILO sneezed and Mindi caught a cold. Please read the README / FAQ.\n"
    19841989    fi
    19851990    echo "$LILO_EXE -r $mountpoint ...failed."
     
    19871992    LogIt "Cannot run lilo on $mountpoint\nPlease upgrade/downgrade your version of LILO. It has a bug.\n"
    19881993    retval=$(($retval+1))
    1989     fi
    1990     cp -f $liloconf /tmp/lilo.conf
    1991     if [ "$ARCH" = "ia64" ] ; then
    1992         cp `dirname $kernelpath`/*.efi $mountpoint
    1993     fi
    1994     umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    1995     echo -en "..."
    1996     rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
    1997     if [ "$retval" -eq "0" ] ; then
     1994    fi
     1995    cp -f $liloconf /tmp/lilo.conf
     1996    if [ "$ARCH" = "ia64" ] ; then
     1997        cp `dirname $kernelpath`/*.efi $mountpoint
     1998    fi
     1999    umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
     2000    echo -en "..."
     2001    rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
     2002    if [ "$retval" -eq "0" ] ; then
    19982003    echo -en "...$DONE\r"
    19992004    if [ "$KERN_DISK_MADE" ] && [ "$disksize" != "2880" ] ; then
    2000         LogIt "... 1440KB boot+root disks were created OK\r"
    2001     else
    2002         LogIt "... "$disksize"KB boot disk was created OK\r"
    2003     fi
    2004     else
     2005        LogIt "... 1440KB boot+root disks were created OK\r"
     2006    else
     2007        LogIt "... "$disksize"KB boot disk was created OK\r"
     2008    fi
     2009    else
    20052010    echo -en "...failed\r"
    20062011    LogIt $disksize"KB boot disk was NOT created\r"
    20072012    rm -f $imagefile
    2008     fi
    2009     [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero\n"
     2013    fi
     2014    [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero\n"
    20102015#0421#$imagesdir/mindi-boot.1440.img
    2011     return $retval
     2016    return $retval
    20122017}
    20132018
     
    20162021
    20172022PrepareBootDiskImage_SYSLINUX() {
    2018     local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage
    2019     imagesdir=$1
    2020     disksize=$2
    2021     kernelpath=$3
    2022     ramdisksize=$4
    2023     do_boot_root_thingy=""
    2024     local retval old_pwd
    2025     retval=0
    2026     [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
    2027     echo -en "Making "$disksize"KB boot disk..."
    2028     TurnTgzIntoRdz $MINDI_HOME/rootfs $TMP_ROOT/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
    2029     [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "5760" ] && Die "PDBI - disksize is $disksize - bad size"
    2030     echo -en "..."
    2031     imagefile=$imagesdir/mindi-bootroot.$disksize.img
    2032     mountpoint=$TMP_ROOT/mountpoint.$$
    2033     mkdir -p $mountpoint
     2023    local disksize imagesdir dev imagefile mountpoint fname i kernelpath ramdisksize cfg_file testpath options retval outstr old_pwd ooo max_kernel_size bootimage
     2024    imagesdir=$1
     2025    disksize=$2
     2026    kernelpath=$3
     2027    ramdisksize=$4
     2028    do_boot_root_thingy=""
     2029    local retval old_pwd
     2030    retval=0
     2031    [ ! -e "$kernelpath" ] && Die "PBDI - cannot find $kernelpath kernel"
     2032    echo -en "Making "$disksize"KB boot disk..."
     2033    TurnTgzIntoRdz $MINDI_HOME/rootfs $TMP_ROOT/mindi.rdz $ramdisksize $disksize `du -sk $kernelpath | cut -f1` || Die "Could not turn rootfs into mindi.rdz; are you SURE your kernel supports loopfs?"
     2034    [ "$disksize" != "1722" ] && [ "$disksize" != "2880" ] && [ "$disksize" != "5760" ] && Die "PDBI - disksize is $disksize - bad size"
     2035    echo -en "..."
     2036    imagefile=$imagesdir/mindi-bootroot.$disksize.img
     2037    mountpoint=$TMP_ROOT/mountpoint.$$
     2038    mkdir -p $mountpoint
    20342039# If I format a 1722KB data file & run syslinux on it, the resultant image
    20352040# won't boot. So, I have formatted a floppy, called syslinux on/to it, and
     
    20382043# image _is_ bootable. I don't know why syslinux and/or mkfs.vfat won't
    20392044# play nicely and I don't care. :) I have worked around the problem. -Hugo, 06/27/2002
    2040     if [ "$disksize" = "1722" ] ; then
    2041         gzip -dc $MINDI_HOME/sys-disk.raw.gz > $imagefile || Die "Cannot dd blank file"
    2042     else
    2043         dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
    2044         mkfs.vfat $imagefile
    2045         syslinux $imagefile
    2046     fi
    2047     mount -t vfat -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)\n\n"
     2045    if [ "$disksize" = "1722" ] ; then
     2046        gzip -dc $MINDI_HOME/sys-disk.raw.gz > $imagefile || Die "Cannot dd blank file"
     2047    else
     2048        dd if=/dev/zero of=$imagefile bs=1k count=$disksize &> /dev/null || Die "Cannot dd blank file"
     2049        mkfs.vfat $imagefile
     2050        syslinux $imagefile
     2051    fi
     2052    mount -t vfat -o loop $imagefile $mountpoint || LogIt "Cannot mount (PBDI)\n\n"
    20482053# copy Mindi's skeleton fs & lilo/syslinux/whatever stuff into it
    2049     old_pwd=`pwd`
    2050     MakeSyslinuxMessageFile $mountpoint/message.txt
    2051     cd $mountpoint
    2052     [ -e "$sys_cfg_file" ] || Die "Obi Wan, word up?"
     2054    old_pwd=`pwd`
     2055    MakeSyslinuxMessageFile $mountpoint/message.txt
     2056    cd $mountpoint
     2057    [ -e "$sys_cfg_file" ] || Die "Obi Wan, word up?"
    20532058#    tar -zxf $MINDI_HOME/dev.tgz || LogIt "Cannot untar dev.tgz\n" <--- present for LILO; is it nec. for SYSLINUX too?
    2054     cat $sys_cfg_file | HackSyslinuxFile $ramdisk_size $mountpoint > syslinux.cfg || Die "Cannot copy syslinux.cfg from mindi_home to tmp_root"
    2055     if [ -e "$MONDO_TMP/start-nfs" ] ; then
     2059    cat $sys_cfg_file | HackSyslinuxFile $ramdisk_size $mountpoint > syslinux.cfg || Die "Cannot copy syslinux.cfg from mindi_home to tmp_root"
     2060    if [ -e "$MONDO_TMP/start-nfs" ] ; then
    20562061    mv syslinux.cfg syslinux.cfg.orig
    20572062    cat syslinux.cfg.orig | sed s/interactive/iso/ > syslinux.cfg
    2058     fi
    2059     cd $old_pwd
    2060     echo "Copying $TMP_ROOT/mindi.rdz to $mountpoint/initrd.img..." >> $LOGFILE
    2061     cp -f $TMP_ROOT/mindi.rdz $mountpoint/initrd.img 2>> $LOGFILE
    2062     if [ "$?" -ne "0" ] ; then
     2063    fi
     2064    cd $old_pwd
     2065    echo "Copying $TMP_ROOT/mindi.rdz to $mountpoint/initrd.img..." >> $LOGFILE
     2066    cp -f $TMP_ROOT/mindi.rdz $mountpoint/initrd.img 2>> $LOGFILE
     2067    if [ "$?" -ne "0" ] ; then
    20632068    LogIt "Failed to copy $TMP_ROOT/mindi.rdz to $mountpoint\n"
    20642069    cat $TMP_ROOT/mtpt.$$ >> $LOGFILE
     
    20662071    rm -f $TMP_ROOT/mtpt.$$
    20672072    LogIt "Cannot incorporate mindi.rdz in bootdisk (kernel / modules too big?)"
    2068         retval=$(($retval+1))
    2069     fi
    2070 
    2071     mkdir -p $mountpoint/tmp
    2072     cp -f $TMP_ROOT/mondo-restore.cfg $mountpoint/tmp &> /dev/null
     2073        retval=$(($retval+1))
     2074    fi
     2075
     2076    mkdir -p $mountpoint/tmp
     2077    cp -f $TMP_ROOT/mondo-restore.cfg $mountpoint/tmp &> /dev/null
    20732078
    20742079# copy the kernel across
    2075     rm -Rf $mountpoint/lost+found
    2076     dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
    2077     free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
    2078     cp -f $kernelpath $mountpoint/vmlinuz &> /dev/null
    2079     if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
     2080    rm -Rf $mountpoint/lost+found
     2081    dd if=/dev/zero of=$mountpoint/zero bs=1k count=16 &> /dev/null
     2082    free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
     2083    cp -f $kernelpath $mountpoint/vmlinuz &> /dev/null
     2084    if [ "$?" -ne "0" ] || [ "$FORCE_DUAL_FLOPPIES" = "yes" ] ; then
    20802085    echo "Files at mountpoint ($mountpoint) :-" >> $LOGFILE
    20812086    du -sk $mountpoint/* >> $LOGFILE
     
    20832088    echo -en "Kernel size = `du -sk $kernelpath | cut -f1` K\nRamdisk free = $free_space K\n\
    20842089Sorry, your kernel is too big for a boot/root floppy.\nI'll try the new boot/root two-disk thingy.\n" >> $LOGFILE
    2085         rm -f $mountpoint/vmlinuz
     2090        rm -f $mountpoint/vmlinuz
    20862091    cd $old_pwd
    2087         umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    2088         rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
     2092        umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
     2093        rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
    20892094#   losetup /dev/loop0 -d
    20902095
    2091         res=0
    2092         write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
    2093         res=$(($res+$?))
    2094         cp -f $TMP_ROOT/mindi.rdz $imagesdir/mindi-root.1440.img
    2095         res=$(($res+$?))
    2096         rm -f $imagefile
    2097         [ "$res" -ne "0" ] && LogIt "Warning - failed to create 1.44MB boot/root floppies"
    2098         return $res
    2099     fi
    2100     free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
    2101     max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
    2102     echo "Free space left on floppy = $free_space KB" >> $LOGFILE
    2103     echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
     2096        res=0
     2097        write_full_floppy_of_kernel $kernelpath $imagesdir/mindi-boot.1440.img 1440
     2098        res=$(($res+$?))
     2099        cp -f $TMP_ROOT/mindi.rdz $imagesdir/mindi-root.1440.img
     2100        res=$(($res+$?))
     2101        rm -f $imagefile
     2102        [ "$res" -ne "0" ] && LogIt "Warning - failed to create 1.44MB boot/root floppies"
     2103        return $res
     2104    fi
     2105    free_space=`df -k $mountpoint | tail -n1 | tr -s ' ' '\t' | cut -f4`
     2106    max_kernel_size=$(($free_space+`du -sk $kernelpath | cut -f1`))
     2107    echo "Free space left on floppy = $free_space KB" >> $LOGFILE
     2108    echo "Max kernel size on $disksize KB floppy (est'd) = $max_kernel_size K" >> $LOGFILE
    21042109# make it bootable
    2105     rm -f $mountpoint/zero
    2106     mkdir -p $mountpoint/etc
    2107     [ -e "$MINDI_HOME/memdisk" ] && cp -f $MINDI_HOME/memdisk $mountpoint
    2108     umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
    2109     echo -en "..."
    2110     rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
    2111 
    2112     if [ "$retval" -eq "0" ] ; then
    2113         echo -en "...$DONE\r"
    2114         if [ "$KERN_DISK_MADE" ] ; then
    2115             rm -f $imagefile
    2116             LogIt "... 1440KB boot+root disks were created OK\r"
    2117         else
    2118             LogIt "... "$disksize"KB boot disk was created OK\r"
    2119         fi
    2120     else
     2110    rm -f $mountpoint/zero
     2111    mkdir -p $mountpoint/etc
     2112    [ -e "$MINDI_HOME/memdisk" ] && cp -f $MINDI_HOME/memdisk $mountpoint
     2113    umount $mountpoint || Die "Cannot unmount mountpoint ($mountpoint)"
     2114    echo -en "..."
     2115    rmdir $mountpoint || LogIt "Cannot rmdir (PBDI)\n"
     2116
     2117    if [ "$retval" -eq "0" ] ; then
     2118        echo -en "...$DONE\r"
     2119        if [ "$KERN_DISK_MADE" ] ; then
     2120            rm -f $imagefile
     2121            LogIt "... 1440KB boot+root disks were created OK\r"
     2122        else
     2123            LogIt "... "$disksize"KB boot disk was created OK\r"
     2124        fi
     2125    else
    21212126    echo -en "...failed\r"
    21222127    LogIt $disksize"KB boot disk was NOT created\r"
    21232128    rm -f $imagefile
    2124     fi
    2125     [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero\n"
    2126     return $retval
     2129    fi
     2130    [ "$retval" -ne "0" ] && LogIt "PrepareBootDiskImage() is returning nonzero\n"
     2131    return $retval
    21272132}
    21282133
     
    21312136
    21322137PrepareDataDiskImages() {
    2133     local needlist bigdir minidir_root tardir diskdir imagesdir res i j k old_pwd lines
    2134 
    2135     imagesdir=$1
    2136     rm -f $imagesdir/mindi-*.img $imagesdir/[0-9]*.tar.gz $imagesdir/mindi.iso
    2137     needlist=$TMP_ROOT/what-we-need.txt
    2138     bigdir=$TMP_ROOT/bigdir
    2139     minidir_root=$TMP_ROOT/minidir
    2140     mkdir -p $minidir_root
    2141     mkdir -p $bigdir/usr/bin
    2142     tardir=$TMP_ROOT/tardir
    2143 
    2144     lines=`cat $MINDI_CONF/deplist.txt | grep -vx " *#.*" | grep -vx "" |wc -l`
    2145     cat $MINDI_CONF/deplist.txt | GenerateGiantDependencyList $needlist $lines
    2146     res=$?
    2147     if [ "$YOUR_KERNEL_SUCKS" ]; then
     2138    local needlist bigdir minidir_root tardir diskdir imagesdir res i j k old_pwd lines
     2139
     2140    imagesdir=$1
     2141    rm -f $imagesdir/mindi-*.img $imagesdir/[0-9]*.tar.gz $imagesdir/mindi.iso
     2142    needlist=$TMP_ROOT/what-we-need.txt
     2143    bigdir=$TMP_ROOT/bigdir
     2144    minidir_root=$TMP_ROOT/minidir
     2145    mkdir -p $minidir_root
     2146    mkdir -p $bigdir/usr/bin
     2147    tardir=$TMP_ROOT/tardir
     2148
     2149    lines=`cat $MINDI_CONF/deplist.txt | grep -vx " *#.*" | grep -vx "" |wc -l`
     2150    cat $MINDI_CONF/deplist.txt | GenerateGiantDependencyList $needlist $lines
     2151    res=$?
     2152    if [ "$YOUR_KERNEL_SUCKS" ]; then
    21482153    pwd=`pwd`
    21492154    cd $TMP_ROOT
    2150         for i in `ListKernelModulePaths | HackPathsToFailsafe` ; do
    2151         cp --parents -pRdf ./$i $bigdir || Die "PDDI can't cp $i->$bigdir"
    2152         if [ "`du -sk $i | cut -f1`" -lt "$(($CHOPSIZE*2))" ] ; then
     2155        for i in `ListKernelModulePaths | HackPathsToFailsafe` ; do
     2156        cp --parents -pRdf ./$i $bigdir || Die "PDDI can't cp $i->$bigdir"
     2157        if [ "`du -sk $i | cut -f1`" -lt "$(($CHOPSIZE*2))" ] ; then
    21532158        cp --parents -pRdf $i $bigdir
    2154         else
     2159        else
    21552160        ChopUpAndCopyFile $i $bigdir $CHOPSIZE $BIGNO
    21562161        BIGNO=$(($BIGNO+1))
    2157         fi
     2162        fi
    21582163    done
    21592164    for i in $EXTRA_MODS ; do
    2160         j=`find lib/modules/$FAILSAFE_KVER -name $i.*o 2> /dev/null`
    2161         [ ! "$j" ] && echo "Warning - cannot find failsafe module $i.o" >> $LOGFILE
    2162         for k in $j ; do
     2165        j=`find lib/modules/$FAILSAFE_KVER -name $i.*o 2> /dev/null`
     2166        [ ! "$j" ] && echo "Warning - cannot find failsafe module $i.o" >> $LOGFILE
     2167        for k in $j ; do
    21632168        if [ "`du -sk $k | cut -f1`" -lt "$CHOPSIZE" ] ; then
    21642169            cp --parents -pRdf $k $bigdir
     
    21682173        fi
    21692174        echo "Added failsafe module $k to ramdisk" >> $LOGFILE
    2170         done
     2175        done
    21712176    done
    21722177    cd $pwd
    2173     else
     2178    else
    21742179    ListKernelModulePaths >> $needlist
    2175     fi
    2176     if [ "$res" -ne "0" ] ; then
    2177     rm -f /tmp/mindi-needlist.txt
    2178     Die "You have $res file`PluralOrNot $res` present in dependency list\nbut absent from filesystem."
    2179     fi
    2180     FindAndAddUserKeyboardMappingFile
    2181     mkdir -p $bigdir/tmp
    2182     if [ "`DidMondoCallMe`" ] ; then
    2183         MakeMondoConfigFile $TMP_ROOT/mondo-restore.cfg
    2184         cp -f $TMP_ROOT/mondo-restore.cfg $bigdir/tmp &> /dev/null
    2185         cp -f $TMP_ROOT/mondo-restore.cfg $CACHE_LOC &> /dev/null
    2186     fi
    2187     [ -d "/mnt/.boot.d" ] && echo "Oh Jebus" > $bigdir/tmp/DUMBASS-GENTOO
    2188     DropOptimizedLibraries $needlist $bigdir
    2189     echo -en "Assembling dependency files"
    2190     CopyDependenciesToDirectory < $needlist $bigdir
     2180    fi
     2181    if [ "$res" -ne "0" ] ; then
     2182        Die "You have $res file`PluralOrNot $res` present in dependency list\nbut absent from filesystem."
     2183    fi
     2184    FindAndAddUserKeyboardMappingFile
     2185    mkdir -p $bigdir/tmp
     2186    if [ "`DidMondoCallMe`" ] ; then
     2187        MakeMondoConfigFile $TMP_ROOT/mondo-restore.cfg
     2188        cp -f $TMP_ROOT/mondo-restore.cfg $bigdir/tmp &> /dev/null
     2189        cp -f $TMP_ROOT/mondo-restore.cfg $CACHE_LOC &> /dev/null
     2190    fi
     2191    [ -d "/mnt/.boot.d" ] && echo "Oh Jebus" > $bigdir/tmp/DUMBASS-GENTOO
     2192    DropOptimizedLibraries $needlist $bigdir
     2193    echo -en "Assembling dependency files"
     2194    CopyDependenciesToDirectory < $needlist $bigdir
    21912195
    21922196# also copy io.sys and msdos.sys, if we can find them
    2193     for i in `mount | cut -d' ' -f3` ; do
     2197    for i in `mount | cut -d' ' -f3` ; do
    21942198    for j in io.sys msdos.sys ; do
    2195         [ -e "$i/$j" ] && cp -f $i/$j $bigdir
    2196     done
    2197     done
     2199        [ -e "$i/$j" ] && cp -f $i/$j $bigdir
     2200    done
     2201    done
    21982202
    21992203# master boot record, too
    2200     i=`cat $MONDO_TMP/BOOTLOADER.DEVICE 2> /dev/null`
    2201     if [ "$i" ] ; then
     2204    i=`cat $MONDO_TMP/BOOTLOADER.DEVICE 2> /dev/null`
     2205    if [ "$i" ] ; then
    22022206    LogIt "Backing up $i's MBR"
    22032207    dd if=$i of=$bigdir/BOOTLOADER.MBR bs=446 count=1 >> $LOGFILE 2>> $LOGFILE
     
    22112215    mkdir -p $bigdir/dev
    22122216    cp -pRdf $j $bigdir/dev/boot_device || Die "Unable to create /dev/boot_device on ramdisk"
    2213     fi
     2217    fi
    22142218
    22152219# more stuff
    22162220#    cp -f $MINDI_HOME/embleer* $bigdir
    2217     old_pwd=`pwd`
    2218     cd $bigdir
    2219 
    2220     [ -e "$MINDI_HOME/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'."
    2221     cp -Rdf $MINDI_HOME/aux-tools/* . 2>> $LOGFILE || LogIt "Warning - error occurred while unzipping aux-tools\n"
    2222     if [ -e "$MINDI_HOME/x11-tools.tgz" ] ; then
     2221    old_pwd=`pwd`
     2222    cd $bigdir
     2223
     2224    [ -e "$MINDI_HOME/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'."
     2225    cp -Rdf $MINDI_HOME/aux-tools/* . 2>> $LOGFILE || LogIt "Warning - error occurred while unzipping aux-tools\n"
     2226    if [ -e "$MINDI_HOME/x11-tools.tgz" ] ; then
    22232227    tar -zxf $MINDI_HOME/x11-tools.tgz 2>> $LOGFILE || LogIt "Warning - error occurred while unzipping x11-tools.tgz\n"
    2224     fi
    2225     if [ -e "$MONDO_HOME/restore-scripts" ] ; then
    2226         cp -Rdf $MONDO_HOME/restore-scripts/* . 2>> $LOGFILE
    2227         [ "$?" -ne "0" ] && [ "`DidMondoCallMe`" ] && Die "Cannot find/install $MINDI_HOME/restore-scripts"
    2228     fi
    2229     [ -d "/lib/dev-state" ] && cp --parents -pRdf /lib/dev-state .
    2230     cd $old_pwd
    2231     echo -e "$DONE"
    2232     TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`
    2233     SplitDirectoryIntoMinidirs $bigdir $minidir_root
    2234     noof_disks=$?
    2235     [ "$noof_disks" -eq "0" ] && Die "Too much stuff!"
     2228    fi
     2229    if [ -e "$MONDO_HOME/restore-scripts" ] ; then
     2230        cp -Rdf $MONDO_HOME/restore-scripts/* . 2>> $LOGFILE
     2231        [ "$?" -ne "0" ] && [ "`DidMondoCallMe`" ] && Die "Cannot find/install $MINDI_HOME/restore-scripts"
     2232    fi
     2233    [ -d "/lib/dev-state" ] && cp --parents -pRdf /lib/dev-state .
     2234    cd $old_pwd
     2235    echo -e "$DONE"
     2236    TOTAL_BIGDIR_SIZE=`du -sk $bigdir | cut -f1`
     2237    SplitDirectoryIntoMinidirs $bigdir $minidir_root
     2238    noof_disks=$?
     2239    [ "$noof_disks" -eq "0" ] && Die "Too much stuff!"
    22362240#    if [ "$noof_disks" -ge "8" ] ; then
    22372241#        LogIt "You are putting a ludicrously large amount of data on these disks."
     
    22392243#        EXTRA_SPACE=$(($EXTRA_SPACE*2))
    22402244#    fi
    2241     MakeMountlist $TMP_ROOT/mountlist.txt
    2242     mkdir -p $minidir_root/$noof_disks/tmp
    2243     cp -f $TMP_ROOT/mountlist.txt $minidir_root/$noof_disks/tmp/mountlist.txt || Die "Cannot copy mountlist.txt from $TMP_ROOT to data disk"
    2244     cp -f $TMP_ROOT/mountlist.txt $CACHE_LOC
    2245     [ "`DidMondoCallMe`" ] && cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MONDO_TMP/.
    2246     [ -d "/proc/lvm" ] && $MINDI_HOME/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
    2247     [ -d "/dev/mapper" ] && $MINDI_HOME/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
    2248     cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE
    2249     ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks
    2250     CreateDataDiskImagesFromTarballs $tardir $imagesdir $noof_disks
    2251     FRIENDLY_OUTSTRING="Boot and data disk images were created."
     2245    MakeMountlist $TMP_ROOT/mountlist.txt
     2246    mkdir -p $minidir_root/$noof_disks/tmp
     2247    cp -f $TMP_ROOT/mountlist.txt $minidir_root/$noof_disks/tmp/mountlist.txt || Die "Cannot copy mountlist.txt from $TMP_ROOT to data disk"
     2248    cp -f $TMP_ROOT/mountlist.txt $CACHE_LOC
     2249    [ "`DidMondoCallMe`" ] && cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MONDO_TMP/.
     2250    [ -d "/proc/lvm" ] && $MINDI_HOME/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
     2251    [ -d "/dev/mapper" ] && $MINDI_HOME/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
     2252    cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE
     2253    ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks
     2254    CreateDataDiskImagesFromTarballs $tardir $imagesdir $noof_disks
     2255    FRIENDLY_OUTSTRING="Boot and data disk images were created."
    22522256# One 1.72MB boot disk, one 2.88MB boot disk and $noof_disks data disk images
    2253     rmdir $tardir $bigdir
    2254     rm -f $needlist
    2255     return $noof_disks
     2257    rmdir $tardir $bigdir
     2258    rm -f $needlist
     2259    return $noof_disks
    22562260}
    22572261
    22582262
    22592263ProcessLDD() {
    2260     local main_fname incoming j i fname f newf
    2261     main_fname=$1
    2262     read incoming
    2263     while [ "$incoming" != "" ] ; do
    2264         incoming=`echo "$incoming" | sed '/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*(.*/d ; s/[[:blank:]]*\(.*\)[[:blank:]]*=>[[:blank:]]*\/.*/\1/ ; s/[[:blank:]]*\(\/.*\)[[:blank:]]*(.*/\1/'`
    2265         for fname in `echo "$incoming"` ; do
    2266             fname=`LocateFile $fname`
    2267             for f in $fname ; do
    2268                 [ -e "$f" ] && echo $f
    2269             done
    2270         done
    2271         read incoming
    2272     done
     2264    local main_fname incoming j i fname f newf
     2265    main_fname=$1
     2266    read incoming
     2267    while [ "$incoming" != "" ] ; do
     2268        incoming=`echo "$incoming" | sed '/[[:blank:]]*.*[[:blank:]]*=>[[:blank:]]*(.*/d ; s/[[:blank:]]*\(.*\)[[:blank:]]*=>[[:blank:]]*\/.*/\1/ ; s/[[:blank:]]*\(\/.*\)[[:blank:]]*(.*/\1/'`
     2269        for fname in `echo "$incoming"` ; do
     2270            fname=`LocateFile $fname`
     2271            for f in $fname ; do
     2272                [ -e "$f" ] && echo $f
     2273            done
     2274        done
     2275        read incoming
     2276    done
    22732277}
    22742278
     
    22762280
    22772281Prompt() {
    2278     echo -en "$1"
    2279     read line
     2282    echo -en "$1"
     2283    read line
    22802284}
    22812285
     
    22832287
    22842288ReadLine() {
    2285     local i incoming
    2286     read incoming
    2287     i=0
    2288     while [ "$i" -le "32" ] && [ "$incoming" = "" ] ; do
     2289    local i incoming
     2290    read incoming
     2291    i=0
     2292    while [ "$i" -le "32" ] && [ "$incoming" = "" ] ; do
    22892293    i=$(($i+1))
    22902294    read incoming
    2291     done
    2292     echo "$incoming"
     2295    done
     2296    echo "$incoming"
    22932297}
    22942298
     
    22962300
    22972301RejigHyperlinks() {
    2298     local minidir_root noof_disks fname path diskno old_pwd awk_loc gawk_loc dir i
    2299     minidir_root=$1
    2300     noof_disks=$2
    2301 
    2302     old_pwd=`pwd`
    2303     diskno=1
    2304     while [ "$diskno" -le "$noof_disks" ] ; do
     2302    local minidir_root noof_disks fname path diskno old_pwd awk_loc gawk_loc dir i
     2303    minidir_root=$1
     2304    noof_disks=$2
     2305
     2306    old_pwd=`pwd`
     2307    diskno=1
     2308    while [ "$diskno" -le "$noof_disks" ] ; do
    23052309    mkdir -p $minidir_root/$diskno
    2306         cd $minidir_root/$diskno
    2307         for fname in `find -type d -o -print` ; do
    2308             [ -h "$minidir_root/$diskno/$fname" ] && MoveHyperlinkSensibly $fname $minidir_root $diskno $noof_disks
    2309         done
     2310        cd $minidir_root/$diskno
     2311        for fname in `find -type d -o -print` ; do
     2312            [ -h "$minidir_root/$diskno/$fname" ] && MoveHyperlinkSensibly $fname $minidir_root $diskno $noof_disks
     2313        done
    23102314    diskno=$(($diskno+1))
    2311     done
    2312 
    2313 
    2314     cd $old_pwd
    2315     return
     2315    done
     2316
     2317
     2318    cd $old_pwd
     2319    return
    23162320
    23172321
    23182322
    23192323# do some awk/gawk stuff
    2320     cd $minidir_root
    2321     awk_loc=`find -name awk`
    2322     gawk_loc=`find -name gawk`
    2323     if [ "$awk_loc" = "" ] && [ "$gawk_loc" != "" ] ; then
    2324         for i in $gawk_loc ; do HackAwk $i gawk ; done
    2325     elif [ "$gawk_loc" = "" ] && [ "$awk_loc" != "" ] ; then
    2326         for i in $awk_loc ; do HackAwk $i awk ; done
    2327     elif [ "$gawk_loc" != "" ] && [ "$awk_loc" != "" ] ; then
    2328         echo -en "Gawk/awk found. Good.\r"
    2329     else
    2330         Die "Look, I don't want to come across as having an attitude, but you need either awk or gawk. Get a distro that doesn't suck, okay? :-)"
    2331     fi
    2332     cd $old_pwd
     2324    cd $minidir_root
     2325    awk_loc=`find -name awk`
     2326    gawk_loc=`find -name gawk`
     2327    if [ "$awk_loc" = "" ] && [ "$gawk_loc" != "" ] ; then
     2328        for i in $gawk_loc ; do HackAwk $i gawk ; done
     2329    elif [ "$gawk_loc" = "" ] && [ "$awk_loc" != "" ] ; then
     2330        for i in $awk_loc ; do HackAwk $i awk ; done
     2331    elif [ "$gawk_loc" != "" ] && [ "$awk_loc" != "" ] ; then
     2332        echo -en "Gawk/awk found. Good.\r"
     2333    else
     2334        Die "Look, I don't want to come across as having an attitude, but you need either awk or gawk. Get a distro that doesn't suck, okay? :-)"
     2335    fi
     2336    cd $old_pwd
    23332337}
    23342338
     
    23372341EliminateRelatives() {
    23382342# eliminate /../../..... from path string
    2339     local orig i old_i newo
    2340     newo=$1
    2341     while [ "`echo "$newo" | grep "\.\."`" ] ; do
    2342         orig="`echo "$newo" | tr -s '/' '/'`"
     2343    local orig i old_i newo
     2344    newo=$1
     2345    while [ "`echo "$newo" | grep "\.\."`" ] ; do
     2346        orig="`echo "$newo" | tr -s '/' '/'`"
    23432347#        echo "orig=$orig"
    2344         newo="/"
    2345         old_i=""
    2346         for i in `echo "$orig" | tr '/' ' '` ; do
    2347             if [ ! "$old_i" ] ; then
    2348                 old_i=$i
    2349                 continue
    2350             fi
    2351             if [ "$old_i" ] && [ "$i" = ".." ] ; then
    2352                 if [ "$old_i" = ".." ] ; then
    2353                     newo="$newo"$old_i/
     2348        newo="/"
     2349        old_i=""
     2350        for i in `echo "$orig" | tr '/' ' '` ; do
     2351            if [ ! "$old_i" ] ; then
     2352                old_i=$i
     2353                continue
     2354            fi
     2355            if [ "$old_i" ] && [ "$i" = ".." ] ; then
     2356                if [ "$old_i" = ".." ] ; then
     2357                    newo="$newo"$old_i/
    23542358#                    echo "two --- $old_i $i"
    2355                     old_i="$i"
    2356                     continue
     2359                    old_i="$i"
     2360                    continue
    23572361#                else
    23582362#                    echo "swallowing ($old_i $i)"
    2359                 fi
    2360             elif [ "$old_i" != ".." ] ; then
    2361                 newo="$newo"$old_i/
    2362             fi
    2363             old_i=$i
    2364         done
    2365         newo="$newo"$i
    2366     done
    2367     echo "$newo"
     2363                fi
     2364            elif [ "$old_i" != ".." ] ; then
     2365                newo="$newo"$old_i/
     2366            fi
     2367            old_i=$i
     2368        done
     2369        newo="$newo"$i
     2370    done
     2371    echo "$newo"
    23682372}
    23692373
    23702374
    23712375WhatSoftlinkPointsTo() {
    2372     local orig new resolved
    2373         orig=$1
    2374         new=`ls -l $orig | tr -s ' ' '\t' | $AWK '{printf $NF;}'`
    2375         if [ "`echo "$new" | cut -d'/' -f1`" ] ; then
    2376             resolved=`dirname $orig`/$new
    2377         else
    2378             resolved=$new
    2379         fi
    2380     EliminateRelatives $resolved
     2376    local orig new resolved
     2377        orig=$1
     2378        new=`ls -l $orig | tr -s ' ' '\t' | $AWK '{printf $NF;}'`
     2379        if [ "`echo "$new" | cut -d'/' -f1`" ] ; then
     2380            resolved=`dirname $orig`/$new
     2381        else
     2382            resolved=$new
     2383        fi
     2384    EliminateRelatives $resolved
    23812385}
    23822386
     
    23862390
    23872391ReplaceIndividualLine() {
    2388     local orig_file new_file lino newstring lines_total lines_remaining
    2389     orig_file=$1.orig
    2390     mv -f $1 $orig_file || Die "Cannot move $1 to $orig_file"
    2391     new_file=$1
    2392     lino=$2
    2393     newstring="$3"
    2394     if [ "$lino" = "" ] || [ "$lino" -lt "1" ] ; then
     2392    local orig_file new_file lino newstring lines_total lines_remaining
     2393    orig_file=$1.orig
     2394    mv -f $1 $orig_file || Die "Cannot move $1 to $orig_file"
     2395    new_file=$1
     2396    lino=$2
     2397    newstring="$3"
     2398    if [ "$lino" = "" ] || [ "$lino" -lt "1" ] ; then
    23952399    echo "Can't find string" >> $LOGFILE
    23962400    return 1
    2397     fi
    2398     lines_total=`wc -l $orig_file | gawk '{print $1;}'`
    2399     lines_remaining=$(($lines_total-$lino))
    2400     head -n$(($lino-1)) $orig_file > $new_file
    2401     echo "$newstring" >> $new_file
    2402     echo "# The above line was added by Mindi, at the user's instruction" >> $new_file
    2403     tail -n$lines_remaining $orig_file >> $new_file
    2404     echo "Replace line $lino of $new_file with user-specified line, '$newstring'" >> $LOGFILE
     2401    fi
     2402    lines_total=`wc -l $orig_file | gawk '{print $1;}'`
     2403    lines_remaining=$(($lines_total-$lino))
     2404    head -n$(($lino-1)) $orig_file > $new_file
     2405    echo "$newstring" >> $new_file
     2406    echo "# The above line was added by Mindi, at the user's instruction" >> $new_file
     2407    tail -n$lines_remaining $orig_file >> $new_file
     2408    echo "Replace line $lino of $new_file with user-specified line, '$newstring'" >> $LOGFILE
    24052409#    cp -f $new_file /tmp/init.new
    2406     [ -x "$orig_file" ] && chmod +x $new_file
    2407     rm -f $orig_file
    2408     return 0
     2410    [ -x "$orig_file" ] && chmod +x $new_file
     2411    rm -f $orig_file
     2412    return 0
    24092413}
    24102414
     
    24132417
    24142418ResolveSoftlink() {
    2415     local resolved new
    2416     resolved=$1
    2417     while [ -h "$resolved" ] ; do
    2418         resolved=`WhatSoftlinkPointsTo $resolved`
    2419     done
    2420     echo "$resolved"
     2419    local resolved new
     2420    resolved=$1
     2421    while [ -h "$resolved" ] ; do
     2422        resolved=`WhatSoftlinkPointsTo $resolved`
     2423    done
     2424    echo "$resolved"
    24212425}
    24222426
     
    24282432
    24292433    for i in /dev/st0 /dev/ht0 /dev/cdrom /dev/cdrom0 /dev/cdrom 1 ; do
    2430         dd if=$i of=/dev/null bs=64k count=1 &> /dev/null
     2434        dd if=$i of=/dev/null bs=64k count=1 &> /dev/null
    24312435    done
    24322436}
     
    24352439
    24362440SizeOfPartition() {
    2437     local devpath drive res stub
    2438     device=$1
    2439     if [ "`echo "$device" | fgrep "/dev/md"`" != "" ] ; then
     2441    local devpath drive res stub
     2442    device=$1
     2443    if [ "`echo "$device" | fgrep "/dev/md"`" != "" ] ; then
    24402444    res=`SizeOfRaidPartition $device`
    24412445    [ "$res" = "" ] && Die "Cannot find $device's size - is your /etc/raidtab sane?"
    24422446    echo "$res"
    24432447    return 0
    2444     fi
     2448    fi
    24452449#    res=`$FDISK -l 2>> $LOGFILE | grep -w "$device" | head -n1 | sort -u | tr '*' ' ' | tr -s '\t' '|' | tr -s ' ' ' ' | cut -d' ' -f4 | sed s/+// | sed s/-//`
    24462450# patch from Bill <bill@iwizard.biz> - 2003/08/25
    2447     res=`$FDISK -s $device`
    2448     echo "------- $FDISK -l log ------------" >> $LOGFILE
    2449     cat $FDISKLOG >> $LOGFILE
    2450     echo "------- $FDISK log end ------------" >> $LOGFILE
     2451    res=`$FDISK -s $device`
     2452    echo "------- $FDISK -l log ------------" >> $LOGFILE
     2453    cat $FDISKLOG >> $LOGFILE
     2454    echo "------- $FDISK log end ------------" >> $LOGFILE
    24512455# end patch
    2452     [ "$res" = "" ] && res=`df -k -x supermount | tr -s '\t' ' ' | fgrep "$device " | cut -d' ' -f2`
    2453     [ "$res" = "" ] && res="-1"
    2454     echo $res
    2455     return 0
     2456    [ "$res" = "" ] && res=`df -k -x supermount | tr -s '\t' ' ' | fgrep "$device " | cut -d' ' -f2`
     2457    [ "$res" = "" ] && res="-1"
     2458    echo $res
     2459    return 0
    24562460}
    24572461
    24582462
    24592463SizeOfRaidPartition() {
    2460     local real_dev smallest_size silly tmp
    2461 
    2462     silly=999999999
    2463     smallest_size=$silly
    2464 
    2465     for real_dev in `GetRaidDevMembers $1` ; do
     2464    local real_dev smallest_size silly tmp
     2465
     2466    silly=999999999
     2467    smallest_size=$silly
     2468
     2469    for real_dev in `GetRaidDevMembers $1` ; do
    24662470    tmp=`SizeOfPartition $real_dev`
    24672471    [ "$tmp" -lt "$smallest_size" ] && smallest_size=$tmp
    2468     done
    2469 
    2470     if [ "$smallest_size" = "$silly" ] ; then
     2472    done
     2473
     2474    if [ "$smallest_size" = "$silly" ] ; then
    24712475    echo "-1"
    24722476    return 1
    2473     else
     2477    else
    24742478    echo "$smallest_size"
    24752479    return 0
    2476     fi
     2480    fi
    24772481}
    24782482
     
    24842488StripComments()
    24852489{
    2486     local tempfile
    2487     tempfile=$TMP_ROOT/$$.strip.txt
    2488     cp -f $1 $tempfile
    2489     cat $tempfile | $AWK '{if (substr($0,0,1)!="#" || substr($0,0,3)=="#!/") {print $0;};}' > $1
    2490     rm -f $tempfile
    2491     echo "Stripped comments from $2" >> $LOGFILE
     2490    local tempfile
     2491    tempfile=$TMP_ROOT/$$.strip.txt
     2492    cp -f $1 $tempfile
     2493    cat $tempfile | $AWK '{if (substr($0,0,1)!="#" || substr($0,0,3)=="#!/") {print $0;};}' > $1
     2494    rm -f $tempfile
     2495    echo "Stripped comments from $2" >> $LOGFILE
    24922496}
    24932497
     
    24982502
    24992503SplitDirectoryIntoMinidirs() {
    2500     local bigdir minidir_root i noof_disks old_pwd res
    2501     bigdir=$1
    2502     minidir_root=$2
    2503     rm -Rf $minidir_root/*
    2504 
    2505     TryToFitDataIntoSeveralDirs $bigdir $minidir_root
    2506     noof_disks=$?
    2507     if [ "$noof_disks" -eq "0" ] ; then
     2504    local bigdir minidir_root i noof_disks old_pwd res
     2505    bigdir=$1
     2506    minidir_root=$2
     2507    rm -Rf $minidir_root/*
     2508
     2509    TryToFitDataIntoSeveralDirs $bigdir $minidir_root
     2510    noof_disks=$?
     2511    if [ "$noof_disks" -eq "0" ] ; then
    25082512    echo "Failed to fit data into several dirs."
    2509         return 0
    2510     fi
    2511     RejigHyperlinks $minidir_root $noof_disks
    2512     rm -Rf $bigdir/*
     2513        return 0
     2514    fi
     2515    RejigHyperlinks $minidir_root $noof_disks
     2516    rm -Rf $bigdir/*
    25132517   return $noof_disks
    25142518}
     
    25182522StripExecutable()
    25192523{
    2520     local tmpfile
    2521     tmpfile=$TMP_ROOT/stripped.$$.dat
    2522     [ -d "$1" ] || [ -h "$1" ] && return
    2523     cp -f $1 $tmpfile
    2524     strip $tmpfile 2> /dev/null
    2525     if [ "$?" -eq "0" ] ; then
     2524    local tmpfile
     2525    tmpfile=$TMP_ROOT/stripped.$$.dat
     2526    [ -d "$1" ] || [ -h "$1" ] && return
     2527    cp -f $1 $tmpfile
     2528    strip $tmpfile 2> /dev/null
     2529    if [ "$?" -eq "0" ] ; then
    25262530    cp -f $tmpfile $1
    25272531    echo "Stripped binary $2" >> $LOGFILE
    2528     fi
    2529     rm -f $tmpfile
     2532    fi
     2533    rm -f $tmpfile
    25302534}
    25312535
    25322536
    25332537TemporarilyCompressAllFiles() {
    2534     local i orig_fname out_fname out_list
    2535 
    2536     i=0
    2537     out_list=$2/compressed/compressed.txt
    2538     mkdir -p $2/compressed
    2539     > $out_list
    2540     for orig_fname in $1 ; do
    2541         out_fname=$2/compressed/$orig_fname.gz
    2542         mkdir -p $out_fname 2> /dev/null
    2543         rmdir $out_fname 2> /dev/null
    2544         gzip -c6 $orig_fname > $out_fname 2> /dev/null
    2545         i=$(((($i+1))%15))
    2546         [ "$i" -eq "0" ] && echo -en "."
    2547         du -sk $out_fname >> $out_list
    2548     done
     2538    local i orig_fname out_fname out_list
     2539
     2540    i=0
     2541    out_list=$2/compressed/compressed.txt
     2542    mkdir -p $2/compressed
     2543    > $out_list
     2544    for orig_fname in $1 ; do
     2545        out_fname=$2/compressed/$orig_fname.gz
     2546        mkdir -p $out_fname 2> /dev/null
     2547        rmdir $out_fname 2> /dev/null
     2548        gzip -c6 $orig_fname > $out_fname 2> /dev/null
     2549        i=$(((($i+1))%15))
     2550        [ "$i" -eq "0" ] && echo -en "."
     2551        du -sk $out_fname >> $out_list
     2552    done
    25492553}
    25502554
     
    25522556
    25532557TryToFindKernelPath() {
    2554     local fname incoming res fkern_ver we_want_version possible_kernels noof_kernels kernelpath kdate duff_kernels
    2555     we_want_version=`uname -r`
    2556     possible_kernels=""
    2557     duff_kernels=""
     2558    local fname incoming res fkern_ver we_want_version possible_kernels noof_kernels kernelpath kdate duff_kernels
     2559    we_want_version=`uname -r`
     2560    possible_kernels=""
     2561    duff_kernels=""
    25582562   
    2559     if [ "$ARCH" = "ia64" ] ; then
    2560        root="/boot/efi/efi"
    2561     else
    2562        root="/"
    2563     fi
    2564     for fname in `find $root -maxdepth 2 -type f | fgrep lin | fgrep -v /proc/` ; do
     2563    if [ "$ARCH" = "ia64" ] ; then
     2564       root="/boot/efi/efi"
     2565    else
     2566       root="/"
     2567    fi
     2568    for fname in `find $root -maxdepth 2 -type f | fgrep lin | fgrep -v /proc/` ; do
    25652569    [ ! -e "$fname" ] && continue
    2566         [ "$fname" = "/boot/vmlinuz.shipped" ] && [ -f "/boot/vmlinuz" ] && continue; # ignore SuSE's extra kernel
     2570        [ "$fname" = "/boot/vmlinuz.shipped" ] && [ -f "/boot/vmlinuz" ] && continue; # ignore SuSE's extra kernel
    25672571    file $fname | grep -q gzip
    25682572    if [ "$?" -eq "0" ] ; then
    2569         # Used by ia64
    2570             fkern_ver=`gzip -cd $fname | strings 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
    2571     else
    2572             fkern_ver=`strings $fname 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
    2573     fi
    2574         [ "$fkern_ver" = "" ] && continue
     2573        # Used by ia64
     2574            fkern_ver=`gzip -cd $fname | strings 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
     2575    else
     2576            fkern_ver=`strings $fname 2> /dev/null | grep "[2-9]+*[.][0-9]+*[.][0-9]+*[^\@]*@"`
     2577    fi
     2578        [ "$fkern_ver" = "" ] && continue
    25752579#   echo "$fname --> $fkern_ver (but we want $we_want_version)" >> /dev/stderr
    2576         [ "`echo "$fkern_ver" |fgrep "$we_want_version "`" = "" ] && continue
     2580        [ "`echo "$fkern_ver" |fgrep "$we_want_version "`" = "" ] && continue
    25772581    [ -f "$fname" ] || continue
    25782582    [ -h "$fname" ] && continue
     
    25802584    file $fname | grep -q gzip
    25812585    if [ "$?" -eq "0" ] ; then
    2582         # Used by ia64
    2583         if [ "`gzip -cd $fname | strings 2> /dev/null | fgrep "$kdate"`" = "" ] ; then
    2584             LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting? Naughty but I'll allow it...\n"
    2585             duff_kernels="$fname $duff_kernels"
    2586         else
    2587                 [ "`echo "$fname" | fgrep "vmlinux"`" ] && continue
    2588                 possible_kernels="$fname $possible_kernels"
    2589         fi
    2590     else
    2591         if [ "`strings $fname 2> /dev/null | fgrep "$kdate"`" = "" ] ; then
    2592             LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting? Naughty but I'll allow it...\n"
    2593             duff_kernels="$fname $duff_kernels"
    2594         else
    2595                 [ "`echo "$fname" | fgrep "vmlinux"`" ] && continue
    2596                 possible_kernels="$fname $possible_kernels"
    2597         fi
    2598         fi
    2599     done
    2600     if [ ! "$possible_kernels" ] && uname -a | grep Knoppix > /dev/null ; then
     2586        # Used by ia64
     2587        if [ "`gzip -cd $fname | strings 2> /dev/null | fgrep "$kdate"`" = "" ] ; then
     2588            LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting? Naughty but I'll allow it...\n"
     2589            duff_kernels="$fname $duff_kernels"
     2590        else
     2591                [ "`echo "$fname" | fgrep "vmlinux"`" ] && continue
     2592                possible_kernels="$fname $possible_kernels"
     2593        fi
     2594    else
     2595        if [ "`strings $fname 2> /dev/null | fgrep "$kdate"`" = "" ] ; then
     2596            LogIt "Have you recompiled your kernel \"$fname\" w/o rebooting? Naughty but I'll allow it...\n"
     2597            duff_kernels="$fname $duff_kernels"
     2598        else
     2599                [ "`echo "$fname" | fgrep "vmlinux"`" ] && continue
     2600                possible_kernels="$fname $possible_kernels"
     2601        fi
     2602    fi
     2603    done
     2604    if [ ! "$possible_kernels" ] && uname -a | grep Knoppix > /dev/null ; then
    26012605    possible_kernels=`find /boot/vmlinuz-2.* | tail -n1`
    2602     fi
    2603     if [ ! "$possible_kernels" ] ; then
    2604         LogIt "No kernel matches exactly. Are there any duff kernels?"
    2605         possible_kernels="$duff_kernels"
    2606         if [ ! "$possible_kernels" ] ; then
    2607             LogIt "Sorry, no duff kernels either"
    2608         else
    2609             LogIt "I bet you're running Debian or Gentoo, aren't you?"
    2610             LogIt "Your kernel doesn't have a sane builddate. Oh well..."
    2611         fi
    2612     fi
    2613     possible_kernels=`echo "$possible_kernels" | tr -s ' ' '\n' | sort | uniq | tr '\n' ' '`
    2614     noof_kernels=`CountItemsIn "$possible_kernels"`
    2615     if [ "$noof_kernels" -eq "0" ] ; then
    2616         LogIt "Could not find your kernel.\n"
     2606    fi
     2607    if [ ! "$possible_kernels" ] ; then
     2608        LogIt "No kernel matches exactly. Are there any duff kernels?"
     2609        possible_kernels="$duff_kernels"
     2610        if [ ! "$possible_kernels" ] ; then
     2611            LogIt "Sorry, no duff kernels either"
     2612        else
     2613            LogIt "I bet you're running Debian or Gentoo, aren't you?"
     2614            LogIt "Your kernel doesn't have a sane builddate. Oh well..."
     2615        fi
     2616    fi
     2617    possible_kernels=`echo "$possible_kernels" | tr -s ' ' '\n' | sort | uniq | tr '\n' ' '`
     2618    noof_kernels=`CountItemsIn "$possible_kernels"`
     2619    if [ "$noof_kernels" -eq "0" ] ; then
     2620        LogIt "Could not find your kernel.\n"
    26172621    if [ -e "/boot/vmlinuz" ] ; then
    2618         LogIt "Using /boot/vmlinuz as a last resort.\n"
    2619         output=/boot/vmlinuz
    2620         else
    2621         output=""
    2622     fi
    2623     elif [ "$noof_kernels" -eq "1" ] ; then
    2624         kernelpath=`echo "$possible_kernels" | sed s/' '//`
    2625         echo "Your kernel is $kernelpath (v`uname -r`)" >> $LOGFILE
    2626         output="$kernelpath"
    2627     else
    2628         for i in $possible_kernels ; do
    2629             if echo $i | grep "`uname -r`" ; then
     2622        LogIt "Using /boot/vmlinuz as a last resort.\n"
     2623        output=/boot/vmlinuz
     2624        else
     2625        output=""
     2626    fi
     2627    elif [ "$noof_kernels" -eq "1" ] ; then
     2628        kernelpath=`echo "$possible_kernels" | sed s/' '//`
     2629        echo "Your kernel is $kernelpath (v`uname -r`)" >> $LOGFILE
     2630        output="$kernelpath"
     2631    else
     2632        for i in $possible_kernels ; do
     2633            if echo $i | grep "`uname -r`" ; then
    26302634        LogIt "OK, I used my initiative and found that "
    2631                 LogIt "$i is probably your kernel. "
     2635                LogIt "$i is probably your kernel. "
    26322636        output="$i"
    26332637        return
    2634         fi
    2635         done
     2638        fi
     2639        done
    26362640    if echo " $possible_kernels " | fgrep "/boot/vmlinuz " &> /dev/null ; then
    2637         output=/boot/vmlinuz
    2638         echo "Schlomo, this one's for you." >> $LOGFILE
    2639     else
    2640             LogIt "Two or more possible kernels found. You may specify any one of them and the \n"
    2641         LogIt "boot disks will still work, probably. If one does not work, try another.\n"
    2642             LogIt "$possible_kernels\n"
    2643             echo ""
    2644     fi
    2645     fi
    2646     echo "$output" | tr -s ' ' '\n' | sort -u | tr '\n' ' '
     2641        output=/boot/vmlinuz
     2642        echo "Schlomo, this one's for you." >> $LOGFILE
     2643    else
     2644            LogIt "Two or more possible kernels found. You may specify any one of them and the \n"
     2645        LogIt "boot disks will still work, probably. If one does not work, try another.\n"
     2646            LogIt "$possible_kernels\n"
     2647            echo ""
     2648    fi
     2649    fi
     2650    echo "$output" | tr -s ' ' '\n' | sort -u | tr '\n' ' '
    26472651}
    26482652
     
    26522656
    26532657TryToFitDataIntoSeveralDirs() {
    2654     local bigdir minidir_root noof_disks diskno list_of_files filename old_pwd progress
    2655     local i retval noof_disks total_files list_of_devs
    2656     bigdir=$1
    2657     minidir_root=$2
    2658     BIG_CLUNKY_SIZE_COUNTER=0
    2659     retval=0
    2660     noof_disks=1
    2661 
    2662     echo -en "\r                                                                            \rDividing data into several groups..."
    2663     old_pwd=`pwd`
    2664     cd $bigdir
    2665     list_of_files=`GetFileSizeList . | sort -nr | cut -f2 | fgrep -v "/dev/"`
    2666     progress=0
    2667     total_files=`CountItemsIn "$list_of_files"`
    2668     if [ "`echo "$filename" | grep -x "/dev/.*"`" ] ; then
    2669         filesize=1
    2670     fi
    2671     mkdir -p $minidir_root/$noof_disks
    2672     if [ -e "dev" ] ; then
    2673         echo "Copying dev/* to $minidir_root/$noof_disks" >> $LOGFILE
    2674         cp --parents -pRdf dev $minidir_root/$noof_disks
    2675     fi
    2676     TemporarilyCompressAllFiles "$list_of_files" $minidir_root
    2677     for filename in $list_of_files ; do
    2678         AddFileToDir $filename $minidir_root $noof_disks
     2658    local bigdir minidir_root noof_disks diskno list_of_files filename old_pwd progress
     2659    local i retval noof_disks total_files list_of_devs
     2660    bigdir=$1
     2661    minidir_root=$2
     2662    BIG_CLUNKY_SIZE_COUNTER=0
     2663    retval=0
     2664    noof_disks=1
     2665
     2666    echo -en "\r                                                                            \rDividing data into several groups..."
     2667    old_pwd=`pwd`
     2668    cd $bigdir
     2669    list_of_files=`GetFileSizeList . | sort -nr | cut -f2 | fgrep -v "/dev/"`
     2670    progress=0
     2671    total_files=`CountItemsIn "$list_of_files"`
     2672    if [ "`echo "$filename" | grep -x "/dev/.*"`" ] ; then
     2673        filesize=1
     2674    fi
     2675    mkdir -p $minidir_root/$noof_disks
     2676    if [ -e "dev" ] ; then
     2677        echo "Copying dev/* to $minidir_root/$noof_disks" >> $LOGFILE
     2678        cp --parents -pRdf dev $minidir_root/$noof_disks
     2679    fi
     2680    TemporarilyCompressAllFiles "$list_of_files" $minidir_root
     2681    for filename in $list_of_files ; do
     2682        AddFileToDir $filename $minidir_root $noof_disks
    26792683    i=$?
    26802684    if [ "$i" -gt "$noof_disks" ] ; then
    2681         noof_disks=$i
    2682         echo -en "\r\t\t\t\t\t\t($noof_disks disks)"
     2685        noof_disks=$i
     2686        echo -en "\r\t\t\t\t\t\t($noof_disks disks)"
    26832687    fi
    26842688    if [ "$i" -eq "0" ] ; then
    2685         LogIt "Cannot add file $filename to minidir $minidir_root\n"
    2686         retval=$(($retval+1))
    2687     fi
    2688         progress=$(($progress+1))
     2689        LogIt "Cannot add file $filename to minidir $minidir_root\n"
     2690        retval=$(($retval+1))
     2691    fi
     2692        progress=$(($progress+1))
    26892693    echo -en "\r\t\t\t\t\t\t\t\t$(($progress*100/$total_files))% complete\r"
    2690     done
    2691     cd $old_pwd
    2692     echo -en "\rThe files have been subdivided into $noof_disks directories.                                                            \r"
    2693     rm -Rf $minidir_root/compressed
    2694     if [ "$retval" -gt "0" ] ; then
     2694    done
     2695    cd $old_pwd
     2696    echo -en "\rThe files have been subdivided into $noof_disks directories.                                                            \r"
     2697    rm -Rf $minidir_root/compressed
     2698    if [ "$retval" -gt "0" ] ; then
    26952699    return 0
    2696     else
     2700    else
    26972701    return $noof_disks
    2698     fi
     2702    fi
    26992703}
    27002704
     
    27022706
    27032707TurnTgzIntoRdz() {
    2704     local tgz_dir_fname rdz_fname ramdisksize tempfile mountpoint old_pwd nodes disksize kernelsize maxsize res currsize not_copied j k floppy_modules s w
    2705     tgz_dir_fname=$1
    2706     rdz_fname=$2
    2707     ramdisksize=$3
    2708     disksize=$4
    2709     kernelsize=$5
    2710     maxsize=$(($disksize-$kernelsize))
    2711     maxsize=$(($maxsize*2)); # to allow for compression of 50%
    2712     tempfile=$TMP_ROOT/temp.rd
    2713     mountpoint=$TMP_ROOT/mnt1
    2714     res=0
    2715     echo -en "..."
    2716     dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (TurnTgzIntoRdz)"
    2717     echo -en "..."
    2718     mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE
    2719 
    2720     [ "$?" -ne "0" ] && cat /tmp/mke2fs.$$
    2721     rm -f /tmp/mke2fs.$$
    2722     echo -en "..."
    2723     mkdir -p $mountpoint
    2724     mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint"
    2725     echo -en "..."
    2726     old_pwd=`pwd`
    2727     cd $mountpoint
     2708    local tgz_dir_fname rdz_fname ramdisksize tempfile mountpoint old_pwd nodes disksize kernelsize maxsize res currsize not_copied j k floppy_modules s w
     2709    tgz_dir_fname=$1
     2710    rdz_fname=$2
     2711    ramdisksize=$3
     2712    disksize=$4
     2713    kernelsize=$5
     2714    maxsize=$(($disksize-$kernelsize))
     2715    maxsize=$(($maxsize*2)); # to allow for compression of 50%
     2716    tempfile=$TMP_ROOT/temp.rd
     2717    mountpoint=$TMP_ROOT/mnt1
     2718    res=0
     2719    echo -en "..."
     2720    dd if=/dev/zero of=$tempfile bs=1k count=$ramdisk_size &> /dev/null || Die "Not enough room for temporary ramdisk (TurnTgzIntoRdz)"
     2721    echo -en "..."
     2722    mke2fs -b 1024 -m 1 -i 2048 -F $tempfile >> $LOGFILE 2>> $LOGFILE
     2723
     2724    [ "$?" -ne "0" ] && cat /tmp/mke2fs.$$
     2725    rm -f /tmp/mke2fs.$$
     2726    echo -en "..."
     2727    mkdir -p $mountpoint
     2728    mount -t ext2 -o loop $tempfile $mountpoint || Die "Cannot loopmount $tempfile to $mountpoint"
     2729    echo -en "..."
     2730    old_pwd=`pwd`
     2731    cd $mountpoint
    27282732#    [ -e "$MINDI_HOME/memtest.img" ] && echo "Yep, this is a multi-function CD" > MULTIFUNC
    2729     cp -Rdf $tgz_dir_fname/* . 2>> $LOGFILE >> $LOGFILE
    2730     tar -zxf symlinks.tgz || Die "Cannot untar symlinks.tgz"
    2731     cd dev || Die "Can't cd to dev"
    2732     tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz"
    2733     rm -f dev-entries.tgz
    2734     cd ..
     2733    cp -Rdf $tgz_dir_fname/* . 2>> $LOGFILE >> $LOGFILE
     2734    tar -zxf symlinks.tgz || Die "Cannot untar symlinks.tgz"
     2735    cd dev || Die "Can't cd to dev"
     2736    tar -zxf dev-entries.tgz || Die "Cannot untar dev-entries.tgz"
     2737    rm -f dev-entries.tgz
     2738    cd ..
    27352739
    27362740# add insmod.static and insmod.static.old if (a) they exist and (b) this is a 64-bit distro
    27372741#    if [ "`uname -a | grep x86`" ] || [ "`uname -a | grep amd64`" ] ; then
    27382742
    2739     for w in insmod.static insmod.static.old ; do
     2743    for w in insmod.static insmod.static.old ; do
    27402744    s=`which $w 2> /dev/null`
    27412745    if [ -e "$s" ] ; then
    2742         cp --parents -af $s .
     2746        cp --parents -af $s .
    27432747#       LogIt "Copying $s to initrd"
    27442748    fi
    2745     done
     2749    done
    27462750
    27472751#    fi
    27482752
    2749     mkdir -p tmp
    2750     [ -e "/dev/.devfsd" ] && echo "/dev/.devfsd found" > tmp/USE-DEVFS
    2751     for w in cdrom floppy groovy-stuff ; do
    2752         mkdir -p mnt/$w
    2753     done
    2754     if [ "$RUN_AFTER_INITIAL_BOOT_PHASE" ] ; then
     2753    mkdir -p tmp
     2754    [ -e "/dev/.devfsd" ] && echo "/dev/.devfsd found" > tmp/USE-DEVFS
     2755    for w in cdrom floppy groovy-stuff ; do
     2756        mkdir -p mnt/$w
     2757    done
     2758    if [ "$RUN_AFTER_INITIAL_BOOT_PHASE" ] ; then
    27552759    ReplaceIndividualLine sbin/init `grep -n "#WHOLIVESINAPINEAPPLEUNDERTHESEA#" sbin/init | cut -d':' -f1` "$RUN_AFTER_INITIAL_BOOT_PHASE"
    2756     fi
    2757     if [ "$RUN_AFTER_BOOT_PHASE_COMPLETE" ] ; then
     2760    fi
     2761    if [ "$RUN_AFTER_BOOT_PHASE_COMPLETE" ] ; then
    27582762    ReplaceIndividualLine sbin/init `grep -n "#ABSORBENTANDYELLOWANDPOROUSISHE#" sbin/init | cut -d':' -f1` "$RUN_AFTER_BOOT_PHASE_COMPLETE"
    2759     fi
    2760 
    2761     lsmod > tmp/original-lsmod.txt
    2762    
    2763     cp --parents -Rdf /dev/fd0*[1,2][4,7,8]* . 2> /dev/null
    2764     cd $old_pwd
    2765     echo -en "..."
    2766     MakeModuleLoadingScript $TMPMODPROBE_FLAG $mountpoint/sbin/insert-all-my-modules
    2767     echo -en "..."
    2768     old_pwd=`pwd`
    2769     if [ "$YOUR_KERNEL_SUCKS" ] ; then
     2763    fi
     2764
     2765    lsmod > tmp/original-lsmod.txt
     2766   
     2767    cp --parents -Rdf /dev/fd0*[1,2][4,7,8]* . 2> /dev/null
     2768    cd $old_pwd
     2769    echo -en "..."
     2770    MakeModuleLoadingScript $TMPMODPROBE_FLAG $mountpoint/sbin/insert-all-my-modules
     2771    echo -en "..."
     2772    old_pwd=`pwd`
     2773    if [ "$YOUR_KERNEL_SUCKS" ] ; then
    27702774    cd $TMP_ROOT
    27712775    floppy_modules_path=lib/modules/$FAILSAFE_KVER
    2772     else
     2776    else
    27732777    cd /
    27742778###
    27752779### Sq-Modification... Use kernel name in module path if specified.
    27762780###
    2777         #floppy_modules_path=lib/modules/`uname -r`
    2778         if [ "${kernelname}" != "" ]
    2779         then
    2780           floppy_modules_path=lib/modules/${kernelname}
    2781         else
    2782           floppy_modules_path=lib/modules/`uname -r`
    2783         fi
     2781        #floppy_modules_path=lib/modules/`uname -r`
     2782        if [ "${kernelname}" != "" ]
     2783        then
     2784          floppy_modules_path=lib/modules/${kernelname}
     2785        else
     2786          floppy_modules_path=lib/modules/`uname -r`
     2787        fi
    27842788###
    27852789### Sq-Modification end
    27862790###
    2787     fi
    2788     floppy_modules=""
    2789     if [ "$disksize" -lt "2880" ] ; then
     2791    fi
     2792    floppy_modules=""
     2793    if [ "$disksize" -lt "2880" ] ; then
    27902794    list_of_groovy_mods="$FLOPPY_MODS `WhichOfTheseModulesAreLoaded "$SCSI_MODS"`"
    2791     else
     2795    else
    27922796    list_of_groovy_mods="$CDROM_MODS `WhichOfTheseModulesAreLoaded "$SCSI_MODS"`"
    2793     fi
    2794     if [ -e "$MONDO_TMP/start-nfs" ] ; then
    2795         cp -a $MONDO_TMP/start-nfs $mountpoint/sbin
    2796         # For PXE boot
    2797         list_of_groovy_mods="$list_of_groovy_mods $NET_MODS"
    2798             # Here we need the net busybox
    2799             mv $mountpoint/bin/busybox.net $mountpoint/bin/busybox
    2800     else
    2801             rm -f $mountpoint/bin/busybox.net
    2802     fi
    2803     [ -e "$floppy_modules_path" ] || LogIt "path $floppy_modules_path does not exist. If you're not using a modular kernel then you're NUTS."
    2804     for i in $list_of_groovy_mods ; do
     2797    fi
     2798    if [ -e "$MONDO_TMP/start-nfs" ] ; then
     2799        cp -a $MONDO_TMP/start-nfs $mountpoint/sbin
     2800        # For PXE boot
     2801        list_of_groovy_mods="$list_of_groovy_mods $NET_MODS"
     2802            # Here we need the net busybox
     2803            mv $mountpoint/bin/busybox.net $mountpoint/bin/busybox
     2804    else
     2805            rm -f $mountpoint/bin/busybox.net
     2806    fi
     2807    [ -e "$floppy_modules_path" ] || LogIt "path $floppy_modules_path does not exist. If you're not using a modular kernel then you're NUTS."
     2808    for i in $list_of_groovy_mods ; do
    28052809    floppy_modules="$floppy_modules `FindSpecificModuleInPath $floppy_modules_path $i`"
    2806     done
    2807     for i in $floppy_modules ; do
    2808         [ -e "$i" ] && s=`du -sk $i | cut -f1` || s=""
     2810    done
     2811    for i in $floppy_modules ; do
     2812        [ -e "$i" ] && s=`du -sk $i | cut -f1` || s=""
    28092813    [ "$YOUR_KERNEL_SUCKS" ] && i=$TMP_ROOT/$i
    28102814    echo "Adding $i ($s KB) to the rootfs" >> $LOGFILE
    28112815    cp -df $i $mountpoint/ || LogIt "Unable to copy $i to $mountpoint"
    28122816    [ "`echo "$i" | fgrep ".gz"`" ] && gunzip -f $mountpoint/`basename $i`
    2813     done
     2817    done
    28142818#    if [ -e "/dev/.devfsd" ] ; then
    28152819#   echo "Copying devfs stuff to ramdisk" >> $LOGFILE
     
    28182822#   done
    28192823#    fi
    2820     if [ ! -e "/sbin/devfsd" ] || [ "$disksize" -lt "2880" ] || [ "$kernelpath" = "$MINDI_HOME/vmlinuz" ] ; then
    2821         echo "Deleting devfsd daemon from ramdisk" >> $LOGFILE
    2822         [ ! -e "/sbin/devfsd" ] && echo "...because /sbin/devfsd not found" >> $LOGFILE
    2823         [ "$disksize" -lt "2880" ] && echo "...because disksize = $disksize" >> $LOGFILE
    2824         [ "$kernelpath" = "$MINDI_HOME/vmlinuz" ] && echo "...because kernel is failsafe" >> $LOGFILE
     2824    if [ ! -e "/sbin/devfsd" ] || [ "$disksize" -lt "2880" ] || [ "$kernelpath" = "$MINDI_HOME/vmlinuz" ] ; then
     2825        echo "Deleting devfsd daemon from ramdisk" >> $LOGFILE
     2826        [ ! -e "/sbin/devfsd" ] && echo "...because /sbin/devfsd not found" >> $LOGFILE
     2827        [ "$disksize" -lt "2880" ] && echo "...because disksize = $disksize" >> $LOGFILE
     2828        [ "$kernelpath" = "$MINDI_HOME/vmlinuz" ] && echo "...because kernel is failsafe" >> $LOGFILE
    28252829#        ls -l $mountpoint/sbin/devfsd &> /dev/null || Die "Can't find devfsd daemon on ramdisk"
    2826         rm -f $mountpoint/sbin/devfsd
    2827     fi
    2828     cd $old_pwd
    2829     [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $mountpoint/tmp/TAPEDEV-LIVES-HERE
    2830     dd if=/dev/zero of=$mountpoint/zero &> /dev/null
    2831     rm -f $mountpoint/zero
    2832     if [ "`DidMondoCallMe`" ] ; then
    2833         MakeMondoConfigFile $mountpoint/tmp/mondo-restore.cfg
    2834         cp -f $mountpoint/tmp/mondo-restore.cfg $MONDO_TMP &> /dev/null
    2835         cp -f $TMP_ROOT/mountlist.txt $mountpoint/tmp/ || Die "Cannot copy mountlist to ramdisk"
    2836         echo -en "$FILES_IN_FILELIST" > $mountpoint/tmp/FILES-IN-FILELIST
    2837         echo -en "$LAST_FILELIST_NUMBER" > $mountpoint/tmp/LAST-FILELIST-NUMBER
    2838         [ "$USE_LZO" = "yes" ] && echo -en "Pras 4 Pres 2004" >> $mountpoint/tmp/USING-LZO
    2839         [ "$USE_COMP" = "yes" ] && echo -en "Compression, yep" >> $mountpoint/tmp/USING-COMP
     2830        rm -f $mountpoint/sbin/devfsd
     2831    fi
     2832    cd $old_pwd
     2833    [ "$TAPEDEV" ] && echo -en "$TAPEDEV" > $mountpoint/tmp/TAPEDEV-LIVES-HERE
     2834    dd if=/dev/zero of=$mountpoint/zero &> /dev/null
     2835    rm -f $mountpoint/zero
     2836    if [ "`DidMondoCallMe`" ] ; then
     2837        MakeMondoConfigFile $mountpoint/tmp/mondo-restore.cfg
     2838        cp -f $mountpoint/tmp/mondo-restore.cfg $MONDO_TMP &> /dev/null
     2839        cp -f $TMP_ROOT/mountlist.txt $mountpoint/tmp/ || Die "Cannot copy mountlist to ramdisk"
     2840        echo -en "$FILES_IN_FILELIST" > $mountpoint/tmp/FILES-IN-FILELIST
     2841        echo -en "$LAST_FILELIST_NUMBER" > $mountpoint/tmp/LAST-FILELIST-NUMBER
     2842        [ "$USE_LZO" = "yes" ] && echo -en "Pras 4 Pres 2004" >> $mountpoint/tmp/USING-LZO
     2843        [ "$USE_COMP" = "yes" ] && echo -en "Compression, yep" >> $mountpoint/tmp/USING-COMP
    28402844    [ "$USE_STAR" = "yes" ] && echo =en "Using star. Hooray." >> $mountpoint/tmp/USING-STAR
    2841     fi
    2842     mkdir -p $mountpoint/tmp
    2843     mkdir -p $mountpoint/proc
    2844     echo "$disksize" > $mountpoint/tmp/$disksize.siz
    2845     find $mountpoint -name CVS -exec rm -rf '{}' \;
    2846     umount $mountpoint || Die "Cannot unmount $tempfile"
    2847     dd if=$tempfile bs=1k 2> /dev/null | gzip -v9 > $rdz_fname 2> /dev/null
     2845    fi
     2846    mkdir -p $mountpoint/tmp
     2847    mkdir -p $mountpoint/proc
     2848    echo "$disksize" > $mountpoint/tmp/$disksize.siz
     2849    find $mountpoint -name CVS -exec rm -rf '{}' \;
     2850    umount $mountpoint || Die "Cannot unmount $tempfile"
     2851    dd if=$tempfile bs=1k 2> /dev/null | gzip -v9 > $rdz_fname 2> /dev/null
    28482852#    gzip -9 $tempfile
    28492853#    mv $tempfile.gz $rdz_fname
    2850     if [ "$res" -eq "0" ] ; then
    2851         echo -en "..."
    2852     else
    2853         echo -en "\rMade an rdz WITH ERRORS.           \n"
    2854     fi
    2855     return 0
     2854    if [ "$res" -eq "0" ] ; then
     2855        echo -en "..."
     2856    else
     2857        echo -en "\rMade an rdz WITH ERRORS.           \n"
     2858    fi
     2859    return 0
    28562860}
    28572861
     
    28592863
    28602864WhichOfTheseModulesAreLoaded() {
    2861     local modname loaded_modules
    2862     loaded_modules=" `lsmod | tr -s ' ' '\t' | cut -f1 | fgrep -vx "Modules" | tr '\n' ' '` "
    2863     for modname in $1 ; do
     2865    local modname loaded_modules
     2866    loaded_modules=" `lsmod | tr -s ' ' '\t' | cut -f1 | fgrep -vx "Modules" | tr '\n' ' '` "
     2867    for modname in $1 ; do
    28642868    [ "`echo "$loaded_modules" | fgrep " $modname "`" ] && echo "$modname"
    2865     done
     2869    done
    28662870}
    28672871
     
    28702874
    28712875ZipMinidirsIntoTarballs() {
    2872     local minidir_root tardir noof_disks diskno old_pwd i
    2873     minidir_root=$1
    2874     tardir=$2
    2875     noof_disks=$3
    2876 
    2877     echo -en "Tarring and zipping the group`PluralOrNot $noof_disks`..."
    2878     mkdir -p $tardir
    2879     mkdir -p $minidir_root/all
    2880     old_pwd=`pwd`
    2881     diskno=1
    2882     while [ "$diskno" -le "$noof_disks" ] ; do
    2883         cd $minidir_root/$diskno || LogIt "Warning - cannot cd to $minidir_root/$diskno"
    2884         tar -c . -f- 2>> $LOGFILE | gzip -9 > $tardir/$diskno.tar.gz || Die "Can't tar/gzip disk#$diskno; please tell Hugo -exactly- what the errors where."
    2885         diskno=$(($diskno+1))
    2886         echo -n "..."
     2876    local minidir_root tardir noof_disks diskno old_pwd i
     2877    minidir_root=$1
     2878    tardir=$2
     2879    noof_disks=$3
     2880
     2881    echo -en "Tarring and zipping the group`PluralOrNot $noof_disks`..."
     2882    mkdir -p $tardir
     2883    mkdir -p $minidir_root/all
     2884    old_pwd=`pwd`
     2885    diskno=1
     2886    while [ "$diskno" -le "$noof_disks" ] ; do
     2887        cd $minidir_root/$diskno || LogIt "Warning - cannot cd to $minidir_root/$diskno"
     2888        tar -cf - . 2>> $LOGFILE | gzip -9 > $tardir/$diskno.tar.gz || Die "Can't tar/gzip disk#$diskno; please tell Hugo -exactly- what the errors where."
     2889        diskno=$(($diskno+1))
     2890        echo -n "..."
    28872891    cp -pRdf * $minidir_root/all
    2888     done
    2889     mkdir -p $minidir_root/all/tmp
    2890     cd $minidir_root/all
    2891     size_of_all_tools=`du -sk . | cut -f1`
    2892     if [ "`DidMondoCallMe`" ] ; then
    2893         for q in filelist.full.gz biggielist.txt ; do
    2894             [ ! -e "$MONDO_TMP/$q" ] && Die "Cannot find $MONDO_TMP/$q"
    2895             cp -pRdf $MONDO_TMP/$q tmp/
    2896         done
    2897         mkdir -p $minidir_root/all/tmp
    2898         echo -en "$FILES_IN_FILELIST" > $minidir_root/all/tmp/FILES-IN-FILELIST 2> /dev/null
    2899         echo -en "$LAST_FILELIST_NUMBER" > $minidir_root/all/tmp/LAST-FILELIST-NUMBER 2> /dev/null
    2900     fi
    2901     tar -c * -b 4096 -f- 2> /dev/null | gzip -9 > $tardir/all.tar.gz
    2902     dd if=/dev/zero bs=1k count=64 >> $imagesdir/all.tar.gz 2> /dev/null
    2903     [ "`du -sm $imagesdir/all.tar.gz | cut -f1`" -ge "30" ] && Die "You have too many tools in your shed"
    2904     cd $old_pwd
    2905     rm -Rf $minidir_root
    2906     echo -e "$DONE"
     2892    done
     2893    mkdir -p $minidir_root/all/tmp
     2894    cd $minidir_root/all
     2895    size_of_all_tools=`du -sk . | cut -f1`
     2896    if [ "`DidMondoCallMe`" ] ; then
     2897        for q in filelist.full.gz biggielist.txt ; do
     2898            [ ! -e "$MONDO_TMP/$q" ] && Die "Cannot find $MONDO_TMP/$q"
     2899            cp -pRdf $MONDO_TMP/$q tmp/
     2900        done
     2901        mkdir -p $minidir_root/all/tmp
     2902        echo -en "$FILES_IN_FILELIST" > $minidir_root/all/tmp/FILES-IN-FILELIST 2> /dev/null
     2903        echo -en "$LAST_FILELIST_NUMBER" > $minidir_root/all/tmp/LAST-FILELIST-NUMBER 2> /dev/null
     2904    fi
     2905    tar -b 4096 -cf - * 2> /dev/null | gzip -9 > $tardir/all.tar.gz
     2906    dd if=/dev/zero bs=1k count=64 >> $imagesdir/all.tar.gz 2> /dev/null
     2907    [ "`du -sm $imagesdir/all.tar.gz | cut -f1`" -ge "30" ] && Die "You have too many tools in your shed"
     2908    cd $old_pwd
     2909    rm -Rf $minidir_root
     2910    echo -e "$DONE"
    29072911}
    29082912
     
    29112915
    29122916ListUnsavedKernelModules() {
    2913     local fname modules
    2914     fname=/tmp/$RANDOM.$$.$RANDOM
    2915     ListKernelModules > $fname
    2916     lsmod | cut -d' ' -f1 >> $fname
    2917     lsmod | cut -d' ' -f1 >> $fname
    2918     modules=`cat $fname | sort | uniq -d2 | tr '\n' ' '`
    2919     rm -f $fname
    2920     [ "$modules" ] && echo "Unsaved kernel modules: $modules" >> $LOGFILE
     2917    local fname modules
     2918    fname=/tmp/$RANDOM.$$.$RANDOM
     2919    ListKernelModules > $fname
     2920    lsmod | cut -d' ' -f1 >> $fname
     2921    lsmod | cut -d' ' -f1 >> $fname
     2922    modules=`cat $fname | sort | uniq -d2 | tr '\n' ' '`
     2923    rm -f $fname
     2924    [ "$modules" ] && echo "Unsaved kernel modules: $modules" >> $LOGFILE
    29212925}
    29222926
     
    29422946
    29432947if [ "$1" = "-V" ] || [ "$1" = "-v" ] || [ "$1" = "--version" ] || [ "$1" = "-version" ] ; then
    2944     echo "mindi v$MINDI_VERSION"
    2945     exit 0
     2948    echo "mindi v$MINDI_VERSION"
     2949    exit 0
    29462950fi
    29472951
     
    29562960
    29572961if [ -e "/etc/conf.modules" ] && [ ! -e "/etc/modules.conf" ] ; then
    2958     LogIt "Warning. Ancient distro detected." 1
    2959     ln -sf /etc/conf.modules /etc/modules.conf
     2962    LogIt "Warning - Ancient distro detected." 1
     2963    ln -sf /etc/conf.modules /etc/modules.conf
    29602964fi
    29612965[ -e "/sbin/mkdosfs" ] && [ ! -e "/sbin/mkfs.vfat" ] && ln -sf /sbin/mkdosfs /sbin/mkfs.vfat
     
    29852989### Fix as it's not mandatory on ia64
    29862990if [ "$ARCH" = "ia64" ] ; then
    2987     FindELiloBinary
     2991    FindELiloBinary
    29882992else
    2989     FindIsolinuxBinary
    2990     FindLiloBinary
     2993    FindIsolinuxBinary
     2994    FindLiloBinary
    29912995fi
    29922996cat /proc/mounts | fgrep " $TMP_ROOT " | fgrep tmpfs > /dev/null 2> /dev/null && TMP_ROOT=/home && LogIt "Changing TMP_ROOT to $TMP_ROOT because you're using tmpfs for /tmp" ; # tmpfs doesn't like Mindi and /tmp, for some reason
     
    30043008
    30053009if [ "$#" -ge "2" ] ; then
    3006     if [ "$1" = "--max-compressed-size" ] ; then
    3007     MAX_COMPRESSED_SIZE=$2
    3008     shift; shift
    3009     fi
     3010    if [ "$1" = "--max-compressed-size" ] ; then
     3011        MAX_COMPRESSED_SIZE=$2
     3012        shift; shift
     3013    fi
    30103014fi
    30113015
    30123016FLOPPY_WAS_MOUNTED=""
    30133017for mtpt in /media/floppy /mnt/floppy /floppy ; do
    3014     if mount | grep -w $mtpt &> /dev/null ; then
    3015     FLOPPY_WAS_MOUNTED="$FLOPPY_WAS_MOUNTED $mtpt"
    3016     umount $mtpt
    3017     fi
     3018    if mount | grep -w $mtpt &> /dev/null ; then
     3019        FLOPPY_WAS_MOUNTED="$FLOPPY_WAS_MOUNTED $mtpt"
     3020        umount $mtpt
     3021    fi
    30183022done
    30193023
    30203024if [ "$#" -ne "0" ] ; then
    3021     if [ "$1" = "--findkernel" ] ; then
    3022         res=`TryToFindKernelPath`
     3025    if [ "$1" = "--findkernel" ] ; then
     3026        res=`TryToFindKernelPath`
    30233027#    2> /dev/null`
    3024         if [ "$res" = "" ] ; then
    3025             exit 1
    3026         else
    3027             echo "$res"
    3028             exit 0
    3029         fi
    3030     elif [ "$1" = "--makemountlist" ] ; then
    3031         [ ! "$2" ] && Die "Please specify the output file"
    3032         MakeMountlist $2
    3033         exit $?
    3034     elif [ "$1" = " --version" ] || [ "$1" = "-v" ] ; then
     3028        if [ "$res" = "" ] ; then
     3029            exit 1
     3030        else
     3031            echo "$res"
     3032            exit 0
     3033        fi
     3034    elif [ "$1" = "--makemountlist" ] ; then
     3035        [ ! "$2" ] && Die "Please specify the output file"
     3036        MakeMountlist $2
     3037        exit $?
     3038    elif [ "$1" = " --version" ] || [ "$1" = "-v" ] ; then
    30353039    echo "Mindi v$MINDI_VERSION"
    3036         exit 0
    3037     elif [ "$#" -ge "9" ] && [ "$1" = "--custom" ] ; then
     3040        exit 0
     3041    elif [ "$#" -ge "9" ] && [ "$1" = "--custom" ] ; then
    30383042    TMP_ROOT=$2
    30393043    MONDO_TMP=$2
     
    30453049### if module path is found then use it other wise use uname -r to set it...
    30463050###
    3047         kernelname=`echo $kernelpath | cut -d'-' -f2-`
     3051        kernelname=`echo $kernelpath | cut -d'-' -f2-`
    30483052    LogIt "kernelname = $kernelname"
    30493053    LogIt "kernelpath = $kernelpath"
    3050         if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
    3051         then
    3052            LogIt "Module path for ${kernelpath} not found...\n"
    3053            LogIt "using running kernel\'s modules.\n"
    3054            kernelname=`uname -r`
    3055         else
    3056            LogIt "Using modules for kernel: ${kernelname}\n"
    3057         fi
     3054        if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
     3055        then
     3056           LogIt "Module path for ${kernelpath} not found...\n"
     3057           LogIt "using running kernel\'s modules.\n"
     3058           kernelname=`uname -r`
     3059        else
     3060           LogIt "Using modules for kernel: ${kernelname}\n"
     3061        fi
    30583062###
    30593063### end of Sq-Modification
     
    30643068    USE_LZO=$8
    30653069    CDRECOVERY=$9
    3066         if [ "${10}" = "(null)" ] || [ "${10}" = "" ] ; then
    3067             IMAGE_DEVS=""
    3068         else
    3069             IMAGE_DEVS="`echo "${10}" | tr '|' ' '`"
    3070         fi
     3070        if [ "${10}" = "(null)" ] || [ "${10}" = "" ] ; then
     3071            IMAGE_DEVS=""
     3072        else
     3073            IMAGE_DEVS="`echo "${10}" | tr '|' ' '`"
     3074        fi
    30713075    if [ "${11}" ] ; then
    3072         LILO_OPTIONS=""
     3076        LILO_OPTIONS=""
    30733077#       LogIt "LILO will use conservative settings, to be compatible with older BIOSes."
    30743078    fi
    30753079    LAST_FILELIST_NUMBER=${12}
    3076         ESTIMATED_TOTAL_NOOF_SLICES=${13}
    3077         EXCLUDE_DEVS="${14}"
    3078         USE_COMP="${15}"
    3079         USE_LILO="${16}"
     3080        ESTIMATED_TOTAL_NOOF_SLICES=${13}
     3081        EXCLUDE_DEVS="${14}"
     3082        USE_COMP="${15}"
     3083        USE_LILO="${16}"
    30803084    USE_STAR="${17}"
    30813085    INTERNAL_TAPE_BLOCK_SIZE="${18}"
    3082         DIFFERENTIAL="${19}"
    3083         NOT_BOOT="${20}"
    3084         [ "$USE_COMP" = "" ] && USE_COMP=yes
    3085         [ "$NOT_BOOT" = "" ] && NOT_BOOT=no
     3086        DIFFERENTIAL="${19}"
     3087        NOT_BOOT="${20}"
     3088        [ "$USE_COMP" = "" ] && USE_COMP=yes
     3089        [ "$NOT_BOOT" = "" ] && NOT_BOOT=no
    30863090    [ "$TAPEDEV" ] && LogIt "This is a tape-based backup. Fine."
    30873091    [ "$kernelpath" = "" ] && kernelpath=`TryToFindKernelPath`
    3088         kernelname=`echo $kernelpath | cut -d'-' -f2-`
    3089         if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
    3090         then
    3091            LogIt "Module path for ${kernelpath} not found...\n"
    3092            LogIt "using running kernel\'s modules.\n"
    3093            kernelname=`uname -r`
    3094         else
    3095            LogIt "Using modules for kernel: ${kernelname}\n"
    3096         fi
     3092        kernelname=`echo $kernelpath | cut -d'-' -f2-`
     3093        if [ ! -d "/lib/modules/$kernelname" ] && [ "$kernelpath" != "FAILSAFE" ]
     3094        then
     3095           LogIt "Module path for ${kernelpath} not found...\n"
     3096           LogIt "using running kernel\'s modules.\n"
     3097           kernelname=`uname -r`
     3098        else
     3099           LogIt "Using modules for kernel: ${kernelname}\n"
     3100        fi
    30973101    [ "$CDRECOVERY" = "yes" ] && [ "$TAPEDEV" != "" ] && Die "Sorry, you can't use --cd-recovery and --write-tapes at the same time"
    3098         MONDO_ROOT=`echo $imagesdir | sed 's/\(.*\)\/.*/\1/'`
     3102        MONDO_ROOT=`echo $imagesdir | sed 's/\(.*\)\/.*/\1/'`
    30993103    [ "$MONDO_ROOT" = "" ] && Die "MONDO_ROOT is undefined"
    3100     else
     3104    else
    31013105    echo "Syntax: mindi (--custom ....)" >> /dev/stderr
    31023106    exit 1
    3103     fi
     3107    fi
    31043108fi
    31053109#ScanCDandTape
    31063110[ "$CDRECOVERY" = "yes" ] || CDRECOVERY=no
    31073111if [ "$CDRECOVERY" = "yes" ] ; then
    3108     iso_cfg_file=$MINDI_HOME/isolinux-H.cfg
    3109     sys_cfg_file=$MINDI_HOME/syslinux-H.cfg
     3112    iso_cfg_file=$MINDI_HOME/isolinux-H.cfg
     3113    sys_cfg_file=$MINDI_HOME/syslinux-H.cfg
    31103114else
    3111     iso_cfg_file=$MINDI_HOME/isolinux.cfg
    3112     sys_cfg_file=$MINDI_HOME/syslinux.cfg
     3115    iso_cfg_file=$MINDI_HOME/isolinux.cfg
     3116    sys_cfg_file=$MINDI_HOME/syslinux.cfg
    31133117fi
    31143118
     
    31323136mkdir -p $imagesdir
    31333137if [ ! "`DidMondoCallMe`" ] ; then
    3134     LogIt "Mindi Linux mini-distro generator v$MINDI_VERSION by Hugo Rabson"
    3135     LogIt "Latest Mindi is available from http://www.mondorescue.org"
    3136     LogIt "BusyBox sources are available from http://www.busybox.net"
    3137     LogIt "------------------------------------------------------------------------------"
     3138    LogIt "Mindi Linux mini-distro generator v$MINDI_VERSION by Hugo Rabson"
     3139    LogIt "Latest Mindi is available from http://www.mondorescue.org"
     3140    LogIt "BusyBox sources are available from http://www.busybox.net"
     3141    LogIt "------------------------------------------------------------------------------"
    31383142else
    3139     echo "You are using Mindi-Linux v$MINDI_VERSION to make boot+data disks" >> /var/log/mondo-archive.log
     3143    echo "You are using Mindi-Linux v$MINDI_VERSION to make boot+data disks" >> /var/log/mondo-archive.log
    31403144fi
    31413145
     
    31433147insmod /lib/modules/`uname -r`/*/*/misc/aes.*o.gz >> $LOGFILE 2>> $LOGFILE
    31443148for i in loop cdrom ide-cd isofs linear raid0 raid1 raid5 ; do
    3145     insmod $i >> $LOGFILE 2>> $LOGFILE
     3149    insmod $i >> $LOGFILE 2>> $LOGFILE
    31463150done
    31473151
     
    31533157echo "NOT_BOOT = '$NOT_BOOT'" >> $LOGFILE
    31543158if [ "$NOT_BOOT" != "" ] && [ "$NOT_BOOT" != "0" ] && [ "$NOT_BOOT" != "no" ] ; then
    3155     LogIt "Just creating mondo-restore.cfg and a small all.tar.gz for Mondo. Nothing else."
    3156     MakeMondoConfigFile $MONDO_TMP/mondo-restore.cfg
    3157     MakeMountlist $MONDO_TMP/mountlist.txt
    3158     mkdir -p $MONDO_TMP/small-all/tmp
    3159     cd $MONDO_TMP/small-all
    3160     cp -f $MONDO_TMP/{mountlist.txt,mondo-restore.cfg,filelist.full.gz,biggielist.txt} tmp || Die "Cannot copy small all.tar.gz"
    3161     tar -cv tmp | gzip -9 > $MONDO_TMP/all.tar.gz || Die "Cannot make small all.tar.gz"
    3162     sleep 2
    3163     LogIt "Done. Exiting.\n"
    3164     exit 0
     3159    LogIt "Just creating mondo-restore.cfg and a small all.tar.gz for Mondo. Nothing else."
     3160    MakeMondoConfigFile $MONDO_TMP/mondo-restore.cfg
     3161    MakeMountlist $MONDO_TMP/mountlist.txt
     3162    mkdir -p $MONDO_TMP/small-all/tmp
     3163    cd $MONDO_TMP/small-all
     3164    cp -f $MONDO_TMP/{mountlist.txt,mondo-restore.cfg,filelist.full.gz,biggielist.txt} tmp || Die "Cannot copy small all.tar.gz"
     3165    tar -cv tmp | gzip -9 > $MONDO_TMP/all.tar.gz || Die "Cannot make small all.tar.gz"
     3166    sleep 2
     3167    LogIt "Done. Exiting.\n"
     3168    exit 0
    31653169fi
    31663170
    31673171if [ "$kernelpath" = "" ] ; then
    3168     [ "`DidMondoCallMe`" ] && Die "Please use -k <path> to specify kernel."
    3169     if [ $USE_OWN_KERNEL != "yes" ]; then
    3170         echo -en "Do you want to use your own kernel to build the boot disk (y/n) ?"
    3171         read ch
    3172         if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
    3173             USE_OWN_KERNEL="yes"
    3174         fi
    3175     fi
    3176     if [ "$USE_OWN_KERNEL" = "yes" ]; then
     3172    [ "`DidMondoCallMe`" ] && Die "Please use -k <path> to specify kernel."
     3173    if [ $USE_OWN_KERNEL != "yes" ]; then
     3174        echo -en "Do you want to use your own kernel to build the boot disk (y/n) ?"
     3175        read ch
     3176        if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
     3177            USE_OWN_KERNEL="yes"
     3178        fi
     3179    fi
     3180    if [ "$USE_OWN_KERNEL" = "yes" ]; then
    31773181    YOUR_KERNEL_SUCKS=""
    31783182    kernelpath=`TryToFindKernelPath`
    31793183    if [ "$kernelpath" = "" ] ; then
    3180         echo -n "Please enter kernel path : "
    3181         read kernelpath
    3182     fi
    3183     else
     3184        echo -n "Please enter kernel path : "
     3185        read kernelpath
     3186    fi
     3187    else
    31843188    YOUR_KERNEL_SUCKS="That's why you're using mine, dude. :-)"
    3185     fi
     3189    fi
    31863190fi
    31873191if [ ! "`DidMondoCallMe`" ] ; then
    3188     echo -en "Would you like to use LILO (instead of syslinux)\nfor your boot CD/floppies (y/n) ?"
    3189     read ch
    3190     if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
    3191         USE_LILO=yes
    3192     else
    3193         USE_LILO=no
    3194     fi
     3192    echo -en "Would you like to use LILO (instead of syslinux)\nfor your boot CD/floppies (y/n) ?"
     3193    read ch
     3194    if [ "$ch" != "n" ] && [ "$ch" != "N" ] ; then
     3195        USE_LILO=yes
     3196    else
     3197        USE_LILO=no
     3198    fi
    31953199fi
    31963200if [ "$YOUR_KERNEL_SUCKS" != "" ] || [ "$kernelpath" = "" ] || [ "$kernelpath" = "SUCKS" ] || [ "$kernelpath" = "FAILSAFE" ] ; then
    3197     kernelpath=$MINDI_HOME/vmlinuz
    3198     LogIt "I shall include Mindi's failsafe kernel, not your kernel, in the boot disks."
    3199     LogIt "However, you are still running your kernel. If Mindi fails to create your"
    3200     LogIt "disks then it may still be a result of a problem with your kernel."
    3201     pwd=`pwd`
    3202     cd $TMP_ROOT
    3203     bzip2 -dc $MINDI_HOME/lib.tar.bz2 | tar -x || Die "Cannot unzip lib.tar.bz2"
    3204     cd $pwd
    3205     YOUR_KERNEL_SUCKS="Your kernel sucks"
     3201    kernelpath=$MINDI_HOME/vmlinuz
     3202    LogIt "I shall include Mindi's failsafe kernel, not your kernel, in the boot disks."
     3203    LogIt "However, you are still running your kernel. If Mindi fails to create your"
     3204    LogIt "disks then it may still be a result of a problem with your kernel."
     3205    pwd=`pwd`
     3206    cd $TMP_ROOT
     3207    bzip2 -dc $MINDI_HOME/lib.tar.bz2 | tar -x || Die "Cannot unzip lib.tar.bz2"
     3208    cd $pwd
     3209    YOUR_KERNEL_SUCKS="Your kernel sucks"
    32063210fi
    32073211echo -e "Mindi's temp dir = $TMP_ROOT \nMindi's output dir=$imagesdir" >> $LOGFILE
     
    32213225echo "Ramdisk will be $ramdisk_size KB" >> $LOGFILE
    32223226if [ "$USE_LILO" = "yes" ] ; then
    3223     if [ "$ARCH" = "ia64" ] ; then
    3224         PrepareBootDiskImage_LILO $imagesdir $IA64_BOOT_SIZE $kernelpath $ramdisk_size || Die "Failed to create ia64 floppy disk image."
    3225     else
    3226         if ! PrepareBootDiskImage_LILO $imagesdir 1722 $kernelpath $ramdisk_size ; then
    3227         LogIt "Warning! Failed to create 1.72MB boot image. Please reduce your kernel's size"
    3228         LogIt "if you want to make a 1.72MB floppy floppy disk."
    3229         fi
    3230         PrepareBootDiskImage_LILO $imagesdir 2880 $kernelpath $ramdisk_size || Die "Failed to create 2.88MB floppy disk image."
    3231     fi
     3227    if [ "$ARCH" = "ia64" ] ; then
     3228        PrepareBootDiskImage_LILO $imagesdir $IA64_BOOT_SIZE $kernelpath $ramdisk_size || Die "Failed to create ia64 floppy disk image."
     3229    else
     3230        if ! PrepareBootDiskImage_LILO $imagesdir 1722 $kernelpath $ramdisk_size ; then
     3231        LogIt "Warning - failed to create 1.72MB boot image. Please reduce your kernel's size"
     3232        LogIt "if you want to make a 1.72MB floppy disk."
     3233        fi
     3234        PrepareBootDiskImage_LILO $imagesdir 2880 $kernelpath $ramdisk_size || Die "Failed to create 2.88MB floppy disk image."
     3235    fi
    32323236else
    3233     if ! PrepareBootDiskImage_SYSLINUX $imagesdir 1722 $kernelpath $ramdisk_size ; then
    3234     LogIt "Warning! Failed to create 1.72MB boot image. Please reduce your kernel's size"
    3235     LogIt "if you want to make a 1.72MB floppy floppy disk."
    3236     fi
    3237     if ! PrepareBootDiskImage_SYSLINUX $imagesdir 2880 $kernelpath $ramdisk_size ; then
    3238         LogIt "Warning! Failed to create 2.88MB floppy disk image."
    3239         LogIt "Please reduce your kernel's size"
    3240         LogIt "if you want to make a 2.88MB floppy floppy disk."
    3241     fi
    3242     PrepareBootDiskImage_SYSLINUX $imagesdir 5760 $kernelpath $ramdisk_size || Die "Failed to create 5.76MB floppy disk image."
     3237    if ! PrepareBootDiskImage_SYSLINUX $imagesdir 1722 $kernelpath $ramdisk_size ; then
     3238    LogIt "Warning - failed to create 1.72MB boot image. Please reduce your kernel's size"
     3239    LogIt "if you want to make a 1.72MB floppy disk."
     3240    fi
     3241    if ! PrepareBootDiskImage_SYSLINUX $imagesdir 2880 $kernelpath $ramdisk_size ; then
     3242        LogIt "Warning - failed to create 2.88MB floppy disk image."
     3243        LogIt "Please reduce your kernel's size"
     3244        LogIt "if you want to make a 2.88MB floppy disk."
     3245    fi
     3246    PrepareBootDiskImage_SYSLINUX $imagesdir 5760 $kernelpath $ramdisk_size || Die "Failed to create 5.76MB floppy disk image."
    32433247fi
    32443248
     
    32503254
    32513255if [ ! "`DidMondoCallMe`" ] ; then
    3252     ListImagesForUser $imagesdir
    3253     boot_dev=/dev/fd0u1722
    3254     [ ! -e "$boot_dev" ] && mknod $boot_dev b 2 60
    3255     [ ! -e "$boot_dev" ] && boot_dev=/dev/fd0H1722
    3256     [ ! -e "$boot_dev" ] && Die "Oh Lord, will you PLEASE tell the vendor to create the 1.72MB devices in /dev?"
    3257     if [ "$PROMPT_WRITE_BOOT_FLOPPIES" = "yes" ]; then
    3258         OfferToCopyImagesToDisks $imagesdir $boot_dev $FDDEVICE
    3259     fi
    3260     OfferToMakeBootableISO $imagesdir
    3261     LogIt "Finished.\n"
     3256    ListImagesForUser $imagesdir
     3257    boot_dev=/dev/fd0u1722
     3258    [ ! -e "$boot_dev" ] && mknod $boot_dev b 2 60
     3259    [ ! -e "$boot_dev" ] && boot_dev=/dev/fd0H1722
     3260    [ ! -e "$boot_dev" ] && Die "Oh Lord, will you PLEASE tell the vendor to create the 1.72MB devices in /dev?"
     3261    if [ "$PROMPT_WRITE_BOOT_FLOPPIES" = "yes" ]; then
     3262        OfferToCopyImagesToDisks $imagesdir $boot_dev $FDDEVICE
     3263    fi
     3264    OfferToMakeBootableISO $imagesdir
     3265    LogIt "Finished.\n"
    32623266elif [ "$TAPEDEV" ] ; then
    3263     mkdir -p /root/images/mindi
    3264     rm -f /root/images/mindi/{*img,*gz,*iso}
    3265     OfferToMakeBootableISO $imagesdir
    3266     if [ -e "$imagesdir/all.tar.gz" ] ; then
    3267         cp -f $imagesdir/all.tar.gz $MONDO_TMP/
    3268     else
     3267    mkdir -p /root/images/mindi
     3268    rm -f /root/images/mindi/{*img,*gz,*iso}
     3269    OfferToMakeBootableISO $imagesdir
     3270    if [ -e "$imagesdir/all.tar.gz" ] ; then
     3271        cp -f $imagesdir/all.tar.gz $MONDO_TMP/
     3272    else
    32693273    Die "Cannot find all.tar.gz, to be written to tape"
    3270     fi
     3274    fi
    32713275else
    3272     OfferToMakeBootableISO $imagesdir
     3276    OfferToMakeBootableISO $imagesdir
    32733277fi
    32743278if [ "$imagesdir" != "/root/images/mindi" ] ; then
    3275     for i in `find $imagesdir -maxdepth 1 -name "*.iso" -o -name "*.img"` ; do
     3279    for i in `find $imagesdir -maxdepth 1 -name "*.iso" -o -name "*.img"` ; do
    32763280    cp -f $i /root/images/mindi || LogIt "[line 1613] Cannot copy $i to /root/images/mindi"
    3277     done
     3281    done
    32783282fi
    32793283[ "$TMP_ROOT" != "/tmp" ] && rm -Rf $TMP_ROOT
    3280 rm -Rf /tmp/mindi-needlist.txt /tmp/mountlist.txt.$$
     3284# cleanup
     3285rm -f /tmp/mountlist.txt.$$ $FDISKLOG /tmp/mindilinux
    32813286LogIt "$FRIENDLY_OUTSTRING"
    32823287ListUnsavedKernelModules
    32833288for mtpt in $FLOPPY_WAS_MOUNTED ; do
    3284     mount $ptpt
     3289    mount $mtpt
    32853290done
    32863291echo "Mindi is exiting" >> $LOGFILE
Note: See TracChangeset for help on using the changeset viewer.