check_oracle_health: update to 2.0
[omd.git] / get_version
blob9136e6e409d945ff6c7e704dc11db80eda33af13
1 #!/bin/bash
3 if [ ! -d .git ]; then
4 echo "not in an development environment, no .git directory found" >&2
5 exit 1
6 fi
8 # find an exact match, if found use it as version as we are currently
9 # exactly on one tag
10 # ex.: v0.42
11 version=`git describe --tag --exact-match 2>/dev/null`
12 if [ $? -eq 0 ]; then
13 echo $version | tr -d 'v'
14 exit 0
17 # if we are not on a exact tag, use the last tag and add the date
18 # ex.: v0.43.20101018
19 # "git describe --tag --abbrev=0 --always" does not work correctly with git versions < 1.7
20 # see issue #198
21 version=`git tag -l | sed -e 's/^v//g' | sort -n | tail -n 1`
22 if [ $? -eq 0 ]; then
23 date=`date +%Y%m%d`
24 major=`echo $version | cut -d . -f 1`
25 minor=`echo $version | cut -d . -f 2`
27 # do we have a even minor version?
28 let mod=$minor%2
29 if [ $mod -eq 0 ]; then
30 minor=$(printf '%02d' $((minor+1)))
32 version="$major.$minor"
34 echo $version.$date | tr -d 'v'
35 exit 1
38 echo "unknown"