Skip to content

Commit 6947f70

Browse files
Refactor macOS patch function to handle environment variable insertion with temporary file for compatibility
1 parent 26851ee commit 6947f70

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

‎scripts/dappnode_install.sh‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,23 @@ patch_dappmanager_compose_for_macos() {
268268
[[ ${#envs_to_add[@]} -gt 0 ]] || return 0
269269

270270
local tmp="${file}.tmp"
271-
local insert_text
272-
insert_text=$(printf '%s\n' "${envs_to_add[@]}")
271+
local insert_file="${file}.envinsert"
273272

274-
awk -v ins="$insert_text" '/DISABLE_UPNP/ { print; print ins; next } { print }' "$file" > "$tmp" && mv "$tmp" "$file"
273+
# macOS ships BSD awk, which can error with "newline in string" if a -v argument contains
274+
# literal newlines. Write the insertion block to a temp file and have awk read it.
275+
printf '%s\n' "${envs_to_add[@]}" >"$insert_file"
276+
277+
awk -v insfile="$insert_file" '
278+
/^[[:space:]]*environment:[[:space:]]*$/ {
279+
print
280+
while ((getline line < insfile) > 0) print line
281+
close(insfile)
282+
next
283+
}
284+
{ print }
285+
' "$file" >"$tmp" && mv "$tmp" "$file"
286+
287+
rm -f "$insert_file" || true
275288
}
276289

277290
# TODO: remove once profile macos-compatibility published
@@ -836,12 +849,12 @@ main() {
836849
echo ""
837850

838851
echo "--- Wireguard ---"
839-
dappnode_wireguard --localhost 2>&1 || \
852+
docker exec -i DAppNodeCore-api.wireguard.dnp.dappnode.eth getWireguardCredentials --localhost 2>&1 || \
840853
echo "Wireguard credentials not yet available. Try later with: dappnode_wireguard --localhost"
841854

842855
echo ""
843856
echo "--- OpenVPN ---"
844-
dappnode_openvpn_get dappnode_admin --localhost 2>&1 || \
857+
docker exec -i DAppNodeCore-vpn.dnp.dappnode.eth vpncli get dappnode_admin --localhost 2>&1 || \
845858
echo "OpenVPN credentials not yet available. Try later with: dappnode_openvpn_get dappnode_admin --localhost"
846859

847860
echo ""

0 commit comments

Comments
 (0)