Skip to content

Commit

Permalink
Use jq to retrieve envs
Browse files Browse the repository at this point in the history
  • Loading branch information
dappnodedev committed Jan 23, 2024
1 parent a3a07b1 commit bffca99
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion bind/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ FROM alpine:3.18

WORKDIR /app

RUN apk add --no-cache curl
RUN apk add --no-cache curl jq

COPY --from=builder /usr/local/bin/dnscrypt-proxy /app/dnscrypt-proxy

Expand Down
8 changes: 5 additions & 3 deletions bind/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fetch_envs() {
local wait_time=10 # Wait time between retries

while true; do
response=$(curl -s http://dappmanager-api/global-envs) # Replace with actual API endpoint if different
response=$(curl -s http://dappmanager.dappnode/global-envs) # Replace with actual API endpoint if different

if [ $? -eq 0 ]; then
domain=$(echo $response | jq -r '.DOMAIN')
Expand All @@ -24,7 +24,7 @@ fetch_envs() {
break
fi
else
echo "Failed to fetch data. Retrying in $wait_time seconds..."
echo "[ERROR] Failed to fetch data. Retrying in $wait_time seconds..."
fi

sleep $wait_time
Expand All @@ -36,8 +36,9 @@ if [ -n "${_DAPPNODE_GLOBAL_DOMAIN}" ] && [ -n "${_DAPPNODE_GLOBAL_INTERNAL_IP}"
domain=${_DAPPNODE_GLOBAL_DOMAIN}
internal_ip=${_DAPPNODE_GLOBAL_INTERNAL_IP}

echo "Using domain($domain) and internal ip ($internal_ip) from global envs."
echo "[INFO] Using domain($domain) and internal ip ($internal_ip) from global envs."
else
echo "[INFO] Fetching domain and internal ip from Dappmanager API..."
fetch_envs
fi

Expand All @@ -50,5 +51,6 @@ if [ -n "$domain" ] && [ -n "$internal_ip" ]; then

/app/dnscrypt-proxy
else
touch cloaking-rules.txt
echo "[ERROR] Missing domain or internal IP. Cloaking rules not updated. Dyndns domain will not be forwarded to internal IP."
fi

0 comments on commit bffca99

Please sign in to comment.