Changeset 741


Ignore:
Timestamp:
Aug 4, 2006, 1:04:25 PM (13 years ago)
Author:
bruno
Message:
  • Fix a bug for LVM where current_lvolume wasn't not re-initialized at each time (in a loop)
  • Introduces LVM and LVMCMD as global var for mindi (idea taken from init)
  • header for start-nfs
Location:
branches/stable/mindi
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mindi/mindi

    r739 r741  
    10761076
    10771077
    1078 
    10791078#ListKernelModules() {
    10801079    #local output q
     
    10941093        if [ ! -e "$fname" ] ; then
    10951094            echo "Warning - $fname does not exist; cannot be LDD'd." >> $LOGFILE
    1096         if echo $fname | grep lvm &> /dev/null ; then
    1097         echo "This warning only affects you if you are using LVM." >> $LOGFILE
    1098         if lsmod | grep lvm &> /dev/null ; then
    1099             echo "I think you are, so please take heed!" >> $LOGFILE
    1100 #           LogIt "Where is liblvm? You need it."
    1101         else
    1102             echo "I don't think you are, so don't worry about it." >> $LOGFILE
    1103         fi
    1104         fi
     1095            if echo $fname | grep lvm &> /dev/null ; then
     1096                echo "This warning only affects you if you are using LVM." >> $LOGFILE
     1097                if lsmod | grep lvm &> /dev/null ; then
     1098                    echo "I think you are, so please take heed!" >> $LOGFILE
     1099#                   LogIt "Where is liblvm? You need it."
     1100                else
     1101                    echo "I don't think you are, so don't worry about it." >> $LOGFILE
     1102                fi
     1103            fi
    11051104        elif [ -h "$fname" ] && [ -x "$fname" ] ; then
    1106         echo "$fname is softlink" >> $LOGFILE
     1105            echo "$fname is softlink" >> $LOGFILE
    11071106#            echo "$fname will not be LDD'd. It is a softlink to `WhatSoftlinkPointsTo $fname`, which should already be in queue to be analyzed." >> $LOGFILE
    11081107#            echo "$fname"
     
    13311330    all_partitions=""
    13321331   
    1333     if [ -d "/proc/lvm" ] || [ -d "/dev/mapper" ]; then
     1332    if [ $LVM != "false" ]; then
    13341333        echo -en "\rAnalyzing LVM...\r"
    13351334        all_partitions=`$MINDI_LIB/analyze-my-lvm | grep -F ">>>" | cut -d' ' -f2-32`
     
    14071406                current_partition=$actual_dev
    14081407            else
    1409                 Die "Your system uses a labelled swap partition, but you lack the tool to support it.\nPlease replace swap labels with their correct devices in /etc/fstab or install blkid|vol_id\n"
     1408                Die "Your system uses a labelled partition ($current_partition), but you lack the tool to support it.\nPlease replace labels with their correct devices in /etc/fstab or install blkid|vol_id\n"
    14101409            fi
    14111410        else
     
    14131412        fi
    14141413
    1415     partition_format=`$AWK '$1 == "'"$str_to_find_fmt_with"'" {print $3}' $MY_FSTAB`
    1416     # Some distributions such as Debian do not put /dev/<VG>/<LV> in fstab
    1417     # for LVM partitions but use /dev/mapper/<VG>-<LV> instead. Fortunately,
    1418     # the former is then a link to the latter, so we test whether
    1419     # $current_partition is actually such a link or not and set
    1420     # $current_lvolume accordingly. Note that $current_lvolume may well be an
    1421     # ordinary device. It is just to make sure that we feed the right value
    1422     # into any of the LVM tools if possible.
    1423     if [ -d "/dev/mapper" ] && [ -z "`lvm lvdisplay $current_partition 2> /dev/null`" ]; then
    1424         partition_stub="`echo "$current_partition" | sed "s|^/dev/mapper/|/dev/|" | cut -d"-" -f1`"
    1425         current_lvolume="`find /dev -lname "$current_partition" | grep "^$partition_stub"`"
    1426     fi
    1427     if [ -z "$current_lvolume" ]; then
     1414        partition_format=`$AWK '$1 == "'"$str_to_find_fmt_with"'" {print $3}' $MY_FSTAB`
     1415        # Some distributions such as Debian do not put /dev/<VG>/<LV> in fstab
     1416        # for LVM partitions but use /dev/mapper/<VG>-<LV> instead. Fortunately,
     1417        # the former is then a link to the latter, so we test whether
     1418        # $current_partition is actually such a link or not and set
     1419        # $current_lvolume accordingly. Note that $current_lvolume may well be an
     1420        # ordinary device. It is just to make sure that we feed the right value
     1421        # into any of the LVM tools if possible.
     1422
    14281423        current_lvolume="$current_partition"
    1429     fi
    1430     # End of LVM device style variation code (other than $current_lvolume).
    1431     if [ -d "/proc/lvm" ] && [ "`lvdisplay $current_lvolume 2> /dev/null`" ]; then
    1432         partition_size="lvm"
    1433     elif [ -d "/dev/mapper" ] && [ "`lvm lvdisplay $current_lvolume 2> /dev/null`" ]; then
    1434         partition_size="lvm"
    1435     else
    1436         partition_size=`SizeOfPartition $current_partition`
    1437         [ "`echo "$current_partition" | grep "[0-9]"`" = "" ] && continue
    1438         [ "`echo "$current_partition" | grep -c "^/"`" -ne "1" ] && continue
    1439         if [ "$partition_format" = "swap" ] || [ "$partition_mountpt" = "swap" ] ; then
    1440         partition_size=`grep -Fv "Priority" /proc/swaps | tr -s '\t' ' ' | grep -F "$current_partition" | $AWK '{print $3}'`
    1441         [ "$partition_mountpt" != "swap" ] && partition_mountpt="swap"
     1424        if [ $LVM = "v2" ] && [ -z "`$LVMCMD lvdisplay $current_partition 2> /dev/null`" ]; then
     1425            partition_stub="`echo "$current_partition" | sed "s|^/dev/mapper/|/dev/|" | cut -d"-" -f1`"
     1426            current_lvolume="`find /dev -lname "$current_partition" | grep "^$partition_stub"`"
     1427        fi
     1428        # End of LVM device style variation code (other than $current_lvolume).
     1429
     1430        if [ $LVM != "false" ] && [ "`$LVMCMD lvdisplay $current_lvolume 2> /dev/null`" ]; then
     1431            partition_size="lvm"
     1432        else
     1433            partition_size=`SizeOfPartition $current_partition`
     1434            [ "`echo "$current_partition" | grep "[0-9]"`" = "" ] && continue
     1435            [ "`echo "$current_partition" | grep -c "^/"`" -ne "1" ] && continue
     1436            if [ "$partition_format" = "swap" ] || [ "$partition_mountpt" = "swap" ] ; then
     1437                partition_size=`grep -Fv "Priority" /proc/swaps | tr -s '\t' ' ' | grep -F "$current_partition" | $AWK '{print $3}'`
     1438                [ "$partition_mountpt" != "swap" ] && partition_mountpt="swap"
    14421439                [ "$partition_format" != "swap" ] && partition_format="swap"
    1443         if [ "$partition_size" = "" ] ; then
    1444             totalsize=0
    1445             items=0
    1446             for i in `tr -s ' ' '\t' < /proc/swaps | grep -Fv "Filename" | cut -f3` ; do
    1447                 totalsize=$(($totalsize+$i))
    1448                 items=$(($items+1))
    1449             done
    1450             [ "$items" -gt "0" ] && partition_size=$(($totalsize/$items)) || partition_size=0
    1451             [ "$partition_size" -lt "125000" ] && partition_size=125000
    1452             echo "I'm guessing $c_p is $(($partition_size/1024))MB" >> $LOGFILE
    1453         fi
    1454         fi
    1455     fi
    1456     [ "$partition_mountpt" = "swap" ] && partition_format="swap"
    1457     [ "$partition_format" = "swap" ] && partition_mountpt="swap"
    1458     if [ "$partition_mountpt" = "" ] ; then
    1459         if [ "`pvdisplay $current_lvolume 2> /dev/null`" != "" ] || [ "`lvm pvdisplay $current_lvolume 2> /dev/null`" != "" ] ; then
    1460             if  [ "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
    1461                 partition_mountpt="raid"
    1462                 partition_format="raid"
     1440                if [ "$partition_size" = "" ] ; then
     1441                    totalsize=0
     1442                    items=0
     1443                    for i in `tr -s ' ' '\t' < /proc/swaps | grep -Fv "Filename" | cut -f3` ; do
     1444                        totalsize=$(($totalsize+$i))
     1445                        items=$(($items+1))
     1446                    done
     1447                    [ "$items" -gt "0" ] && partition_size=$(($totalsize/$items)) || partition_size=0
     1448                    [ "$partition_size" -lt "125000" ] && partition_size=125000
     1449                    echo "I'm guessing $c_p is $(($partition_size/1024))MB" >> $LOGFILE
     1450                fi
     1451            fi
     1452        fi
     1453        [ "$partition_mountpt" = "swap" ] && partition_format="swap"
     1454        [ "$partition_format" = "swap" ] && partition_mountpt="swap"
     1455        if [ "$partition_mountpt" = "" ] ; then
     1456            if [ "`$LVMCMD pvdisplay $current_lvolume 2> /dev/null`" != "" ] ; then
     1457                if  [ "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
     1458                    partition_mountpt="raid"
     1459                    partition_format="raid"
     1460                else
     1461                    partition_mountpt="lvm"
     1462                    partition_format="lvm"
     1463                fi
     1464            fi
     1465        fi
     1466        psz=$partition_size
     1467        echo "Examining $current_partition (mount=$partition_mountpt fmt=$partition_format psz=$psz)" >> $LOGFILE
     1468        [ "$psz" != "lvm" ] && psz=$(($psz/1024))
     1469        if [ "`echo " $IMAGE_DEVS " | grep -F " $current_partition "`" != "" ] ; then
     1470            partition_mountpt="image"
     1471            old_partition_fmt=$partition_format
     1472#           partition_format="`$FDISK -l 2>> $LOGFILE | tr -s '\t' ' ' | grep -w "$absolute_partition" | $AWK 'x=$(NF-1}'`"
     1473            partition_format="`$FDISK -l 2>> $LOGFILE | tr '*' ' ' | tr '+' ' ' | tr -s ' ' '\t' | grep -w "$absolute_partition" | cut -f5`"
     1474            echo "------- $FDISK -l log ------------" >> $LOGFILE
     1475            cat $FDISKLOG >> $LOGFILE
     1476            echo "------- $FDISK log end ------------" >> $LOGFILE
     1477            partition_size=$(($partition_size+1)); # just in case
     1478            if [ "$partition_format" = "Linux" ] ; then
     1479                echo "Are you imaging a mounted swap partition? Silly..." >> $LOGFILE
     1480                echo "Reverting format from $old_partition_fmt to $partition_format" >> $LOGFILE
     1481                partition_format=$old_partition_fmt
     1482            fi
     1483        fi
     1484        if [ "$EXCLUDE_DEVS" ] && [ "`echo " $EXCLUDE_DEVS " | grep -F " $current_partition "`" ] || [ "`echo " $EXCLUDE_DEVS " | grep " $current_partition "`" ] ; then
     1485            echo "Excluding $current_partition from mountlist" >> $LOGFILE
     1486            continue
     1487        fi
     1488        if [ ! "$partition_mountpt" ] ; then
     1489            for qq in "" `find /dev/ida/c*d* ! -name '*p*'` ; do
     1490                partition_format=`$FDISK -l $qq 2>> $LOGFILE | grep -w "$c_p" | sed 's/12/|/' | tr -s '\t' ' ' | cut -d'|' -f2 | cut -d' ' -f2-9`
     1491                echo "------- $FDISK -l $qq log ------------" >> $LOGFILE
     1492                cat $FDISKLOG >> $LOGFILE
     1493                echo "------- $FDISK log end ------------" >> $LOGFILE
     1494                [ "$partition_format" ] && break
     1495            done
     1496            if [ "$partition_format" = "Compaq diagnostics" ] ; then
     1497                partition_format="compaq"
     1498            elif [ ! "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
     1499                LogIt "Unable to find mountpoint of $current_partition - ignoring\n"
     1500                continue
     1501            fi
     1502        fi
     1503        partition_format="`echo "$partition_format" | cut -d',' -f1`"; # in case user has ext3,ext2 or something dumb like that
     1504        [ "$partition_format" = "auto" ] && partition_format="`mount | grep -w $current_partition | awk '{print$5;}'`"; # in case user uses 'auto' (dumb!)
     1505        unofficial_outstring=`printf "\t%-15s %-15s %-15s %7s\n" $current_partition $partition_mountpt $partition_format $psz`
     1506        if [ "$current_partition" = "" ] ; then
     1507            echo "Unknown partition (outstring = $unofficial_outstring)" >> $LOGFILE
     1508        elif [ "$partition_mountpt" = "" ] && [ -f "/etc/raidtab" ] ; then
     1509            if [ "`grep -F device /etc/raidtab 2>/dev/null | grep -F $current_partition`" ] ; then
     1510                partition_mountpt=raid
     1511                partition_format=raid
     1512                printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
     1513                printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
    14631514            else
    1464 #               lvm_dev="`pvdisplay $current_lvolume | grep -i "VG N" | head -n1 | tr -s ' ' ' ' | cut -d' ' -f3`"
    1465                 partition_mountpt="lvm"
    1466                 partition_format="lvm"
     1515                echo "Unknown mountpoint (outstring = $unofficial_outstring)" >> $LOGFILE
    14671516            fi
    1468         fi
    1469     fi
    1470     psz=$partition_size
    1471     echo "Examining $current_partition (mount=$partition_mountpt fmt=$partition_format psz=$psz)" >> $LOGFILE
    1472     [ "$psz" != "lvm" ] && psz=$(($psz/1024))
    1473     if [ "`echo " $IMAGE_DEVS " | grep -F " $current_partition "`" != "" ] ; then
    1474         partition_mountpt="image"
    1475         old_partition_fmt=$partition_format
    1476 #       partition_format="`$FDISK -l 2>> $LOGFILE | tr -s '\t' ' ' | grep -w "$absolute_partition" | $AWK 'x=$(NF-1}'`"
    1477         partition_format="`$FDISK -l 2>> $LOGFILE | tr '*' ' ' | tr '+' ' ' | tr -s ' ' '\t' | grep -w "$absolute_partition" | cut -f5`"
    1478         echo "------- $FDISK -l log ------------" >> $LOGFILE
    1479         cat $FDISKLOG >> $LOGFILE
    1480         echo "------- $FDISK log end ------------" >> $LOGFILE
    1481         partition_size=$(($partition_size+1)); # just in case
    1482         if [ "$partition_format" = "Linux" ] ; then
    1483             echo "Are you imaging a mounted swap partition? Silly..." >> $LOGFILE
    1484             echo "Reverting format from $old_partition_fmt to $partition_format" >> $LOGFILE
    1485             partition_format=$old_partition_fmt
    1486         fi
    1487     fi
    1488     if [ "$EXCLUDE_DEVS" ] && [ "`echo " $EXCLUDE_DEVS " | grep -F " $current_partition "`" ] || [ "`echo " $EXCLUDE_DEVS " | grep " $current_partition "`" ] ; then
    1489         echo "Excluding $current_partition from mountlist" >> $LOGFILE
    1490         continue
    1491     fi
    1492     if [ ! "$partition_mountpt" ] ; then
    1493         for qq in "" `find /dev/ida/c*d* ! -name '*p*'` ; do
    1494             partition_format=`$FDISK -l $qq 2>> $LOGFILE | grep -w "$c_p" | sed 's/12/|/' | tr -s '\t' ' ' | cut -d'|' -f2 | cut -d' ' -f2-9`
    1495             echo "------- $FDISK -l $qq log ------------" >> $LOGFILE
    1496             cat $FDISKLOG >> $LOGFILE
    1497             echo "------- $FDISK log end ------------" >> $LOGFILE
    1498             [ "$partition_format" ] && break
    1499         done
    1500         if [ "$partition_format" = "Compaq diagnostics" ] ; then
    1501             partition_format="compaq"
    1502         elif [ ! "`grep -F device /etc/raidtab 2> /dev/null | grep -w $current_partition`" ] ; then
    1503             LogIt "Unable to find mountpoint of $current_partition - ignoring\n"
     1517        elif [ "$partition_format" = "" ] ; then
     1518            echo "Unknown format (outstring = $unofficial_outstring)" >> $LOGFILE
     1519        elif [ "$partition_size" = "" ] ; then
     1520            echo "Unknown partition size (outstring = $unofficial_outstring)" >> $LOGFILE
     1521        elif [ "$partition_mountpt" = "/proc" ] || [ "$partition_mountpt" = "/dev/pts" ] ; then
    15041522            continue
    1505         fi
    1506     fi
    1507     partition_format="`echo "$partition_format" | cut -d',' -f1`"; # in case user has ext3,ext2 or something dumb like that
    1508     [ "$partition_format" = "auto" ] && partition_format="`mount | grep -w $current_partition | awk '{print$5;}'`"; # in case user uses 'auto' (dumb!)
    1509     unofficial_outstring=`printf "\t%-15s %-15s %-15s %7s\n" $current_partition $partition_mountpt $partition_format $psz`
    1510     if [ "$current_partition" = "" ] ; then
    1511         echo "Unknown partition (outstring = $unofficial_outstring)" >> $LOGFILE
    1512     elif [ "$partition_mountpt" = "" ] && [ -f "/etc/raidtab" ] ; then
    1513         if [ "`grep -F device /etc/raidtab 2>/dev/null | grep -F $current_partition`" ] ; then
    1514             partition_mountpt=raid
    1515             partition_format=raid
    1516             printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
     1523        else
     1524            if [ "$partition_format" = "dos" ] || [ "$partition_format" = "msdos" ] ; then
     1525                echo "Stupid bastard..." >> $LOGFILE
     1526                partition_format="vfat"
     1527            fi
     1528            printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
    15171529            printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
    1518         else
    1519             echo "Unknown mountpoint (outstring = $unofficial_outstring)" >> $LOGFILE
    1520         fi
    1521     elif [ "$partition_format" = "" ] ; then
    1522         echo "Unknown format (outstring = $unofficial_outstring)" >> $LOGFILE
    1523     elif [ "$partition_size" = "" ] ; then
    1524         echo "Unknown partition size (outstring = $unofficial_outstring)" >> $LOGFILE
    1525     elif [ "$partition_mountpt" = "/proc" ] || [ "$partition_mountpt" = "/dev/pts" ] ; then
    1526         continue
    1527     else
    1528         if [ "$partition_format" = "dos" ] || [ "$partition_format" = "msdos" ] ; then
    1529             echo "Stupid bastard..." >> $LOGFILE
    1530             partition_format="vfat"
    1531         fi
    1532         printf "\t%-15s %-15s %-15s %7s %-15s\n" $current_partition $partition_mountpt $partition_format $psz "$redhat_label"
    1533         printf "%s %s %s %s %s\n" $current_partition $partition_mountpt $partition_format $partition_size "$redhat_label" >> $mountlist
    1534     fi
     1530        fi
    15351531    done
    15361532}
     
    22962292    cp -f $TMP_ROOT/mountlist.txt $CACHE_LOC
    22972293    [ "`DidMondoCallMe`" ] && cp -f $minidir_root/$noof_disks/tmp/mountlist.txt $MONDO_TMP/.
    2298     [ -d "/proc/lvm" ] && $MINDI_LIB/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
    2299     [ -d "/dev/mapper" ] && $MINDI_LIB/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
     2294    [ $LVM != "false" ] && $MINDI_LIB/analyze-my-lvm > $minidir_root/$noof_disks/tmp/i-want-my-lvm
    23002295    cat $minidir_root/$noof_disks/tmp/mountlist.txt >> $LOGFILE
    23012296    ZipMinidirsIntoTarballs $minidir_root $tardir $noof_disks
     
    30523047mkdir -p $MONDO_ROOT
    30533048
     3049if [ -d "/proc/lvm" ]; then
     3050    # LVM v1
     3051    LVMCMD=""
     3052    LVM="v1"
     3053elif [ -d "/dev/mapper" ]; then
     3054    # LVM v2
     3055    LVMCMD="lvm"
     3056    LVM="v2"
     3057else
     3058    LVM="false"
     3059fi
     3060
    30543061if [ "$#" -ge "2" ] ; then
    30553062    if [ "$1" = "--max-compressed-size" ] ; then
  • branches/stable/mindi/rootfs/sbin/start-nfs

    r740 r741  
    1 #!/bin/sh
     1#!/bin/bash
    22#
     3# $Id$
     4#
     5# This script set up the network + NFS environement if needed.
     6#
     7
     8
    39# number of ping
    4 #
    510ipcount=3
    611
Note: See TracChangeset for help on using the changeset viewer.