Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cloaking rules file #71

Merged
merged 5 commits into from
Jan 24, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 8 additions & 22 deletions bind/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
fetch_env() {
local env_var_name=$1
local env_var_value=""
local retries=30 # Number of retries
local wait_time=1 # Wait time between retries
local wait_time=10 # Wait time between retries

for i in $(seq 1 $retries); do
echo "Fetching $env_var_name (attempt $i)"
while true; do
echo "Fetching $env_var_name"
env_var_value=$(curl -s "my.dappnode/global-envs/$env_var_name")

if [ -n "$env_var_value" ]; then
Expand All @@ -18,9 +17,6 @@ fetch_env() {

sleep $wait_time
done

echo " [ERROR] Failed to fetch $env_var_name after $retries attempts."
return 1
}

# Start DNS server in background right away
Expand All @@ -38,26 +34,16 @@ if [ -n "${_DAPPNODE_GLOBAL_DOMAIN}" ]; then
domain=${_DAPPNODE_GLOBAL_DOMAIN}
echo "Using existing domain: $domain"
else
fetched_domain=$(fetch_env "DOMAIN")

if [ $? -eq 0 ]; then
domain=$fetched_domain
else
echo "[ERROR] Failed to fetch DOMAIN"
fi
fetched_domain=$(fetch_env "DOMAIN" | tail -n 1)
3alpha marked this conversation as resolved.
Show resolved Hide resolved
domain=$fetched_domain
fi

if [ -n "${_DAPPNODE_GLOBAL_INTERNAL_IP}" ]; then
internal_ip=${_DAPPNODE_GLOBAL_INTERNAL_IP}
echo "Using existing domain: $domain"
echo "Using existing internal IP: $internal_ip"
else
fetched_internal_ip=$(fetch_env "INTERNAL_IP")

if [ $? -eq 0 ]; then
internal_ip=$fetched_internal_ip
else
echo "[ERROR] Failed to fetch INTERNAL_IP"
fi
fetched_internal_ip=$(fetch_env "INTERNAL_IP" | tail -n 1)
3alpha marked this conversation as resolved.
Show resolved Hide resolved
internal_ip=$fetched_internal_ip
fi

# Only write to cloaking-rules.txt if both domain and internal_ip are available
Expand Down