use EnvironmentFile in dyndns systemd service to drastically uncomplicate things

This commit is contained in:
2026-02-11 22:21:56 +01:00
parent 52486cdb13
commit 9d92c0bbd8
2 changed files with 8 additions and 19 deletions
+3 -7
View File
@@ -3,12 +3,7 @@
...
}:
let
pyenv = pkgs.python3.withPackages (
ps: with ps; [
nc-dnsapi
python-dotenv
]
);
pyenv = pkgs.python3.withPackages (ps: with ps; [ nc-dnsapi ]);
in
{
users.groups.dyndns = { };
@@ -32,7 +27,8 @@ in
serviceConfig = {
Type = "oneshot";
User = "dyndns";
ExecStart = "${pyenv.interpreter} ${./dyndns.py} ${./nc.env.secret}";
ExecStart = "${pyenv.interpreter} ${./dyndns.py}";
EnvironmentFile = ./. + "/nc.env.secret";
};
};
}
+5 -12
View File
@@ -1,17 +1,10 @@
from nc_dnsapi import Client
from dotenv import dotenv_values
import sys, urllib3
import os, urllib3
if len(sys.argv) != 2:
raise Exception("Something funky is going on with argv")
dotenv_path = sys.argv[1]
secrets = dotenv_values(dotenv_path)
CUSTOMER = secrets["NC_CUSTOMER"]
API_PASSWORD = secrets["NC_API_PASSWORD"]
API_KEY = secrets["NC_API_KEY"]
DOMAIN = secrets["NC_DOMAIN"]
CUSTOMER = os.environ["NC_CUSTOMER"]
API_PASSWORD = os.environ["NC_API_PASSWORD"]
API_KEY = os.environ["NC_API_KEY"]
DOMAIN = os.environ["NC_DOMAIN"]
ip = urllib3.request("GET", "https://api.ipify.org").data.decode()