-
Notifications
You must be signed in to change notification settings - Fork 307
Expand file tree
/
Copy pathdocker_entrypoint.sh
More file actions
62 lines (55 loc) · 1.75 KB
/
docker_entrypoint.sh
File metadata and controls
62 lines (55 loc) · 1.75 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
#!/bin/sh
set -e
# Store original arguments to pass to the final exec call
original_args="$@"
# Set default values
base_path='/data'
chain_spec=''
# Parse arguments to find the real --base-path and --chain, handles both
# --key value and --key=value formats.
while [ $# -gt 0 ]; do
case "$1" in
--base-path)
# Check if the next argument exists and is not another option
if [ -n "$2" ] && ! expr "$2" : '--' > /dev/null; then
base_path="$2"
shift
fi
;;
--base-path=*)
base_path="${1#*=}"
;;
--chain)
# Check if the next argument exists and is not another option
if [ -n "$2" ] && ! expr "$2" : '--' > /dev/null; then
chain_spec="$2"
shift
fi
;;
--chain=*)
chain_spec="${1#*=}"
;;
esac
shift
done
echo "entrypoint: ensuring permissions for base path: ${base_path}"
mkdir -p "$base_path"
chown -R subtensor:subtensor "$base_path"
# Check if a chain spec was provided and if it's an existing file
if [ -n "$chain_spec" ] && [ -f "$chain_spec" ]; then
echo "entrypoint: ensuring permissions for chain spec: ${chain_spec}"
chown subtensor:subtensor "$chain_spec"
fi
# Also check for the hardcoded /tmp/blockchain directory
if [ -d "/tmp/blockchain" ]; then
chown -R subtensor:subtensor /tmp/blockchain
fi
# Execute node-subtensor with the original, unmodified arguments
# Skip gosu if we're already running as the subtensor user or if SKIP_GOSU is set
if [ "$(id -un)" = "subtensor" ] || [ "${SKIP_GOSU}" = "true" ]; then
echo "executing: node-subtensor $original_args (without gosu)"
exec node-subtensor $original_args
else
echo "executing: gosu subtensor node-subtensor $original_args"
exec gosu subtensor node-subtensor $original_args
fi