forked from casper-network/casper-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-chainspec.sh
More file actions
executable file
·39 lines (29 loc) · 862 Bytes
/
generate-chainspec.sh
File metadata and controls
executable file
·39 lines (29 loc) · 862 Bytes
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
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
generate_timestamp() {
local DELAY=${1}
local SCRIPT=(
"from datetime import datetime, timedelta, timezone;"
"print((datetime.now(timezone.utc).replace(tzinfo=None) + timedelta(seconds=${DELAY})).isoformat('T') + 'Z')"
)
python3 -c "${SCRIPT[*]}"
}
generate_chainspec() {
local BASEDIR=${1}
local TIMESTAMP=${2}
local SOURCE="${BASEDIR}/resources/local/chainspec.toml.in"
local TARGET="${BASEDIR}/resources/local/chainspec.toml"
export BASEDIR
export TIMESTAMP
echo "Generating chainspec..."
envsubst < ${SOURCE} > ${TARGET}
}
main() {
local DELAY=${1:-40}
local BASEDIR="$(readlink -f $(dirname ${0}))"
local TIMESTAMP="$(generate_timestamp ${DELAY})"
generate_chainspec ${BASEDIR} ${TIMESTAMP}
}
main $@