Support pwqgen/pwgen checking

Closes coop-cloud/abra#66.
This commit is contained in:
Luke Murphy 2020-12-31 18:10:13 +01:00
parent 5da9f26076
commit 44d3ac3a1c
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

14
abra
View File

@ -306,6 +306,18 @@ fi
###### Safety checks ###### 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() { require_abra_dir() {
mkdir -p "$ABRA_DIR" mkdir -p "$ABRA_DIR"
} }
@ -819,8 +831,10 @@ sub_app_secret_generate(){
LENGTH="$abra__length_" LENGTH="$abra__length_"
if [[ "$SECRET" == *"password"* ]]; then if [[ "$SECRET" == *"password"* ]]; then
require_pwqgen
PWGEN="${abra__cmd_:-pwqgen}" PWGEN="${abra__cmd_:-pwqgen}"
else else
require_pwgen
PWGEN=${abra__cmd_:-pwgen -s "$LENGTH" 1} PWGEN=${abra__cmd_:-pwgen -s "$LENGTH" 1}
fi fi