forked from Chia-Network/chia-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-entrypoint.sh
executable file
·104 lines (83 loc) · 2.83 KB
/
docker-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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/usr/bin/env bash
# shellcheck disable=SC2154
if [[ -n "${TZ}" ]]; then
echo "Setting timezone to ${TZ}"
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime && echo "$TZ" > /etc/timezone
fi
cd /chia-blockchain || exit 1
# shellcheck disable=SC1091
. ./activate
chia init --fix-ssl-permissions
if [[ ${testnet} == 'true' ]]; then
echo "configure testnet"
chia configure --testnet true
fi
if [[ ${keys} == "persistent" ]]; then
echo "Not touching key directories"
elif [[ ${keys} == "generate" ]]; then
echo "to use your own keys pass the mnemonic as a text file -v /path/to/keyfile:/path/in/container and -e keys=\"/path/in/container\""
chia keys generate -l ""
elif [[ ${keys} == "copy" ]]; then
if [[ -z ${ca} ]]; then
echo "A path to a copy of the farmer peer's ssl/ca required."
exit
else
chia init -c "${ca}"
fi
else
chia keys add -f "${keys}" -l ""
fi
for p in ${plots_dir//:/ }; do
mkdir -p "${p}"
if [[ ! $(ls -A "$p") ]]; then
echo "Plots directory '${p}' appears to be empty, try mounting a plot directory with the docker -v command"
fi
chia plots add -d "${p}"
done
if [[ ${recursive_plot_scan} == 'true' ]]; then
sed -i 's/recursive_plot_scan: false/recursive_plot_scan: true/g' "$CHIA_ROOT/config/config.yaml"
else
sed -i 's/recursive_plot_scan: true/recursive_plot_scan: false/g' "$CHIA_ROOT/config/config.yaml"
fi
chia configure --upnp "${upnp}"
if [[ -n "${log_level}" ]]; then
chia configure --log-level "${log_level}"
fi
if [[ -n "${peer_count}" ]]; then
chia configure --set-peer-count "${peer_count}"
fi
if [[ -n "${outbound_peer_count}" ]]; then
chia configure --set_outbound-peer-count "${outbound_peer_count}"
fi
if [[ -n ${farmer_address} && -n ${farmer_port} ]]; then
chia configure --set-farmer-peer "${farmer_address}:${farmer_port}"
fi
if [[ -n ${crawler_db_path} ]]; then
chia configure --crawler-db-path "${crawler_db_path}"
fi
if [[ -n ${crawler_minimum_version_count} ]]; then
chia configure --crawler-minimum-version-count "${crawler_minimum_version_count}"
fi
if [[ -n ${self_hostname} ]]; then
sed -i "s/self_hostname: localhost/self_hostname: $self_hostname/g" "$CHIA_ROOT/config/config.yaml"
fi
# TODO: Document why this is needed
sed -i 's/localhost/127.0.0.1/g' "$CHIA_ROOT/config/config.yaml"
if [[ ${log_to_file} != 'true' ]]; then
sed -i 's/log_stdout: false/log_stdout: true/g' "$CHIA_ROOT/config/config.yaml"
else
sed -i 's/log_stdout: true/log_stdout: false/g' "$CHIA_ROOT/config/config.yaml"
fi
# Map deprecated legacy startup options.
if [[ ${farmer} == "true" ]]; then
service="farmer-only"
elif [[ ${harvester} == "true" ]]; then
service="harvester"
fi
if [[ ${service} == "harvester" ]]; then
if [[ -z ${farmer_address} || -z ${farmer_port} || -z ${ca} ]]; then
echo "A farmer peer address, port, and ca path are required."
exit
fi
fi
exec "$@"