-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathnode.sh
More file actions
executable file
·44 lines (35 loc) · 1.16 KB
/
node.sh
File metadata and controls
executable file
·44 lines (35 loc) · 1.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
#!/bin/bash
set -euo pipefail
if [ $# -lt 2 ]; then
echo "Usage: ./node.sh <MINING_ADDRESS> <COMPOSE_FILE>" >&2
exit 1
fi
mining_address=$1
compose_file=$2
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ "$compose_file" = /* ]]; then
compose_path="$compose_file"
else
compose_path="$SCRIPT_DIR/$compose_file"
fi
if [ ! -f "$compose_path" ]; then
echo "Compose file not found: $compose_path" >&2
exit 1
fi
export MINING_ADDRESS="$mining_address"
# Force amd64 image on ARM hosts since the blockdag image is not multi-arch.
arch=$(uname -m)
if [ -z "${DOCKER_DEFAULT_PLATFORM:-}" ] && [[ "$arch" =~ ^(arm64|aarch64)$ ]]; then
export DOCKER_DEFAULT_PLATFORM=linux/amd64
echo "Detected $arch host; using DOCKER_DEFAULT_PLATFORM=$DOCKER_DEFAULT_PLATFORM"
fi
if docker compose version >/dev/null 2>&1; then
echo "Using docker compose with file $compose_path"
docker compose -f "$compose_path" up -d
elif docker-compose version >/dev/null 2>&1; then
echo "Using docker-compose with file $compose_path"
docker-compose -f "$compose_path" up -d
else
echo "Neither 'docker compose' nor 'docker-compose' command is available." >&2
exit 1
fi