generated from spknetwork/js-typescript-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
update.sh
executable file
·65 lines (45 loc) · 1.22 KB
/
update.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
60
61
62
63
64
#!/bin/bash
set -e
echo "********** This method of updating the node is deprecated. **********"
echo "********** Please use the vsc-deployment repository to launch the VSC-node. **********"
echo "********** For an easy migration please use the 'migrate.sh' script. **********"
updateCode=$(git pull);
gitCommit=$(git rev-parse HEAD)
# if [[ "$updateCode" == "Already up to date." ]]
# then
# echo $updateCode
# exit
# fi
{ # try
deployedGitCommit=`cat data/git-flag`
#save your output
} || { # catch
deployedGitCommit="0"
}
echo "$gitCommit $deployedGitCommit"
indexVersion=`cat deploy/index-flag`
{ # try
indexVersionDeployed=`cat data/index-flag`
#save your output
} || { # catch
indexVersionDeployed="0"
}
echo "$indexVersion $indexVersionDeployed"
if [ "$gitCommit" != "$deployedGitCommit" ];
then
docker-compose down
sleep 15; # Ensure safe shutdown
docker-compose build
if [ "$indexVersion" -ne "$indexVersionDeployed" ];
then
echo "Need to reset database"
{ # try
rm -r data/*
} || { # catch
indexVersionDeployed="0"
}
echo $indexVersion > data/index-flag
fi
docker-compose up -d
echo $gitCommit > data/git-flag
fi