Allow check_ifstatus to accept version=2c
[monitoring-plugins.git] / NP-VERSION-GEN
blob273e0665c4218c6a19929ae0081963bbad7b0372
1 #!/bin/sh
3 # This is from the Git repository (GIT-VERSION-GEN with modifications)
6 SRC_ROOT=`dirname $0`
8 NPVF=NP-VERSION-FILE
9 DEF_VER=1.4.14.git
11 LF='
14 # First try git-describe, then svn info, then default.
15 if test -d $SRC_ROOT/.git -o -f $SRC_ROOT/.git &&
16 VN=`cd $SRC_ROOT; git describe --abbrev=4 HEAD 2>/dev/null` &&
17 case "$VN" in
18 *$LF*) (exit 1) ;;
19 release-[0-9]*)
20 git update-index -q --refresh
21 test -z "`git diff-index --name-only HEAD --`" ||
22 VN="$VN-dirty" ;;
23 esac
24 then
25 VN=`echo "$VN" | sed -e 's/^release-//' | sed -e 's/-/./g'`;
26 elif test -d $SRC_ROOT/.svn -o -f $SRC_ROOT/.svn &&
27 VN=`cd $SRC_ROOT; svn info 2>/dev/null | grep '^Revision'` &&
28 case "$VN" in
29 *$LF*) (exit 1) ;;
30 Revision:*)
31 VN=`echo $VN | awk '{print $NF}'`
32 test "`svn status 2>/dev/null | grep '^[AMD]' | wc -l | tr -d ' '`" = 0 ||
33 VN="$VN-dirty" ;;
34 esac
35 then
36 VN=`echo "trunk.$VN" | sed -e 's/-/./g'`;
37 else
38 VN="$DEF_VER"
41 VN=`expr "$VN" : v*'\(.*\)'`
43 if test -r $NPVF
44 then
45 VC=`sed -e 's/^NP_VERSION = //' <$NPVF`
46 else
47 VC=unset
49 test "$VN" = "$VC" || {
50 echo >&2 "NP_VERSION = $VN"
51 echo "NP_VERSION = $VN" >$NPVF