-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
71 lines (59 loc) · 1.37 KB
/
entrypoint.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
#!/usr/bin/env bash
export CONFIG=${CONFIG:-/config.ini}
BIN=/usr/local/bin/core
# will make init if core thinks history does not exist.
# USE AT YOUR ON OWN RISK
ensuredb() {
# vs history is hard-coded as a de facto standard
$BIN --conf $CONFIG --histexists vs
exit_code=$?
[[ $exit_code -eq 0 ]] && return
[[ $exit_code -eq 42 ]] && init && return
echo "histexists failed with $exit_code"
return $exit_code
}
start() {
$BIN --conf $CONFIG --forcescp
$BIN --conf $CONFIG
}
init() {
$BIN --conf $CONFIG --newdb
$BIN --conf $CONFIG --newhist vs
}
catchup() {
$BIN --conf $CONFIG --catchup-complete
}
# Environment variable explanation:
# ENSUREDB - create new history for node, then start node (if no other env var provided)
# DOCATCHUP - do complete catchup, then start node
case "$1" in
"ensuredb")
ensuredb
;;
"init")
init
;;
"start")
start
;;
"catchup")
catchup
;;
*)
echo "ensuredb=$ENSUREDB"
echo "docatchup=$DOCATCHUP"
if [ -z "$ENSUREDB" ]; then
echo "ensuring history will not be done"
else
echo "ensuring history..."
ensuredb
fi
if [ -z "$DOCATCHUP" ]; then
echo "catchup will not be done"
else
echo "catchuping history..."
catchup
fi
echo "starting node"
start
esac