-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-updates.sh
executable file
·59 lines (58 loc) · 1.31 KB
/
check-updates.sh
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
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
dir=$PWD
folder_exists () {
FND=$(ls -l | grep ^d | grep -wc $1)
echo $FND
}
is_behind () {
Pull=$(git status -u $1 | grep "is behind" -c)
echo $Pull
}
not_on_branch () {
CBRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CBRANCH" != "$1" ]; then
echo 1
else
echo 0
fi
}
for filename in ./*.cfg; do
foo=""
module="${filename/autodeploy-/$foo}"
module="${module/.\//$foo}"
module="${module/.cfg/$foo}"
echo $module
cd $dir
source $filename
FX=$(folder_exists $FOLDER)
toPull=0
if [ $FX != 1 ]; then
#echo "folder does not exist!"
toPull=1
else
cd $FOLDER
fi
if [[ $toPull -eq 1 ]]; then
#proceed to next condition
echo ""
else
toPull=$(not_on_branch $BRANCH)
fi
if [[ $toPull -eq 1 ]]; then
#proceed to next condition
echo ""
else
git remote update > /dev/null
toPull=$(is_behind $BRANCH)
# echo $toPull
fi
if [[ $toPull -eq 1 ]]; then
echo "`date` - Updating $module ">> deployments.txt
echo "`date` - Update required for $module"
pwd
cd $dir
# continue
echo "Updating $module ..."
./deploy.sh -u $module -s -i #> /dev/null
echo "`date` -finished updating $module">> deployments.txt
fi done