diff --git a/.gitignore b/.gitignore index 4c49bd7..3afbece 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .env +server-scripts/desec/public_ip diff --git a/server-scripts/desec/desec.py b/server-scripts/desec/desec.py index 78f5fa6..ed34e37 100755 --- a/server-scripts/desec/desec.py +++ b/server-scripts/desec/desec.py @@ -4,7 +4,9 @@ import subprocess import json import os import asyncio +from time import sleep from dotenv import load_dotenv +import urllib3 load_dotenv() # Loads up .env file @@ -86,8 +88,19 @@ async def newIPCheck(): getCurrentIP() # update current ip await newIPCheck() +def waitForConnection(): + while True: + try: + response = urllib3.request("GET", "https://ifconfig.me") + return + except urllib3.exceptions.MaxRetryError: + print("Failed connection!") + sleep(1) + pass def main(): + waitForConnection() + if not os.path.exists("public_ip"): getCurrentIP() elif not os.path.exists(".env"): diff --git a/server-scripts/desec/dev.bash b/server-scripts/desec/dev.bash index be6b92f..24a745d 100755 --- a/server-scripts/desec/dev.bash +++ b/server-scripts/desec/dev.bash @@ -4,8 +4,8 @@ if [ ! -d .venv ]; then python3 -m venv .venv source .venv/bin/activate - pip install -U python-dotenv - pip install --upgrade pip # Update pip to the latest version + pip install -U python-dotenv urllib3 + pip install -U pip # Update pip to the latest version fi echo 'Make sure to run ". .venv/bin/activate" to enter the development environment'