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 error being set into txt file #64

Merged
merged 2 commits into from
Jan 8, 2024
Merged
Changes from all 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
37 changes: 29 additions & 8 deletions bind/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@ fetch_env() {
sleep $wait_time
done

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

# Start DNS server in background right away
/app/dnscrypt-proxy &

# Initialize domain and internal_ip variables
domain=""
internal_ip=""

pid=$!

# Fetch required environment variables
Expand All @@ -34,19 +38,36 @@ if [ -n "${_DAPPNODE_GLOBAL_DOMAIN}" ]; then
domain=${_DAPPNODE_GLOBAL_DOMAIN}
echo "Using existing domain: $domain"
else
domain=$(fetch_env "DOMAIN")
fetched_domain=$(fetch_env "DOMAIN")

if [ $? -eq 0 ]; then
domain=$fetched_domain
else
echo "[ERROR] Failed to fetch DOMAIN"
fi
fi

if [ -n "${_DAPPNODE_GLOBAL_INTERNAL_IP}" ]; then
internal_ip=${_DAPPNODE_GLOBAL_INTERNAL_IP}
echo "Using existing domain: $domain"
else
internal_ip=$(fetch_env "INTERNAL_IP")
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
fi

echo "$domain $internal_ip" >cloaking-rules.txt
# Only write to cloaking-rules.txt if both domain and internal_ip are available
if [ -n "$domain" ] && [ -n "$internal_ip" ]; then
echo "$domain $internal_ip" >cloaking-rules.txt

kill $pid
wait $pid
kill $pid
wait $pid

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