This repository was archived by the owner on Apr 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathkickstart_jenkins
More file actions
executable file
·82 lines (69 loc) · 3.16 KB
/
kickstart_jenkins
File metadata and controls
executable file
·82 lines (69 loc) · 3.16 KB
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
77
78
79
80
81
82
#!/bin/bash
# Iguana Coin Synchronization Tool
# Usage: ./kickstart COIN
# Unattended version
RTNUMBER=""
HEIGHT=""
SUPPORTED=(BTC BTCD DOGE LTC DGB GMC SYS MZC UNO ZET BTM CARB ANC FRK)
RESULTS=kickstart.log
COINLC=$(echo "$1" | tr '[:upper:]' '[:lower:]')
CURPROC=$(echo "../agents/iguana coins/gen$COINLC.json")
CURPID=$(pidof $CURPROC)
COMMIT=$(git rev-parse HEAD)
wget https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64 -O jq; chmod +x jq
if [[ " ${SUPPORTED[@]} " =~ " $1 " ]]; then
ps ax | grep -q "[i]guana coins/gen$COINLC.json" && { echo "Synchronization for $1 was already running! Stopping current process and restarting"; kill -9 $CURPID; sleep 1; }
echo Starting $1 Synchronization.
else
echo ">>> Argument error. Please run ./kickstart COIN"
echo "Currently supported coins: BTC, BTCD, DOGE, LTC, DGB, GMC, SYS, MZC, UNO, ZET, BTM, CARB, ANC, FRK"
exit 1
fi
echo WARNING: This will remove any existing DB and tmp sub-folders for $1 under the current working directory.
if [[ "${COINLC}" == "btc" ]]; then
cat coins/genbtc.json | ./jq '.minconfirms=3' > coins/genbtc.kick.json
MINCONFIRMS=3
else
cat coins/gen$COINLC.json | ./jq '.minconfirms=10' > coins/gen$COINLC.kick.json
MINCONFIRMS=10
fi
echo
echo "Running commit $COMMIT"
echo "Running parameters:"
cat coins/gen$COINLC.kick.json
echo
echo
rm -rf tmp/$1 DB/$1 DB/purgeable/$1 >/dev/null
rm $1.sync.log >/dev/null
../agents/iguana coins/gen$COINLC.kick.json > $1.sync.log 2>&1 &
SECONDS=0
STARTTIME=$(date +%T)
echo " >>> $1 Monitored Synchronization started at $STARTTIME." >> debug.log
echo " >>> Synchronization started at $STARTTIME."
echo " >>> You can follow this synchronization log at $1.sync.log. $1 status lines will also appear in debug.log"
echo " >>> Monitoring the log. Leave this process open to get a report in $RESULTS when $1 is fully synchronized."
echo "$1 synchronization started at $STARTTIME" | tee -a $RESULTS
while sleep .5; do
ENDTIME=$(date +%T)
ps ax | grep "[a]gents/iguana coins/gen$COINLC.kick.json" >/dev/null || { echo -e "\n$1 Synchronization process exited before finishing. Check $1.sync.log for details.\n"; echo "$1 synchronization finished prematurely at $ENDTIME" >> $RESULTS; echo "--------------------------------------------------------" >> $RESULTS; exit 1; }
LASTLINE=$(tac debug.log |egrep -m 1 .)
if [[ "${LASTLINE}" != "${1}.RT"* ]]; then
LASTLINE="$1.RT0 u.0+c.0 b.0 v.0 (0+0/1 1st.0).s0 to 1 N[1] h.0 r.0 c.0"
fi
RTNUMBERPR=${LASTLINE% u.*}
RTNUMBER=${RTNUMBERPR##*RT}
HEIGHTPR=${LASTLINE% r.*}
HEIGHT=${HEIGHTPR##*] h.}
if [[ "$((RTNUMBER + MINCONFIRMS - 1))" == "$((HEIGHT))" ]]; then
echo " $1 synchronization finished at $ENDTIME" | tee -a $RESULTS
echo "Total time: $((SECONDS / 3600)) hours, $((($SECONDS % 3600) / 60)) minutes and $((SECONDS % 60)) seconds" | tee -a $RESULTS
echo "Last status line: $LASTLINE" | tee -a $RESULTS
COMMIT=$(git rev-parse HEAD)
echo "Running commit: $COMMIT" | tee -a $RESULTS
echo "--------------------------------------------------------" | tee -a $RESULTS
exit 0
fi
done
kill -9 $CURPID
rm -rf tmp/$1 DB/$1 DB/purgeable/$1 >/dev/null
exit $?