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 errors with running script and building the Docker image #11

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -21,4 +22,4 @@ COPY . .

RUN chmod +x entrypoint.sh

CMD ./entrypoint.sh
CMD /app/entrypoint.sh
25 changes: 14 additions & 11 deletions autologin.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -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