From 44d3ac3a1cb86edc9b9e91eea1a00e70eae14965 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Thu, 31 Dec 2020 18:10:13 +0100 Subject: [PATCH] Support pwqgen/pwgen checking Closes https://git.autonomic.zone/coop-cloud/abra/issues/66. --- abra | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/abra b/abra index 619fc63..8c2acda 100755 --- a/abra +++ b/abra @@ -306,6 +306,18 @@ fi ###### Safety checks +require_pwqgen() { + if ! type pwqgen > /dev/null 2>&1; then + error "pwqgen program is not installed" + fi +} + +require_pwgen() { + if ! type pwgen > /dev/null 2>&1; then + error "pwgen program is not installed" + fi +} + require_abra_dir() { mkdir -p "$ABRA_DIR" } @@ -819,8 +831,10 @@ sub_app_secret_generate(){ LENGTH="$abra__length_" if [[ "$SECRET" == *"password"* ]]; then + require_pwqgen PWGEN="${abra__cmd_:-pwqgen}" else + require_pwgen PWGEN=${abra__cmd_:-pwgen -s "$LENGTH" 1} fi