Annotation of coherent/f/etc/conf/bin/src/idtune, revision 1.1

1.1     ! root        1: # Shell version of something similar to the System V 'idtune' command
        !             2: 
        !             3: ##################### FUNCTION DEFINITIONS #######################
        !             4: 
        !             5: # Call with the $0 of the script as a parameter; this commands writes the
        !             6: # name of the directory containing the script to standard output.
        !             7: # Example:
        !             8: #      conf_path $0
        !             9: 
        !            10: conf_path () {
        !            11:        set `which $1 2>/dev/null` X
        !            12:        if [ $# -ne 2 ]; then
        !            13:                echo .          # Assume the current directory.
        !            14:                return 1
        !            15:        fi
        !            16:        set `expr $1 : '\(.*\)/.*'` X
        !            17:        if [ $# -ne 2 ]; then
        !            18:                echo .          # Must be in the current directory.
        !            19:        else
        !            20:                echo $1
        !            21:        fi
        !            22:        return 0
        !            23: }
        !            24: 
        !            25: # Report a usage message to standard output, with the name of the script
        !            26: # passed as the argument to this function.
        !            27: 
        !            28: usage () {
        !            29:        echo $1 ": Change values of configurable parameters"
        !            30:        echo "usage :\t[-f] [-m] param value [param value] ..."
        !            31:        echo "\t-f suppresses interactive confirmation of the change"
        !            32:        echo "\t-m specifies that the current value be raised to the given minimum"
        !            33: }
        !            34: 
        !            35: # Read the mtune/stune parameters for a variable into shell globals
        !            36: 
        !            37: read_mstune () {
        !            38:        ggrep ^"$1$WHITESPACE" $CONF_DIR/[ms]tune 2>/dev/null 1>&2
        !            39:        if [ $? -ne 0 ]; then
        !            40:                echo There is no installed tunable parameter called $1 1>&2
        !            41:                return 1
        !            42:        fi
        !            43:        set `grep "^$1$WHITESPACE" $CONF_DIR/mtune 2>/dev/null` \
        !            44:            `grep "^$1$WHITESPACE" $CONF_DIR/stune 2>/dev/null`
        !            45:        MTUNE_MIN=$2
        !            46:        MTUNE_DEFAULT=$3
        !            47:        MTUNE_MAX=$4
        !            48:        if [ $# -gt 4 ]; then
        !            49:                STUNE_VALUE=$6
        !            50:        else
        !            51:                STUNE_VALUE=$3
        !            52:        fi
        !            53:        OLD_STUNE_VALUE=$STUNE_VALUE
        !            54: }
        !            55: 
        !            56: # Update the value of a tunable parameter
        !            57: 
        !            58: write_mstune () {
        !            59:        if [ $OLD_STUNE_VALUE -eq $2 ]; then
        !            60:                return 0
        !            61:        fi
        !            62:        if [ $2 -lt $MTUNE_MIN -o $2 -gt $MTUNE_MAX ]; then
        !            63:                echo The new value is not within the legal range of values. \
        !            64:                        1>&2
        !            65:                return 1
        !            66:        fi
        !            67: 
        !            68:        $HOME_DIR/devadm -I $CONF_DIR -s"$1 $2" -W
        !            69: }
        !            70: 
        !            71: # Confirm the parameter change
        !            72: 
        !            73: ask () {
        !            74:        echo Tunable parameter $1 is currently set to $2.
        !            75:        echo -n Is it OK to change it to $3"? (y/n) "
        !            76:        read yesno
        !            77:        [ "$yesno" = "y" ]
        !            78:        return $?
        !            79: }
        !            80: 
        !            81: HOME_DIR=`conf_path $0`
        !            82: CONF_DIR=$HOME_DIR/..
        !            83: WHITESPACE="    "              : A space and a tab
        !            84: 
        !            85: if [ $# -lt 1 ]; then
        !            86:        usage $0 1>&2
        !            87:        exit 100
        !            88: fi
        !            89: 
        !            90: while [ $# -gt 1 ]; do
        !            91:        ARG=$1; shift
        !            92:        case $ARG in
        !            93:        -f)     FORCE=1
        !            94:                ;;
        !            95: 
        !            96:        -m)     MINIMUM=1
        !            97:                ;;
        !            98: 
        !            99:        *)      read_mstune $ARG || exit 1
        !           100: 
        !           101:                # If there is no change, do nothing. If there is a minimum and
        !           102:                # the current value is large enough, do nothing. Otherwise,
        !           103:                # make the change if forced or the user confirms.
        !           104: 
        !           105:                if [ $STUNE_VALUE -ne $1 -a \
        !           106:                        \( -z "$MINIMUM" -o $STUNE_VALUE -lt $1 \) ] &&
        !           107:                   ([ -n "$FORCE" ] || ask $ARG $STUNE_VALUE $1) then
        !           108:                        write_mstune $ARG $1
        !           109:                fi
        !           110:                shift
        !           111:                ;;
        !           112:        esac
        !           113: done
        !           114: 
        !           115: if [ $# -ne 0 ]; then
        !           116:        usage $0 1>&2
        !           117:        exit 100
        !           118: fi

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.