Skip to content

johnwbyrd/freedns-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FreeDNS Automation

A Python-based automation tool using Playwright to automatically log into FreeDNS accounts, helping to keep them active.

Overview

FreeDNS (freedns.afraid.org) may deactivate accounts after extended periods of inactivity. This tool automates the login process to ensure your account remains active.

Prerequisites

  • Ubuntu 22.04 LTS or later
  • Python 3.8+
  • Internet connection

Installation

Phase 1: System Setup (Requires sudo)

The setup.sh script installs system dependencies and creates a Python virtual environment. This phase requires sudo permissions only for installing system packages.

chmod +x setup.sh
./setup.sh

Permissions needed:

  • sudo access for apt-get commands to install system packages
  • Write access to current directory for creating the virtual environment

Phase 2: Configuration (No special permissions)

After installation, activate the virtual environment:

source freedns-automation/bin/activate

Usage

Manual Execution (No special permissions)

The script can be run with user-level permissions:

# Using command line arguments
python freedns_login.py -u your_username -p your_password

# Using environment variables
export FREEDNS_USERNAME='your_username'
export FREEDNS_PASSWORD='your_password'
python freedns_login.py

Automated Execution with Cron (No root required)

The automation script runs perfectly fine with regular user permissions. Here's how to set up a cron job:

  1. Edit your user's crontab:
crontab -e
  1. Add one of these example entries:
# Run weekly on Sundays at 2:17 AM (recommended for most users)
17 2 * * 0 cd /home/your_user/git/freedns-automation && /home/your_user/git/freedns-automation/freedns-automation/bin/python /home/your_user/git/freedns-automation/freedns_login.py

# Run monthly on the 1st at 3:42 AM
42 3 1 * * cd /home/your_user/git/freedns-automation && /home/your_user/git/freedns-automation/freedns-automation/bin/python /home/your_user/git/freedns-automation/freedns_login.py

# Run every 3 months on the 1st at 4:23 AM (Jan, Apr, Jul, Oct)
23 4 1 */3 * cd /home/your_user/git/freedns-automation && /home/your_user/git/freedns-automation/freedns-automation/bin/python /home/your_user/git/freedns-automation/freedns_login.py

Cron with Environment Variables

For better security, store credentials in a separate file:

  1. Create a credentials file (readable only by you):
touch ~/.freedns_creds
chmod 600 ~/.freedns_creds
  1. Add credentials to the file:
echo 'export FREEDNS_USERNAME="your_username"' >> ~/.freedns_creds
echo 'export FREEDNS_PASSWORD="your_password"' >> ~/.freedns_creds
  1. Use this crontab entry:
# Run weekly with credentials from file
17 2 * * 0 source /home/your_user/.freedns_creds && cd /home/your_user/git/freedns-automation && /home/your_user/git/freedns-automation/freedns-automation/bin/python /home/your_user/git/freedns-automation/freedns_login.py

Permissions Summary

Phase Required Permissions Purpose
Installation sudo (temporary) Install system packages via apt-get
Configuration User-level Create virtual environment, install Python packages
Execution User-level Run the automation script
Cron Setup User-level Schedule automated runs

Security Considerations

  1. Credentials: Never commit credentials to version control
  2. File Permissions: If storing credentials in files, ensure they're readable only by you (chmod 600)
  3. Headless Mode: For production/cron use, modify freedns_login.py line 10 to headless=True
  4. Logs: When running via cron, redirect output to a log file for debugging

Troubleshooting

Cron Job Not Running

  1. Check cron logs:
grep CRON /var/log/syslog
  1. Ensure full paths are used in crontab (cron has minimal PATH)

  2. For debugging, add logging to your crontab:

17 2 * * 0 source /home/your_user/.freedns_creds && cd /home/your_user/git/freedns-automation && /home/your_user/git/freedns-automation/freedns-automation/bin/python /home/your_user/git/freedns-automation/freedns_login.py >> /home/your_user/freedns_automation.log 2>&1

Display Issues in Cron

When running via cron in headless mode, you might need to set display variables:

17 2 * * 0 export DISPLAY=:0 && source /home/your_user/.freedns_creds && cd /home/your_user/git/freedns-automation && /home/your_user/git/freedns-automation/freedns-automation/bin/python /home/your_user/git/freedns-automation/freedns_login.py

License

This project is provided as-is for educational and personal use.

About

Log in periodically to freedns afraid and other freedns services to keep service alive

Topics

Resources

Stars

Watchers

Forks