forked from KMDLabs/LabsNotary
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_komodo.sh
executable file
·76 lines (69 loc) · 1.76 KB
/
update_komodo.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
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#temporary
type dc>/dev/null 2>&1 || sudo apt-get install dc
cd $HOME/StakedNotary
checkRepo () {
if [ -z $1 ]; then
return
fi
prevdir=${PWD}
if [[ ! -f komodo/$1/lastbuildcommit ]]; then
eval cd "$HOME/komodo"
git pull > /dev/null 2>&1
git checkout $1 > /dev/null 2>&1
localrev=$(git rev-parse HEAD)
mkdir -p $HOME/StakedNotary/komodo/$1
echo $localrev > $HOME/StakedNotary/komodo/$1/lastbuildcommit
cd $prevdir
fi
localrev=$(cat komodo/$1/lastbuildcommit)
eval cd "$HOME/komodo"
git remote update > /dev/null 2>&1
remoterev=$(git rev-parse origin/$1)
cd $prevdir
if [ $localrev != $remoterev ]; then
return 1
else
return 0
fi
}
buildkomodo () {
if [ -z $1 ]; then
return
fi
cd $HOME/komodo
git pull > /dev/null 2>&1
git checkout $1 > /dev/null 2>&1
git pull > /dev/null 2>&1
rm -f $HOME/komodo/src/komodod $HOME/komodo/src/komodo-cli > /dev/null 2>&1
#make clean > /dev/null 2>&1
#make -j$(nproc) > /dev/null 2>&1
./zcutil/build.sh -j$(nproc) > /dev/null 2>&1
if [[ ! -f $HOME/komodo/src/komodod ]]; then
return 0
fi
if [[ ! -f $HOME/komodo/src/komodo-cli ]]; then
return 0
fi
localrev=$(git rev-parse HEAD)
mkdir -p $HOME/StakedNotary/komodo/$1
echo $localrev > $HOME/StakedNotary/komodo/$1/lastbuildcommit
mv src/komodod $HOME/StakedNotary/komodo/$1
mv src/komodo-cli $HOME/StakedNotary/komodo/$1
return 1
}
if [ -z $1 ]; then
exit
fi
branch=$1
checkRepo $branch
outcome=$(echo $?)
if [[ $outcome = 1 ]] || [[ ! -f komodo/$1/komodod ]] || [[ ! -f komodo/$1/komodo-cli ]]; then
buildkomodo $branch
outcome=$(echo $?)
if [[ $outcome = 1 ]]; then
echo "updated"
else
echo "update_failed"
fi
fi