Add Dockerfile.
This commit is contained in:
parent
8c1dc8f9ec
commit
b11f3ae950
4 changed files with 66 additions and 2 deletions
15
Dockerfile
Normal file
15
Dockerfile
Normal 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
20
README.md
Normal 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
|
||||
```
|
2
main.py
2
main.py
|
@ -1,13 +1,11 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import itertools
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import logging
|
||||
|
||||
import yaml
|
||||
import schema
|
||||
import click
|
||||
import ovh
|
||||
import dns.resolver
|
||||
|
|
31
periodic.sh
Executable file
31
periodic.sh
Executable 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
|
||||
|
Loading…
Reference in a new issue