diff --git a/install.py b/install.py index 3a6aedd..d3349d1 100755 --- a/install.py +++ b/install.py @@ -46,7 +46,7 @@ class Installer: with open("secrets.template", "r") as template_file: template_content = [ line.strip() - for line in template_file.readlines() + for line in template_file.read().split("\n\n") if not line.startswith("#") and line.strip() ] except FileNotFoundError: @@ -63,10 +63,10 @@ class Installer: print("No 'secrets' file found. Did you forget to create it?") sys.exit(1) - # Check that the template file and secrets file have the same keys - template_keys = [line.split("=")[0] for line in template_content] - secrets_keys = [line.split("=")[0] for line in secrets_content] + template_keys = [line.split("=")[0] for line in template_content if "=" in line] + secrets_keys = [line.split("=")[0] for line in secrets_content if "=" in line] + # Check that the template file and secrets file have the same keys if template_keys != secrets_keys: print( "'secrets.template' and 'secrets' don't have the same keys.\n" @@ -74,12 +74,12 @@ class Installer: ) sys.exit(1) + secrets_values = [line.split("=")[1] for line in secrets_content if "=" in line] + # Check that each key has a value that has been set: - for line in secrets_content: - key, value = line.split("=") - value = value.replace("'", "").replace('"', "") + for i, value in enumerate(secrets_values): if not value: - print(line) + key = secrets_keys[i] print(f" 'secrets' file has no value for {key}, please add one.") sys.exit(1) diff --git a/secrets.template b/secrets.template index 0035259..802467d 100644 --- a/secrets.template +++ b/secrets.template @@ -1,8 +1,11 @@ # secrets - is sourced by some commands - this is a template SETUP_COCKPIT_EMAIL='john@doe.com' + SSH_REPO='user@ho.st' + BORG_PASSPHRASE='passphrase' + BORG_EXCLUDES="\ /path/to/exlude/* /another/*/path/to/exlude/*