#!/bin/sh
#
# Folding@Home
#
# Parameters:
#
#   config   (required)
#   autoconf (optional - only used by munin-config)
#
# $Log$
# Revision 1.1  2004/12/09 16:49:30  jimmyo
# Renamed generic/folding@home to generic/foldingathome (SF#1074241).
#
# Revision 1.2  2004/05/09 19:47:24  jimmyo
# Added Folding@home plugin, contributed by Xavier.
#
#
# Magic markers (optional - used by munin-config and some installation
# scripts):
#%# family=contrib
#%# capabilities=autoconf

PATH=/usr/local/fah
FILE=${file:=unitinfo.txt}

if [ "$1" = "autoconf" ]; then
    if ( cat $PATH/$FILE 2>/dev/null >/dev/null ); then
        echo yes
        exit 0
    else
        if [ $? -eq 127 ]
        then
            echo "no (F@H not found)"
            exit 1
        else
            echo no
            exit 1
        fi
    fi
fi

if [ "$1" = "config" ]; then

    echo 'graph_title Folding@Home'
    echo 'graph_args -l 0 --base 1000'
    echo 'graph_vlabel % finished'
    echo 'done.label done folding'
    echo 'done.type GAUGE'
    echo 'done.max 100'''
    exit 0
fi

echo `/bin/grep "Progress" $PATH/$FILE | /bin/sed 's/^.*: \(.*\)%.*/done.value \1/'`
