diff --git a/.gitignore b/.gitignore index 44bb00a..6dfd5ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.secret -*_secrets.env \ No newline at end of file +*_secrets.env +server\config\ddns\ddclient\ddclient.conf \ No newline at end of file diff --git a/server/config/ddns/README.md b/server/config/ddns/README.md new file mode 100644 index 0000000..65475c3 --- /dev/null +++ b/server/config/ddns/README.md @@ -0,0 +1,17 @@ +# Updating ddclient.conf +ddclient does not natively support proper secret management for credentials. So in order to ensure that our DNS management credentials are not kept in Git, we have to work around that. + +Our credentials are stored in `ddclient_secrets.env`, which is git-ignored. Additionally, the actual `ddclient.conf` file is git-ignored because it must contain the credentials. + +So we generate the config file when it must be updated. To update the file, we can run the following command: + +```bash +cd ~/homelab/server/config/ddns/ && \ +export $(cat ddclient_secrets.env | xargs) && \ +envsubst < ./ddclient/ddclient.template > ./ddclient/ddclient.conf && \ +unset $(grep -v '^#' ddclient_secrets.env | sed -E 's/(.*)=.*/\1/' | xargs) +``` + +First we export the variables in the `ddclient_secrets.env` file (which are all simple key-value pairs). Then, the [`envsubst`](https://www.baeldung.com/linux/envsubst-command) command looks for env variable references (like `$USER_Jafner_chat`) in the `ddclient.template` file (via stdin) and replaces them with the values from the current shell. Lastly, we remove the secrets from the shell to preserve security. + +[StackOverflow - Set environment variables from file of ke/value pairs](https://stackoverflow.com/questions/19331497/set-environment-variables-from-file-of-key-value-pairs) \ No newline at end of file diff --git a/server/config/ddns/ddclient/ddclient.template b/server/config/ddns/ddclient/ddclient.template new file mode 100644 index 0000000..20dfdc0 --- /dev/null +++ b/server/config/ddns/ddclient/ddclient.template @@ -0,0 +1,26 @@ +# jafner.dev +use=web +web=dynamicdns.park-your-domain.com/getip +protocol=googledomains +ssl=yes +login=$USER_Jafner_dev +password=$PASS_Jafner_dev +@.jafner.dev, *.jafner.dev + +# jafner.chat +use=web +web=dynamicdns.park-your-domain.com/getip +protocol=cloudflare +login=$USER_Jafner_chat +password=$PASS_Jafner_chat +zone=jafner.chat +jafner.chat,*.jafner.chat + +# meganmcdonough.art +use=web +web=dynamicdns.park-your-domain.com/getip +protocol=googledomains +ssl=yes +login=$USER_Meganmcdonough_art +password=$PASS_Meganmcdonough_art +meganmcdonough.art \ No newline at end of file diff --git a/server/config/ddns/docker-compose.yml b/server/config/ddns/docker-compose.yml index 19af96e..ab6323e 100644 --- a/server/config/ddns/docker-compose.yml +++ b/server/config/ddns/docker-compose.yml @@ -17,6 +17,7 @@ services: - cloudflare_secrets.env labels: - traefik.enable=false + ddclient: image: linuxserver/ddclient container_name: ddns_ddclient