Skip to content
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
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,26 @@ CHECK_IP_CHANGE = True
LAST_IP_FILE = "lastip.txt"
```

## Docker

To build docker from dockerfile: Replace imagenamexyz with your own
```
docker build --rm -f "dockerfile" -t imagenameXYZ:tag .
```
Dockercompose example:
```
version: '3.3'
services:
one:
image: imagenameXYZ:latest
environment:
- Username=example@domain.com
- Password=pwd
- Domain=domain.com
- SubDomains=sub
```


## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Expand Down
1 change: 1 addition & 0 deletions builddocker.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docker build --rm -f "dockerfile" -t onedotcomddns:latest .
9 changes: 9 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version: '3.3'
services:
one:
image: onedotcomddns:latest
environment:
- USERNAME=NotMyEmail
- PASSWORD=NotMyPass
- Domain=not-my-domain.com
- SubDomains=subdomain
8 changes: 8 additions & 0 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM python:3
RUN pip3 install requests --user

WORKDIR /usr/src/app

COPY . .

CMD [ "python3", "one_com_ddns.py" ]
34 changes: 18 additions & 16 deletions one_com_ddns.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,41 +29,43 @@
on github or send me an email (main@lugico.de)

'''


import os
import requests
import json
import sys

# YOUR ONE.COM LOGIN
USERNAME="email.address@example.com"
PASSWORD="Your Beautiful Password"

#USERNAME="email.address@example.com"
USERNAME = os.getenv('Username')
#PASSWORD="Your Beautiful Password"
PASSWORD = os.getenv('Password')
# YOUR DOMAIN ( NOT www.example.com, only example.com )"
DOMAIN="example.com"

#DOMAIN="example.com"
DOMAIN = os.getenv('Domain')
# LIST OF SUBDOMAINS YOU WANT POINTING TO YOUR IP
SUBDOMAINS = ["myddns"]
#SUBDOMAINS = ["myddns"]
# SUBDOMAINS = ["mutiple", "subdomains"]

SUBDOMAINS = os.getenv('SubDomains').split(',')

# YOUR IP ADDRESS.
IP='AUTO'
#IP='AUTO'
IP = os.getenv('IP','AUTO')
# '127.0.0.1' -> IP Address
# 'AUTO' -> Automatically detect using ipify.org
# 'ARG' -> Read from commandline argument ($ python3 ddns.py 127.0.0.1)


# CHECK IF IP ADDRESS HAS CHANGED SINCE LAST SCRIPT EXECUTION?
CHECK_IP_CHANGE = True
#CHECK_IP_CHANGE = True
CHECK_IP_CHANGE = os.getenv('Change','true').lower() == 'true'
# True = only continue when IP has changed
# False = always continue

# PATH WHERE THE LAST IP SHOULD BE SAVED INBETWEEN SCRIPT EXECUTIONS
# not needed CHECK_IP_CHANGE is false
LAST_IP_FILE = "lastip.txt"


import requests
import json
import sys
print(f"Running with options USERNAME: {USERNAME}, DOMAIN:{DOMAIN} SUBDomains: {SUBDOMAINS} IPMode: {IP}, Change detection: {CHECK_IP_CHANGE}")

if IP == 'AUTO':
IP = requests.get("https://api.ipify.org/").text
Expand Down Expand Up @@ -185,4 +187,4 @@ def changeIP(session, ID, DOMAIN, SUBDOMAIN, IP, TTL=3600):
if recordid == "":
print("!!! - Record '" + subdomain + "' could not be found.")
continue
changeIP(s, recordid, DOMAIN, subdomain, IP, 600)
changeIP(s, recordid, DOMAIN, subdomain, IP, 600)