|
|
@@ -32,16 +32,47 @@ class Configuration:
|
|
|
|
|
|
@classmethod
|
|
|
def read(cls, hostname: str, login: str, config_dir: Path):
|
|
|
- secret_sources_file = config_dir / f"secret_sources_{hostname}_{login}"
|
|
|
- data_sources_file = config_dir / f"data_sources_{hostname}_{login}"
|
|
|
+ # The configuration directory has to be organized like this :
|
|
|
+ #
|
|
|
+ # .
|
|
|
+ # ├── borgmatic
|
|
|
+ # │ └── common.yaml
|
|
|
+ # ├── <host1>
|
|
|
+ # │ ├── <user1>
|
|
|
+ # │ │ ├── borgmatic.d
|
|
|
+ # │ │ │ ├── <config1>.yaml
|
|
|
+ # │ │ │ ├── <config2>.yaml
|
|
|
+ # │ │ │ └── windows.yaml
|
|
|
+ # │ │ ├── data_sources
|
|
|
+ # │ │ └── secret_sources
|
|
|
+ # │ └── <user2>
|
|
|
+ # │ ├── borgmatic.d
|
|
|
+ # │ │ ├── ...
|
|
|
+ # │ ├── data_sources
|
|
|
+ # │ └── secret_sources
|
|
|
+ # └── <host2>
|
|
|
+ # ├── <user1>
|
|
|
+ # │ ├── borgmatic.d
|
|
|
+ # │ │ ├── ...
|
|
|
+ # │ ├── data_sources
|
|
|
+ # │ └── secret_sources
|
|
|
+ # └── <user2>
|
|
|
+ # ├── borgmatic.d
|
|
|
+ # │ ├── ...
|
|
|
+ # ├── data_sources
|
|
|
+ # └── secret_sources
|
|
|
+ specific_config_dir = config_dir / hostname / login
|
|
|
+
|
|
|
+ secret_sources_file = specific_config_dir / "secret_sources"
|
|
|
+ data_sources_file = specific_config_dir / "data_sources"
|
|
|
ssh_auth_sock = os.getenv("SSH_AUTH_SOCK")
|
|
|
|
|
|
return cls(
|
|
|
secret_sources=Secret.read_sources(secret_sources_file),
|
|
|
data_sources=read_data_sources(data_sources_file),
|
|
|
- borgmatic_d_path=config_dir / "borgmatic.d",
|
|
|
+ borgmatic_d_path=specific_config_dir / "borgmatic.d",
|
|
|
borgmatic_path=config_dir / "borgmatic",
|
|
|
- history_file=config_dir / f".bash_history_{login}",
|
|
|
+ history_file=specific_config_dir / ".bash_history",
|
|
|
ssh_auth_sock=Path(ssh_auth_sock) if ssh_auth_sock else None,
|
|
|
)
|
|
|
|