commit
19d6354826
9 changed files with 176 additions and 0 deletions
@ -0,0 +1 @@ |
|||||||
|
.idea |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
language: bash |
||||||
|
os: linux |
||||||
|
arch: |
||||||
|
- amd64 |
||||||
|
- arm64 |
||||||
|
- ppc64le |
||||||
|
- s390x |
||||||
|
|
||||||
|
services: docker |
||||||
|
sudo: required |
||||||
|
|
||||||
|
script: |
||||||
|
- docker build . |
||||||
|
|
||||||
|
after_script: |
||||||
|
- docker images |
||||||
@ -0,0 +1,37 @@ |
|||||||
|
ARG ARCH=amd64/ |
||||||
|
FROM ${ARCH}alpine:latest |
||||||
|
MAINTAINER webhainaut <jerome@webhainaut.be> |
||||||
|
|
||||||
|
ENV HOST="" |
||||||
|
ENV LOGIN="" |
||||||
|
ENV PASSWORD="" |
||||||
|
ENV ENTRYPOINT="https://www.ovh.com/nic/update" |
||||||
|
ENV NSSERVER="8.8.8.8" |
||||||
|
|
||||||
|
RUN echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ |
||||||
|
&& apk --no-cache update \ |
||||||
|
&& apk --no-cache upgrade \ |
||||||
|
&& apk add --no-cache \ |
||||||
|
curl \ |
||||||
|
wget \ |
||||||
|
curl \ |
||||||
|
bash \ |
||||||
|
zip \ |
||||||
|
dcron \ |
||||||
|
bind-tools \ |
||||||
|
ca-certificates \ |
||||||
|
&& mkdir -p /srv/dyndns |
||||||
|
|
||||||
|
COPY config /srv/dyndns/cmd.sh |
||||||
|
COPY config /srv/dyndns/entrypoint.sh |
||||||
|
COPY config /srv/dyndns/dynhost |
||||||
|
COPY config /etc/cron.d/dynhost |
||||||
|
|
||||||
|
RUN chmod +x /srv/dyndns/dynhost \ |
||||||
|
&& chmod +x /srv/dyndns/entrypoint.sh \ |
||||||
|
&& chmod +x /srv/dyndns/cmd.sh |
||||||
|
|
||||||
|
HEALTHCHECK --interval=5s --timeout=3s CMD ps aux | grep '[c]rond' || exit 1 |
||||||
|
|
||||||
|
ENTRYPOINT ["/srv/dyndns/entrypoint.sh"] |
||||||
|
CMD ["/srv/dyndns/cmd.sh"] |
||||||
@ -0,0 +1,21 @@ |
|||||||
|
MIT License |
||||||
|
|
||||||
|
Copyright (c) 2020 webhainaut |
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||||
|
of this software and associated documentation files (the "Software"), to deal |
||||||
|
in the Software without restriction, including without limitation the rights |
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||||
|
copies of the Software, and to permit persons to whom the Software is |
||||||
|
furnished to do so, subject to the following conditions: |
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all |
||||||
|
copies or substantial portions of the Software. |
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||||
|
SOFTWARE. |
||||||
@ -0,0 +1,46 @@ |
|||||||
|
# DynDNS update script for OVH domains |
||||||
|
|
||||||
|
[](https://travis-ci.org/webhainaut/docker) |
||||||
|
|
||||||
|
this is based on *ovh-dyndns* from [Ambroisemaupate work](https://github.com/ambroisemaupate/Docker). |
||||||
|
|
||||||
|
https://docs.ovh.com/fr/domains/utilisation-dynhost/ |
||||||
|
|
||||||
|
Check every 5 minutes you WAN IP and if changed call OVH entry-point to update |
||||||
|
your DynDNS domain. |
||||||
|
|
||||||
|
``` |
||||||
|
docker run -d --name="ovh-dyndns" \ |
||||||
|
-e "HOST=mydynamicdomain.domain.com" \ |
||||||
|
-e "LOGIN=mylogin" \ |
||||||
|
-e "PASSWORD=mypassword" \ |
||||||
|
ambroisemaupate/ovh-dyndns |
||||||
|
``` |
||||||
|
|
||||||
|
## Docker-compose |
||||||
|
|
||||||
|
``` |
||||||
|
version: "3" |
||||||
|
services: |
||||||
|
crond: |
||||||
|
image: ambroisemaupate/ovh-dyndns |
||||||
|
environment: |
||||||
|
HOST: mydynamicdomain.domain.com |
||||||
|
LOGIN: mylogin |
||||||
|
PASSWORD: mypassword |
||||||
|
restart: always |
||||||
|
``` |
||||||
|
|
||||||
|
## Customize external NS server |
||||||
|
|
||||||
|
By default, we use Google DNS to check your current DynDNS IP, but you can choose an |
||||||
|
other DNS overriding `NSSERVER` env var: |
||||||
|
|
||||||
|
``` |
||||||
|
docker run -d --name="ovh-dyndns" \ |
||||||
|
-e "HOST=mydynamicdomain.domain.com" \ |
||||||
|
-e "LOGIN=mylogin" \ |
||||||
|
-e "PASSWORD=mypassword" \ |
||||||
|
-e "NSSERVER=192.168.1.1" \ |
||||||
|
ambroisemaupate/ovh-dyndns |
||||||
|
``` |
||||||
@ -0,0 +1,4 @@ |
|||||||
|
#!/bin/sh |
||||||
|
set -e |
||||||
|
|
||||||
|
crond -s /etc/cron.d -f -L /proc/self/fd/1 "$@" |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
# Exec dynhost every 5 minutes |
||||||
|
*/5 * * * * /bin/sh /srv/dyndns/dynhost |
||||||
@ -0,0 +1,42 @@ |
|||||||
|
#! /bin/sh |
||||||
|
# Mainly inspired by DynHost script given by OVH |
||||||
|
# New version by zwindler (zwindler.fr/wordpress) |
||||||
|
# |
||||||
|
# Initial version was doing nasty grep/cut on local ppp0 interface |
||||||
|
# |
||||||
|
# This coulnd't work in a NATed environnement like on ISP boxes |
||||||
|
# on private networks. |
||||||
|
# |
||||||
|
# Also got rid of ipcheck.py thanks to mafiaman42 |
||||||
|
# |
||||||
|
# This script uses curl to get the public IP, and then uses wget |
||||||
|
# to update DynHost entry in OVH DNS |
||||||
|
# |
||||||
|
# Logfile: dynhost.log |
||||||
|
# |
||||||
|
# CHANGE: "HOST", "LOGIN" and "PASSWORD" to reflect YOUR account variables |
||||||
|
SCRIPT_PATH='/srv/dyndns' |
||||||
|
|
||||||
|
getip() { |
||||||
|
IP=`curl http://ifconfig.me/ip` |
||||||
|
OLDIP=`dig +short $HOST @$NSSERVER` |
||||||
|
} |
||||||
|
|
||||||
|
echo "[`date '+%Y-%m-%d %H:%M:%S'`] =============================================================" |
||||||
|
echo "[`date '+%Y-%m-%d %H:%M:%S'`] Begining new dyndns check" |
||||||
|
getip |
||||||
|
|
||||||
|
if [ "$IP" ]; then |
||||||
|
echo "[`date '+%Y-%m-%d %H:%M:%S'`] Old IP is ${OLDIP}" |
||||||
|
echo "[`date '+%Y-%m-%d %H:%M:%S'`] New IP is ${IP}" |
||||||
|
|
||||||
|
if [ "$OLDIP" != "$IP" ]; then |
||||||
|
echo "[`date '+%Y-%m-%d %H:%M:%S'`] Update is needed…" |
||||||
|
wget "${ENTRYPOINT}?system=dyndns&hostname=${HOST}&myip=${IP}" --user="${LOGIN}" --password="${PASSWORD}" |
||||||
|
echo -n "$IP" > $SCRIPT_PATH/old.ip |
||||||
|
else |
||||||
|
echo "[`date '+%Y-%m-%d %H:%M:%S'`] No update required." |
||||||
|
fi |
||||||
|
else |
||||||
|
echo "[`date '+%Y-%m-%d %H:%M:%S'`] WAN IP not found. Exiting!" |
||||||
|
fi |
||||||
@ -0,0 +1,7 @@ |
|||||||
|
#!/bin/sh |
||||||
|
set -e |
||||||
|
|
||||||
|
# see: https://github.com/dubiousjim/dcron/issues/13 |
||||||
|
# ignore using `exec` for `dcron` to get another pid instead of `1` |
||||||
|
# exec "$@" |
||||||
|
exec "$@" |
||||||
Loading…
Reference in new issue