From e9fb9e56ad599febe24df5e9125b0dc0709f2eaf Mon Sep 17 00:00:00 2001 From: decentral1se Date: Sun, 4 Jul 2021 23:06:20 +0200 Subject: [PATCH] Drop pwgen/pwqgen requirements Closes https://git.autonomic.zone/coop-cloud/abra/issues/167. --- CHANGELOG.md | 1 + README.md | 8 +++----- abra | 16 +++++++++++----- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d34a566..951d6db 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Skip generation of commented out secrets and correctly fail deploy when secret generation fails ([#133](https://git.autonomic.zone/coop-cloud/abra/issues/133)) - Fix logging for chaos deploys and recipe selection logic ([#185](https://git.autonomic.zone/coop-cloud/abra/issues/185)) - Improve reliability of selectig when to download a new `apps.json` ([#170](https://git.autonomic.zone/coop-cloud/abra/issues/170)) +- Remove `pwgen`/`pwqgen` as password generator requirements ([#167](https://git.autonomic.zone/coop-cloud/abra/issues/167)) # abra 9.0.0 (2021-06-10) diff --git a/README.md b/README.md index 014dbca..d150079 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,14 @@ See [CHANGELOG.md](./CHANGELOG.md). > [docs.coopcloud.tech](https://docs.coopcloud.tech) -## Install +## Requirements -Requirements: - -- `pwqgen` (optional) -- `pwgen` (optional) - `curl` - `docker` - `bash` >= 4 +## Install + Install the latest stable release: ```sh diff --git a/abra b/abra index 861bb29..0550500 100755 --- a/abra +++ b/abra @@ -652,6 +652,14 @@ checkout_main_or_master() { git checkout main > /dev/null 2>&1 || git checkout master > /dev/null 2>&1 } +pwgen_native() { + tr -dc 'a-zA-Z0-9' < /dev/urandom | head -c "$1" +} + +pwqgen_native() { + shuf -n 3 /usr/share/dict/words | tr -dc 'a-zA-Z0-9' | tr -d '\n' +} + # FIXME 3wc: update or remove if [ -z "$ABRA_ENV" ] && [ -f .env ] && type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed true'; then error "direnv is blocked, run direnv allow" @@ -1706,11 +1714,9 @@ sub_app_secret_generate(){ fi if [[ -n "$length" ]]; then - require_binary pwgen - abra__cmd_="pwgen -s $length 1" + abra__cmd_="pwgen_native $length" else - require_binary pwqgen - abra__cmd_=pwqgen + abra__cmd_=pwqgen_native fi PWGEN=${abra__cmd_} @@ -1720,7 +1726,7 @@ sub_app_secret_generate(){ error "Required arguments missing" fi - PW=$($PWGEN|tr -d "\n") + PW=$($PWGEN) success "Password: $PW"