From 538c30e930a21f61c3016cd78bfe5e73fa8e6c04 Mon Sep 17 00:00:00 2001 From: Aurelien Gaston Date: Sun, 13 Mar 2022 11:31:49 +0100 Subject: [PATCH] Add instruction from original repo (script in cron) Signed-off-by: Aurelien Gaston --- README.md | 48 +++++++++++++++++++++++++++++++---------------- docker/Dockerfile | 6 +++--- dynhost.sh | 5 +++++ 3 files changed, 40 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 792a0f4..057f345 100644 --- a/README.md +++ b/README.md @@ -12,20 +12,46 @@ A docker image and a Chart is also provided for deployment on kubernetes. > You may also just use `cron` to run the script. -## Prerequisites -### If using the Chart +## How it works -* Kubernetes 1.21 -* helm 3.6.3 +1. The command `dig` is used to retrieve the IP address of your domain name. +2. The command `curl` (with the website `ifconfig.co`) is used to retrieve the current public IP address of your machine. +3. The two IPs are compared and if necessary a `curl` command to OVH is used to update your DynHost with your current public IP address. -> Other versions might work but were not tested. +## Prerequisites ### If running on the host * `curl` - HTTP calls * `dig` - DNS lookup +> On ubuntu `dig` is provided by the `dnsutils` package + +### If using the Chart + +* Kubernetes `1.21` +* helm `3.6.3` + +> Other versions might work but were not tested. + +## Installing as an hourly CRON + +1. Download the `dynhost.sh` script and put it in the folder `/etc/cron.hourly` (to check every hour) +2. Add execution permissions to file : `chmod +x dynhost.sh` +3. Rename `dynhost.sh` to `dynhost` (because `.` at the end of the file name is not allowed in cron) +4. Modify the script with variables : `HOST`, `LOGIN`, `PASSWORD` + +## Script parameters + +The script uses environment variable as parameters. + +| Name | Description | Value | +| ---------- | ---------------------------------------------- | ----- | +| `HOST` | **Mandatory** - The dynhost DNS name to update | `""` | +| `LOGIN` | **Mandatory** - The dynhost identifier | `""` | +| `PASSWORD` | **Mandatory** - The dynhost password | `""` | + ## Installing the Chart To install the chart: @@ -45,7 +71,7 @@ helm install [RELEASE] chart \ ## Uninstalling the Chart ```sh -helm delete [RELEASE] +helm uninstall [RELEASE] ``` ## Chart parameters @@ -85,16 +111,6 @@ helm delete [RELEASE] | `tolerations` | Pod tolerations | `[]` | | `affinity` | Pod affinities | `{}` | -## Script parameters - -The script uses environment variable as parameters. - -| Name | Description | Value | -| ---------- | ---------------------------------------------- | ----- | -| `HOST` | **Mandatory** - The dynhost DNS name to update | `""` | -| `LOGIN` | **Mandatory** - The dynhost identifier | `""` | -| `PASSWORD` | **Mandatory** - The dynhost password | `""` | - ## Building and publishing the Docker image ```sh diff --git a/docker/Dockerfile b/docker/Dockerfile index a8bc537..f5bd20e 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,8 +1,8 @@ FROM alpine:latest -ENV HOST=DOMAIN_NAME \ - LOGIN=LOGIN \ - PASSWORD=PASSWORD +ENV HOST= \ + LOGIN= \ + PASSWORD= RUN addgroup dynhost \ && adduser -G dynhost -D -H dynhost diff --git a/dynhost.sh b/dynhost.sh index c55ff95..d73864f 100755 --- a/dynhost.sh +++ b/dynhost.sh @@ -1,5 +1,10 @@ #!/usr/bin/env sh +# Set those accordingly +HOST= +LOGIN= +PASSWORD= + # Account configuration if [ -z $HOST ] then