You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: scripts/dappnode_install.sh
+87-82Lines changed: 87 additions & 82 deletions
Original file line number
Diff line number
Diff line change
@@ -4,35 +4,12 @@
4
4
# thanks to the shebang), but users sometimes invoke it as `zsh ./script.sh` or `source ./script.sh`.
5
5
# - If sourced, bail out (sourcing would pollute the current shell and can break it).
6
6
# - If invoked by a non-bash shell, re-exec with bash before hitting bash-specific builtins.
7
-
if (return 0 2>/dev/null);then
8
-
echo"This script must be executed, not sourced. Run: bash $0"
9
-
return 1
10
-
fi
11
-
12
-
if [ -z"${BASH_VERSION:-}" ];then
13
-
exec /usr/bin/env bash "$0""$@"
14
-
fi
15
-
16
-
set -Eeuo pipefail
17
-
18
-
# Optional env inputs (avoid unbound-variable errors under `set -u`)
19
-
:"${UPDATE:=false}"
20
-
:"${STATIC_IP:=}"
21
-
:"${LOCAL_PROFILE_PATH:=}"
22
-
:"${MINIMAL:=false}"
23
-
:"${LITE:=false}"
24
-
:"${PACKAGES:=}"
25
-
26
-
# Enable alias expansion in non-interactive bash scripts.
27
-
# Required so commands like `dappnode_wireguard` (defined as aliases in `.dappnode_profile`) work.
28
-
shopt -s expand_aliases
29
-
30
-
# Ensure array is always defined (avoid `set -u` edge cases)
31
-
DNCORE_COMPOSE_ARGS=()
32
7
33
8
##############################
34
9
# Logging / Errors #
35
10
##############################
11
+
# Note: LOGFILE and LOGS_DIR are set during bootstrap_filesystem based on DAPPNODE_DIR
12
+
# Early definition allows these functions to be used throughout the script.
36
13
37
14
log() {
38
15
# LOGFILE is created after dir bootstrap; until then we just print to stdout.
@@ -71,6 +48,35 @@ die() {
71
48
exit 1
72
49
}
73
50
51
+
##############################
52
+
# Script Guards #
53
+
##############################
54
+
55
+
if (return 0 2>/dev/null);then
56
+
die "This script must be executed, not sourced. Run: bash $0"
57
+
fi
58
+
59
+
if [ -z"${BASH_VERSION:-}" ];then
60
+
exec /usr/bin/env bash "$0""$@"
61
+
fi
62
+
63
+
set -Eeuo pipefail
64
+
65
+
# Optional env inputs (avoid unbound-variable errors under `set -u`)
66
+
:"${UPDATE:=false}"
67
+
:"${STATIC_IP:=}"
68
+
:"${LOCAL_PROFILE_PATH:=}"
69
+
:"${MINIMAL:=false}"
70
+
:"${LITE:=false}"
71
+
:"${PACKAGES:=}"
72
+
73
+
# Enable alias expansion in non-interactive bash scripts.
74
+
# Required so commands like `dappnode_wireguard` (defined as aliases in `.dappnode_profile`) work.
75
+
shopt -s expand_aliases
76
+
77
+
# Ensure array is always defined (avoid `set -u` edge cases)
78
+
DNCORE_COMPOSE_ARGS=()
79
+
74
80
usage() {
75
81
cat <<'EOF'
76
82
Usage: dappnode_install.sh [options]
@@ -200,7 +206,7 @@ wait_for_internal_ip() {
200
206
local internal_ip_url="http://127.0.0.1/global-envs/INTERNAL_IP"
201
207
local hostname_url="http://127.0.0.1/global-envs/HOSTNAME"
202
208
203
-
echo"Waiting for dappmanager to publish INTERNAL_IP and HOSTNAME..."
209
+
log"Waiting for dappmanager to publish INTERNAL_IP and HOSTNAME..."
204
210
sleep "$initial_sleep_seconds"
205
211
206
212
local start_seconds internal_http_code internal_value internal_result
@@ -235,12 +241,12 @@ wait_for_internal_ip() {
235
241
236
242
if [[ "$internal_http_code"=="200"&&-n"$internal_value"&&"$internal_value"!="null"&&"$hostname_http_code"=="200"&&-n"$hostname_value"&&"$hostname_value"!="null" ]];then
237
243
sleep "$final_sleep_seconds"# Extra buffer to ensure values are fully propagated before we proceed
238
-
echo"INTERNAL_IP is ready: $internal_value"
239
-
echo"HOSTNAME is ready: $hostname_value"
244
+
log"INTERNAL_IP is ready: $internal_value"
245
+
log"HOSTNAME is ready: $hostname_value"
240
246
return 0
241
247
fi
242
248
243
-
echo"INTERNAL_IP/HOSTNAME not ready yet (INTERNAL_IP code=${internal_http_code:-?}, HOSTNAME code=${hostname_http_code:-?}). Retrying..."
249
+
log"INTERNAL_IP/HOSTNAME not ready yet (INTERNAL_IP code=${internal_http_code:-?}, HOSTNAME code=${hostname_http_code:-?}). Retrying..."
0 commit comments