diff --git a/README.md b/README.md index d30eb4c..6bf9fe7 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,8 @@ Docs are in the `./docs/` folder, but here's a quick overview on how to use this - Add maintenance windows (optionally recurring) - Add groups - Add ability for checkers to have preferred alerts and logging extensions - will print a warning if the preferred extension(s) are not used -- Add "keywords" to be replaced in the config (for current directory, service name, maybe some others) +- Add "keywords" to be replaced in the config (for ~~current directory~~, service name, maybe some others) + - Current directory done - `%dir%` --- diff --git a/docs/README.md b/docs/README.md index 29b8682..3af5a2f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -62,6 +62,12 @@ Optional arguments: - `name`: A human-friendly name for the service; currently unused. +#### Keywords + +Keywords get replaced with their value. + +- `%dir%`: The directory Updog is located in. + --- This example uses the template extensions, [askiiart/updog-checker_template](https://git.askiiart.net/askiiart/updog-checker_template), [askiiart/updog-logging_template](https://git.askiiart.net/askiiart/updog-logging_template), and [askiiart/updog-alerts_template](https://git.askiiart.net/askiiart/updog-alerts_template), so the arguments for them are mostly irrelevant. For each extension, check its docs for what arguments to use. diff --git a/services-example.json b/services-example.json index 6c3703f..9c547ca 100644 --- a/services-example.json +++ b/services-example.json @@ -10,13 +10,13 @@ "checker-args": { "url": "https://askiiart.net" }, - "rate": 1, + "rate": 5, "alerts-args": { "url": "https://example.com/webhook-url-or-whatever-goes-here", "lol": "irrelevant, AlertsTemplate ignores these options lol" }, "logging-args": { - "file": "/home/askiiart/Documents/updog/logs/site-log" + "file": "%dir%/logs/site-log" } } } \ No newline at end of file diff --git a/updog.py b/updog.py index 2cbadfe..1888b91 100644 --- a/updog.py +++ b/updog.py @@ -71,8 +71,14 @@ elif 'services-example.json' in os.listdir(path): config_filename = f'{path}/services-example.json' with open(config_filename, 'rt') as config_file: + config_text = ''.join(config_file.readlines()) + # Replace static keywords in config + keywords = {'%dir%': path} + for key in keywords: + config_text = config_text.replace(key, keywords[key]) config = json.loads(''.join(config_file.readlines())) + instances = create_instances(config, checkers, alerts, logging) timers = {}