Skip to content

Commit 950af70

Browse files
Add macOS-specific environment variable injection for dappmanager compose
1 parent e541023 commit 950af70

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

scripts/dappnode_install.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,37 @@ patch_compose_paths() {
240240
sed_inplace "s|/usr/src/dappnode|${DAPPNODE_DIR}|g" "$file"
241241
}
242242

243+
# Patch dappmanager compose for macOS: inject env vars the container needs
244+
# to know the host core-dir path and to skip host-only operations,
245+
# and fix the DNCORE volume mount to use the macOS host path.
246+
patch_dappmanager_compose_for_macos() {
247+
local file="$1"
248+
249+
# Replace the host side of the DNCORE volume mount with the actual DAPPNODE_CORE_DIR value
250+
# e.g. /usr/src/dappnode/DNCORE/:/usr/src/app/DNCORE/ -> $HOME/dappnode/DNCORE/:/usr/src/app/DNCORE/
251+
sed_inplace "s|[^[:space:]]*:/usr/src/app/DNCORE/|${DAPPNODE_CORE_DIR}/:/usr/src/app/DNCORE/|" "$file"
252+
253+
local envs_to_add=()
254+
255+
# DAPPNODE_CORE_DIR: lets the container know the host's DNCORE path
256+
if ! grep -q "DAPPNODE_CORE_DIR" "$file"; then
257+
envs_to_add+=(" - DAPPNODE_CORE_DIR=${DAPPNODE_CORE_DIR}")
258+
fi
259+
260+
# DISABLE_HOST_SCRIPTS: tells the container to skip host-only scripts
261+
if ! grep -q "DISABLE_HOST_SCRIPTS" "$file"; then
262+
envs_to_add+=(" - DISABLE_HOST_SCRIPTS=${DISABLE_HOST_SCRIPTS:-true}")
263+
fi
264+
265+
[[ ${#envs_to_add[@]} -gt 0 ]] || return 0
266+
267+
local tmp="${file}.tmp"
268+
local insert_text
269+
insert_text=$(printf '%s\n' "${envs_to_add[@]}")
270+
271+
awk -v ins="$insert_text" '/DISABLE_UPNP/ { print; print ins; next } { print }' "$file" > "$tmp" && mv "$tmp" "$file"
272+
}
273+
243274
# TODO: remove once profile macos-compatibility published
244275
# Patch .dappnode_profile for macOS compatibility
245276
patch_profile_for_macos() {
@@ -486,6 +517,10 @@ dappnode_core_download() {
486517
if $IS_MACOS; then
487518
remove_logging_section "${!yml_file_var}"
488519
patch_compose_paths "${!yml_file_var}"
520+
# Inject macOS-specific env vars into the dappmanager compose
521+
if [[ "$comp" == "DAPPMANAGER" ]]; then
522+
patch_dappmanager_compose_for_macos "${!yml_file_var}"
523+
fi
489524
fi
490525
fi
491526
done

0 commit comments

Comments
 (0)