/
get_status
executable file
·48 lines (41 loc) · 1.25 KB
/
get_status
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
42
43
44
45
46
47
48
#!/bin/bash
if [[ -z ${ROOT} ]]; then
ROOT=$(pwd)
fi
function get_status()
{
dir=$1
if [[ -z ${dir} ]]; then
echo "WARNING: skilling empty \$dir"
return 0
fi
oldpwd=$(pwd)
cd ${dir}
branch=$(git branch | grep "^* " | cut -d ' ' -f2)
rev=$(git rev-parse HEAD)
if [[ -n ${branch} ]] && [[ -n ${rev} ]]; then
echo "\"branch\": \"${branch}\", \"rev\": \"${rev}\""
else
echo "\"branch\": \"unknown\""
fi
cd ${oldpwd}
}
function get_status_extra()
{
extra_tarball=$(basename `ls ${ROOT}/illumos-extra*.tgz |tail -n1`)
if [[ -n ${extra_tarball} ]]; then
branch=$(echo ${extra_tarball} | /usr/bin/cut -d '-' -f 3)
rev=$(echo ${extra_tarball} | cut -d '-' -f 5 | cut -d '.' -f 1 | sed -e 's/.//')
echo "\"branch\": \"${branch}\", \"rev\": \"${rev}\""
else
get_status ${ROOT}/projects/illumos-extra
fi
}
echo "["
echo " { \"repo\": \"illumos-live\", $(get_status ${ROOT}) }"
echo " , { \"repo\": \"illumos-extra\", $(get_status_extra) }"
echo " , { \"repo\": \"illumos-joyent\", $(get_status ${ROOT}/projects/illumos) }"
if [[ -d ${ROOT}/projects/local/ur-agent ]]; then
echo " , { \"repo\": \"ur-agent\", $(get_status ${ROOT}/projects/local/ur-agent) }"
fi
echo "]"