Add Dockerfile.

This commit is contained in:
redxef 2023-02-21 20:45:50 +01:00
parent 8c1dc8f9ec
commit b11f3ae950
Signed by: redxef
GPG key ID: 7DAC3AA211CBD921
4 changed files with 66 additions and 2 deletions

15
Dockerfile Normal file
View file

@ -0,0 +1,15 @@
FROM alpine:latest
RUN apk --no-cache add \
python3 \
py3-pip \
py3-yaml \
py3-click \
py3-dnspython \
&& python3 -m pip install \
ovh \
schema
COPY main.py /usr/local/bin/ovhddns
COPY periodic.sh /usr/local/bin/ovhddns-periodic
ENTRYPOINT [ "ovhddns-periodic" ]

20
README.md Normal file
View file

@ -0,0 +1,20 @@
# OVHDDNS
Update a OVH subdomain to own IP.
## Configuration file
```yaml
---
ovh:
application_key: str
application_secret: str
consumer_key: str
endpoint: str
zone: str; example: redxef.at
subdomain: str; example: subdomain-xyz
field_type: *Optional* str; example: 'A' or 'AAAA'
logging: *Optional*
level: *Optional* str; default: :WARNING,ovhdns:INFO
ttl: *Optional* int; default: None
```

View file

@ -1,13 +1,11 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import itertools import itertools
import json
import os import os
import sys import sys
import logging import logging
import yaml import yaml
import schema
import click import click
import ovh import ovh
import dns.resolver import dns.resolver

31
periodic.sh Executable file
View file

@ -0,0 +1,31 @@
#!/bin/sh
pids=""
run_prog() {
"$@" &
pids="$! $pids"
}
trap_sig() {
printf '%s' "$pids" | while IFS= read -r pid; do
echo "pid=$pid"
# shellcheck disable=2086
kill -s $1 $pid
done
}
trap 'trap_sig TERM' TERM
# default to every 5 minutes
DELAY="${OVHDDNS_INTERVAL_SECONDS:-300}"
stdin_content="$(cat -)"
while :; do
echo "$stdin_content" | ovhddns "$@"
run_prog sleep "$DELAY"
wait $pids
pids=
done