-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathblockdag.sh
More file actions
executable file
·63 lines (51 loc) · 1.25 KB
/
blockdag.sh
File metadata and controls
executable file
·63 lines (51 loc) · 1.25 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
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
usage() {
cat <<'USAGE'
Usage: ./blockdag.sh [ROLE]
ROLE may be one of:
miner - use docker-compose.yml (default)
full - use docker-compose.full.yml
relay - use docker-compose.relay.yml
You can also set NODE_ROLE environment variable instead of passing ROLE.
USAGE
}
ROLE_INPUT=${1:-${NODE_ROLE:-miner}}
case "$ROLE_INPUT" in
-h|--help)
usage
exit 0
;;
full)
COMPOSE_FILE="docker-compose.full.yml"
;;
relay)
COMPOSE_FILE="docker-compose.relay.yml"
;;
default|miner)
COMPOSE_FILE="docker-compose.yml"
;;
*)
echo "Unknown node role: $ROLE_INPUT" >&2
usage >&2
exit 1
;;
esac
ENV_FILE="$SCRIPT_DIR/.env"
# load PUB_ETH_ADDR from .env if present
if [ -f "$ENV_FILE" ]; then
# shellcheck disable=SC1090
source "$ENV_FILE"
fi
if [ -z "${PUB_ETH_ADDR:-}" ]; then
if [ -f "$SCRIPT_DIR/wallet.txt" ]; then
PUB_ETH_ADDR=$(tail -n 1 "$SCRIPT_DIR/wallet.txt")
else
echo "PUB_ETH_ADDR not set. Please create $ENV_FILE or wallet.txt" >&2
exit 1
fi
fi
export PUB_ETH_ADDR
# start the blockdag node with the selected compose file
"$SCRIPT_DIR"/node.sh "$PUB_ETH_ADDR" "$COMPOSE_FILE"