forked from naemon/naemon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_version
executable file
·41 lines (34 loc) · 1.28 KB
/
get_version
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
if [ ! -d .git ]; then
echo "not in an development environment, no .git directory found" >&2
exit 1
fi
# get tags of submodules
version_tg=`cd thruk/gui && git describe --tag --exact-match 2>/dev/null; cd ..`
version_tl=`cd thruk/libs && git describe --tag --exact-match 2>/dev/null; cd ..`
version_nc=`cd naemon-core && git describe --tag --exact-match 2>/dev/null; cd ..`
version_nl=`cd naemon-livestatus && git describe --tag --exact-match 2>/dev/null; cd ..`
if [ "$version_tg" != "" -a "$version_tl" != "" -a "$version_nc" != "" -a "$version_nl" != "" ]; then
# find an exact match, if found use it as version as we are currently
# exactly on one tag
version=`git describe --tag --exact-match 2>/dev/null`
if [ $? -eq 0 ]; then
echo $version | tr -d 'v'
exit 0
fi
fi
# if we are not on a exact tag, use the last tag and add the date
version=`git tag -l | sort -V | sed -e 's/^v//g' | tail -n 1`
if [ $? -eq 0 ]; then
date=`date +%Y%m%d`
major=` echo $version | cut -d . -f 1`
minor1=`echo $version | cut -d . -f 2`
minor2=`echo $version | cut -d . -f 3`
# do we have a even minor version?
minor2=$((minor2+1))
version="$major.$minor1.$minor2"
echo ${version}_${date} | tr -d 'v'
exit 0
fi
echo "unknown"
exit 1