diff --git a/Dockerfile b/Dockerfile index 5ecbe30..3d51b16 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,10 @@ -FROM python:3.8-slim-buster +FROM python:3.12.1-slim-bookworm SHELL ["/bin/bash", "-c"] + RUN echo "deb http://deb.debian.org/debian/ unstable main contrib non-free" >> /etc/apt/sources.list.d/debian.list RUN apt-get update && apt-get install -y cron xvfb firefox wget vim -RUN wget -c https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz && tar -xzf geckodriver-v0.23.0-linux64.tar.gz -C /usr/local/bin/ +RUN wget -c https://github.com/mozilla/geckodriver/releases/download/v0.33.0/geckodriver-v0.33.0-linux64.tar.gz && tar -xzf geckodriver-v0.33.0-linux64.tar.gz -C /usr/local/bin/ RUN chown root:root /usr/local/bin/geckodriver COPY afraid-cron /etc/cron.d/afraid-cron @@ -21,4 +22,4 @@ COPY . . RUN chmod +x entrypoint.sh -CMD ./entrypoint.sh +CMD /app/entrypoint.sh diff --git a/autologin.py b/autologin.py index 2594684..fd07387 100755 --- a/autologin.py +++ b/autologin.py @@ -1,5 +1,8 @@ #!/usr/bin/env python from selenium import webdriver +from selenium.webdriver.firefox.service import Service +from selenium.webdriver.firefox.options import Options +from selenium.webdriver.common.by import By import argparse import os import sys @@ -63,43 +66,43 @@ def main(logger): if args.browser == 'phantomjs': browser = webdriver.PhantomJS() else: - profile = webdriver.FirefoxProfile() - profile.set_preference("browser.download.folderList", 2) + options = Options() + options.set_preference("browser.download.folderList", 2) - browser = webdriver.Firefox(firefox_profile=profile) + browser = webdriver.Firefox(options=options) browser.get(URL) time.sleep(random.randint(1,3)) logger.debug('navigating to login page') - browser.find_element_by_link_text("Domains").click() + browser.find_element(By.LINK_TEXT, "Domains").click() time.sleep(random.randint(1,3)) logger.debug('submit login form') - username_field = browser.find_element_by_name('username') - password_field = browser.find_element_by_name('password') + username_field = browser.find_element(By.NAME, 'username') + password_field = browser.find_element(By.NAME, 'password') username_field.send_keys(USERNAME) password_field.send_keys(PASSWORD) - browser.find_element_by_name('submit').click() + browser.find_element(By.NAME, 'submit').click() time.sleep(random.randint(1,3)) logger.debug('extending account if dormant'); browser.get(URL_DORMANT); # https://freedns.afraid.org/dormant/ # https://freedns.afraid.org/dormant/?action=extend - buttons = browser.find_elements_by_xpath("//input[@type='submit']") + buttons = browser.find_elements(By.XPATH, "//input[@type='submit']") logger.debug(buttons) for input in buttons: #print attribute name of each input element # print input.get_attribute('value') if input.get_attribute('value') == "Extend your account" : - input.click() - break + input.click() + break browser.get(URL_DORMANT_EXTEND); time.sleep(random.randint(1,3)) # view the subdomains - browser.find_element_by_link_text("Subdomains").click() + browser.find_element(By.LINK_TEXT, "Subdomains").click() # check whether login was successful # 'Last IP' is only shown after login diff --git a/entrypoint.sh b/entrypoint.sh index c05fdbe..bc33fa2 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,7 @@ #!/bin/bash printenv >> /etc/environment +# Run the script once initially to ensure everything is working +bash -c "PATH=$PATH:/usr/local/bin/; source /app/venv/bin/activate && python /app/autologin.py --headless" + cron && tail -f /var/log/cron.log \ No newline at end of file