Compare commits

..

No commits in common. "84f4b11b9ceaa65f6599779fba6f30249627e59d" and "e6d487863643aff02b4bdbc08440c836e06d41e1" have entirely different histories.

3 changed files with 10 additions and 35 deletions

View File

@ -27,7 +27,7 @@ The script looks for a config file at `$HOME/.config/dyn-gandi/config.log` or `/
},
"/path/to/a/file/containing/api_key": {
"example.at": [ "sub1" ],
"example.au": [ "sub1", "sub2" ]
"example.au": [ "sub1" "sub2" ]
}
},
"resolvers": [

View File

@ -6,8 +6,7 @@ from datetime import datetime
from typing import Callable, Any
def loadSettings(path: str | None) -> dict:
if path is None:
def loadSettings() -> dict:
path = f"{os.path.expanduser('~')}/.config/dyn-gandi/config.json"
if not os.path.exists(path):
@ -100,29 +99,8 @@ def renewRecords(api: dict[str, dict[str, list[str]]], current_ip: str, log: Cal
log(f"[ERROR][{domain}][{record}][{response.status_code}] {response.json()}")
def parseArgv(argv: list[str]) -> dict[str, list[str]]:
cli_options = {}
buffer = None
for arg in argv:
if arg.startswith('--'):
cli_options[arg.removeprefix('--')] = []
buffer = arg.removeprefix('--')
else:
cli_options[buffer].append(arg)
return cli_options
def main():
argv = os.sys.argv
options = {}
if len(argv) > 1:
options = parseArgv(argv[1:])
config_path = None
if 'config' in options:
config_path = options['config'][0]
settings = loadSettings(config_path)
settings = loadSettings()
log_path, ttl = settings['log_path'], settings['ttl']
def logger(x: str) -> Any: return log(x, log_path)

View File

@ -8,9 +8,6 @@ inputs: {
cfg = config.dyn-gandi;
package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default;
inherit (lib) mkIf mkEnableOption mkOption types;
format = pkgs.formats.json {};
configFile = format.generate "config.json" cfg.settings;
in {
options.dyn-gandi = {
enable = mkEnableOption "dyn-gandi";
@ -45,14 +42,14 @@ in {
environment = {
systemPackages = [package];
# etc."dyn-gandi.json" = {
# text = builtins.toJSON cfg.settings;
# };
etc."dyn-gandi.json" = {
text = builtins.toJSON cfg.settings;
};
};
systemd.services.dyn-gandi = mkIf (cfg.timer
!= null) {
script = "${package}/bin/dyn_gandi --config ${configFile}";
script = "${package}/bin/dyn_gandi"; # TODO: add config file via command line options
serviceConfig = {
Type = "oneshot";