From 513eff5f1762a6a6d3a1e28b9546635578f289ca Mon Sep 17 00:00:00 2001 From: Jarno Elonen Date: Mon, 29 Jul 2024 12:10:56 +0300 Subject: [PATCH] Improve Windows/Powershell compatibility --- README.md | 20 ++++++++++++++++++++ hsm_secrets/main.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) mode change 100644 => 100755 hsm_secrets/main.py diff --git a/README.md b/README.md index 9b0cef5..e330613 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ Work-in-progress, but usable and useful. ## Installation and upgrade +LINUX: + Assuming you have a `~/bin/` directory in path, this will install(/upgrade) the tool in a `_venv` and link it into your bin directory: @@ -94,6 +96,24 @@ make rm -f ~/bin/hsm-secrets; ln -s $(pwd)/_venv/bin/hsm-secrets ~/bin/ ``` +WINDOWS: + +``` +git pull +python3 -m venv _venv +_venv\Scripts\activate +pip install -r requirements.txt +python setup.py install -e . +``` + +Then add to PowerShell profile something like this: + +``` +$env:HSM_SECRETS_CONFIG = "~\hsm-secrets\hsm-conf.yml" +Set-Alias -Name hsm-secrets -Value "~\hsm-secrets\_venv\Scripts\hsm-secrets" +``` +...and restart PowerShell. + ## Authentication Default HSM authentication method depends on the subcommand: diff --git a/hsm_secrets/main.py b/hsm_secrets/main.py old mode 100644 new mode 100755 index d6e1efe..2b85cd8 --- a/hsm_secrets/main.py +++ b/hsm_secrets/main.py @@ -59,7 +59,7 @@ def cli(ctx: click.Context, config: str|None, quiet: bool, yklabel: str|None, hs raise click.UsageError(f"No configuration file found in env or {str(default_paths)}. Please specify a config file with -c/--config or set the {env_var} environment variable.") cli_info("Using config file: " + click.style(config, fg='cyan'), err=True) - conf = load_hsm_config(config) + conf = load_hsm_config(os.path.expanduser(config)) assert conf.general.master_device, "No master YubiHSM serial specified in config file."