Compare commits

..

9 Commits

Author SHA1 Message Date
3wc
546d53b93e app restore
All checks were successful
continuous-integration/drone/pr Build is passing
2021-01-01 22:20:42 +02:00
3wc
b9e89048fd Add scaffolding for per-app backup commands
See #70
2021-01-01 22:19:52 +02:00
3wc
e94b862dc3 Add global --skip-check / --skip-update commands 2021-01-01 22:19:09 +02:00
6ba2657dc1
Use short hash convention
All checks were successful
continuous-integration/drone/push Build is passing
2021-01-01 18:59:19 +01:00
ac6b805cbf
Follow parens convention 2021-01-01 18:57:39 +01:00
decentral1se
d4e52a9de3 Merge pull request 'Make secret generation more robust' (#73) from simplify-secret-logic into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.autonomic.zone/coop-cloud/abra/pulls/73
2021-01-01 18:55:47 +01:00
aa59c1ad43
Make secret generation more robust
All checks were successful
continuous-integration/drone/pr Build is passing
Closes https://git.autonomic.zone/coop-cloud/abra/issues/68.
2021-01-01 18:54:41 +01:00
decentral1se
36f1d679ae Merge pull request 'Merging auto functionality into generate command' (#64) from app-auto-merge into main
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: https://git.autonomic.zone/coop-cloud/abra/pulls/64
2021-01-01 17:32:30 +01:00
f5c8ee1136
Merge auto/generate and use --secrets
All checks were successful
continuous-integration/drone/pr Build is passing
Closes https://git.autonomic.zone/coop-cloud/abra/issues/58.
2021-01-01 17:31:21 +01:00
2 changed files with 119 additions and 126 deletions

View File

@ -1,20 +1,22 @@
# abra x.x.x (UNRELEASED)
- `secret auto` merged into `secret generate` and `app new --auto` is now `app new --secrets` ([#64](https://git.autonomic.zone/coop-cloud/abra/pulls/64))
- Avoid outputting length during secret generation when not in use ([#67](https://git.autonomic.zone/coop-cloud/abra/issues/67))
- Support graceful failure when missing secret generation commands ([44d3ac3a1cb86edc9b9e91eea1a00e70eae14965](https://git.autonomic.zone/coop-cloud/abra/commit/44d3ac3a1cb86edc9b9e91eea1a00e70eae14965))
- Fix secret detection when using new `.env` file format in apps ([55324524ca77141666ffe6cc41b62cc71cf89ace](https://git.autonomic.zone/coop-cloud/abra/commit/55324524ca77141666ffe6cc41b62cc71cf89ace))
- Support choosing an `$EDITOR` when editing configs ([29cc392dff3e93e48e0e2edd3ce11b405c66a95a](https://git.autonomic.zone/coop-cloud/abra/commit/29cc392dff3e93e48e0e2edd3ce11b405c66a95a))
- "server" shell completion fixed ([8839bd45951d00dccf4ef81ece445bcc49e13ee6](https://git.autonomic.zone/coop-cloud/abra/commit/8839bd45951d00dccf4ef81ece445bcc49e13ee6))
- Support graceful failure when missing secret generation commands ([44d3ac3](https://git.autonomic.zone/coop-cloud/abra/commit/44d3ac3a1cb86edc9b9e91eea1a00e70eae14965))
- Fix secret detection when using new `.env` file format in apps ([5532452](https://git.autonomic.zone/coop-cloud/abra/commit/55324524ca77141666ffe6cc41b62cc71cf89ace))
- Support choosing an `$EDITOR` when editing configs ([29cc392](https://git.autonomic.zone/coop-cloud/abra/commit/29cc392dff3e93e48e0e2edd3ce11b405c66a95a))
- "server" shell completion fixed ([8839bd4](https://git.autonomic.zone/coop-cloud/abra/commit/8839bd45951d00dccf4ef81ece445bcc49e13ee6))
- Drop `multilogs` command ([#56](https://git.autonomic.zone/coop-cloud/abra/pulls/56))
- Remove `server use` command ([#51](https://git.autonomic.zone/coop-cloud/abra/issues/51))
- `new <app>` becomes `new <type>` ([#48](https://git.autonomic.zone/coop-cloud/abra/issues/48))
- `check` is run on `deploy` now and configurable ([77ba5652b2fe15820f5edfa0f642636f7b8eae7e](https://git.autonomic.zone/coop-cloud/abra/commit/77ba5652b2fe15820f5edfa0f642636f7b8eae7e))
- `check` is run on `deploy` now and configurable ([77ba565](https://git.autonomic.zone/coop-cloud/abra/commit/77ba5652b2fe15820f5edfa0f642636f7b8eae7e))
- App configurations are always updated now ([#42](https://git.autonomic.zone/coop-cloud/abra/issues/42))
- We use docker format `.env` files (no "export" syntax) from now now ([#55](https://git.autonomic.zone/coop-cloud/abra/pulls/55))
- Rename `<domain>` option to `<app>` and `APP` variable to `TYPE`, see [#47](https://git.autonomic.zone/coop-cloud/abra/issues/47)
- Use Docker-in-Docker (dind), and `dind-bats-kcov` Docker image, for `make test` ([1600b6277fbbffc4c6de1e4ba799c7bbe72ec6a0](https://git.autonomic.zone/coop-cloud/abra/commit/1600b6277fbbffc4c6de1e4ba799c7bbe72ec6a0))
- Add built-in documentation using `abra help <subcommand>...`, see [#50](https://git.autonomic.zone/coop-cloud/abra/issues/50)
- `version` subcommand [e6b24fe](https://git.autonomic.zone/coop-cloud/abra/commit/e6b24fe)
- Rename `<domain>` option to `<app>` and `APP` variable to `TYPE`, see ([#47](https://git.autonomic.zone/coop-cloud/abra/issues/47))
- Use Docker-in-Docker (dind), and `dind-bats-kcov` Docker image, for `make test` ([1600b62](https://git.autonomic.zone/coop-cloud/abra/commit/1600b6277fbbffc4c6de1e4ba799c7bbe72ec6a0))
- Add built-in documentation using `abra help <subcommand>...`, see ([#50](https://git.autonomic.zone/coop-cloud/abra/issues/50))
- `version` subcommand ([e6b24fe](https://git.autonomic.zone/coop-cloud/abra/commit/e6b24fe))
- Use `# length=x` comments to generate passwords with `pwgen` and drop `KEY`/`PASSWORD` logic ([#68](https://git.autonomic.zone/coop-cloud/abra/issues/68))
- Global `--skip-update` / `--skip-check` options to make things quicker,
[37e8b00](https://git.autonomic.zone/coop-cloud/abra/commit/37e8b00)
- `app backup` and `app restore` commands; requires per-app definition -- see

225
abra
View File

@ -13,7 +13,7 @@ The cooperative cloud utility belt 🎩🐇
Usage:
abra [options] app (list|ls) [--status] [--server=<server>]
abra [options] app new [--server=<server>] [--domain=<domain>] [--app-name=<app_name>] [--pass] [--auto] <type>
abra [options] app new [--server=<server>] [--domain=<domain>] [--app-name=<app_name>] [--pass] [--secrets] <type>
abra [options] app <app> backup (<service>|--all)
abra [options] app <app> deploy
abra [options] app <app> check
@ -25,8 +25,7 @@ Usage:
abra [options] app <app> (rm|delete) [--force]
abra [options] app <app> restore <service> [<backup file>]
abra [options] app <app> run [--no-tty] [--user=<user>] <service> <args>...
abra [options] app <app> secret auto [--pass]
abra [options] app <app> secret generate <secret> <version> [<cmd>] [--pass]
abra [options] app <app> secret generate (<secret> <version>|--all) [<cmd>] [--pass]
abra [options] app <app> secret insert <secret> <version> <data> [--pass]
abra [options] app <app> secret (rm|delete) (<secret>|--all) [--pass] [--force]
abra [options] app <app> undeploy
@ -149,76 +148,77 @@ eval "var_$1+=($value)"; else eval "var_$1=$value"; fi; return 0; fi; done
return 1; }; stdout() { printf -- "cat <<'EOM'\n%s\nEOM\n" "$1"; }; stderr() {
printf -- "cat <<'EOM' >&2\n%s\nEOM\n" "$1"; }; error() {
[[ -n $1 ]] && stderr "$1"; stderr "$usage"; _return 1; }; _return() {
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1733}
usage=${DOC:40:1357}; digest=be96a
shorts=(-h -U -e -s -C '' '' '' '' '' '' '' '' '' '')
longs=(--help --skip-update --env --stack --skip-check --status --server --domain --app-name --pass --auto --all --force --no-tty --user)
argcounts=(0 0 1 1 0 0 1 1 1 0 0 0 0 0 1); node_0(){ switch __help 0; }
node_1(){ switch __skip_update 1; }; node_2(){ value __env 2; }; node_3(){
value __stack 3; }; node_4(){ switch __skip_check 4; }; node_5(){
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1696}
usage=${DOC:40:1320}; digest=563d5
shorts=(-h -s -e -U -C '' '' '' '' '' '' '' '' '' '')
longs=(--help --stack --env --skip-update --skip-check --status --server --domain --app-name --pass --secrets --all --force --no-tty --user)
argcounts=(0 1 1 0 0 0 1 1 1 0 0 0 0 0 1); node_0(){ switch __help 0; }
node_1(){ value __stack 1; }; node_2(){ value __env 2; }; node_3(){
switch __skip_update 3; }; node_4(){ switch __skip_check 4; }; node_5(){
switch __status 5; }; node_6(){ value __server 6; }; node_7(){ value __domain 7
}; node_8(){ value __app_name 8; }; node_9(){ switch __pass 9; }; node_10(){
switch __auto 10; }; node_11(){ switch __all 11; }; node_12(){ switch __force 12
}; node_13(){ switch __no_tty 13; }; node_14(){ value __user 14; }; node_15(){
value _type_ a; }; node_16(){ value _app_ a; }; node_17(){ value _service_ a; }
node_18(){ value _src_ a; }; node_19(){ value _dst_ a; }; node_20(){
value _backup_file_ a; }; node_21(){ value _args_ a true; }; node_22(){
value _secret_ a; }; node_23(){ value _version_ a; }; node_24(){ value _cmd_ a
}; node_25(){ value _data_ a; }; node_26(){ value _command_ a; }; node_27(){
value _host_ a; }; node_28(){ value _user_ a; }; node_29(){ value _port_ a; }
node_30(){ value _subcommands_ a true; }; node_31(){ _command app; }; node_32(){
switch __secrets 10; }; node_11(){ switch __all 11; }; node_12(){
switch __force 12; }; node_13(){ switch __no_tty 13; }; node_14(){
value __user 14; }; node_15(){ value _type_ a; }; node_16(){ value _app_ a; }
node_17(){ value _service_ a; }; node_18(){ value _src_ a; }; node_19(){
value _dst_ a; }; node_20(){ value _backup_file_ a; }; node_21(){
value _args_ a true; }; node_22(){ value _secret_ a; }; node_23(){
value _version_ a; }; node_24(){ value _cmd_ a; }; node_25(){ value _data_ a; }
node_26(){ value _command_ a; }; node_27(){ value _host_ a; }; node_28(){
value _user_ a; }; node_29(){ value _port_ a; }; node_30(){
value _subcommands_ a true; }; node_31(){ _command app; }; node_32(){
_command list; }; node_33(){ _command ls; }; node_34(){ _command new; }
node_35(){ _command backup; }; node_36(){ _command deploy; }; node_37(){
_command check; }; node_38(){ _command config; }; node_39(){ _command cp; }
node_40(){ _command logs; }; node_41(){ _command ps; }; node_42(){
_command restore; }; node_43(){ _command rm; }; node_44(){ _command delete; }
node_45(){ _command run; }; node_46(){ _command secret; }; node_47(){
_command auto; }; node_48(){ _command generate; }; node_49(){ _command insert; }
node_50(){ _command undeploy; }; node_51(){ _command server; }; node_52(){
_command add; }; node_53(){ _command init; }; node_54(){ _command apps; }
node_55(){ _command upgrade; }; node_56(){ _command version; }; node_57(){
_command help; }; node_58(){ optional 0 1 2 3 4; }; node_59(){ optional 58; }
node_60(){ either 32 33; }; node_61(){ required 60; }; node_62(){ optional 5; }
node_63(){ optional 6; }; node_64(){ required 59 31 61 62 63; }; node_65(){
optional 7; }; node_66(){ optional 8; }; node_67(){ optional 9; }; node_68(){
optional 10; }; node_69(){ required 59 31 34 63 65 66 67 68 15; }; node_70(){
either 17 11; }; node_71(){ required 70; }; node_72(){ required 59 31 16 35 71
}; node_73(){ required 59 31 16 36; }; node_74(){ required 59 31 16 37; }
node_75(){ required 59 31 16 38; }; node_76(){ required 59 31 16 39 18 19; }
node_77(){ optional 17; }; node_78(){ required 59 31 16 40 77; }; node_79(){
required 59 31 16 41; }; node_80(){ required 59 31 16 42 71; }; node_81(){
either 43 44; }; node_82(){ required 81; }; node_83(){ optional 12; }
node_84(){ required 59 31 16 82 83; }; node_85(){ optional 20; }; node_86(){
required 59 31 16 42 17 85; }; node_87(){ optional 13; }; node_88(){ optional 14
}; node_89(){ oneormore 21; }; node_90(){ required 59 31 16 45 87 88 17 89; }
node_91(){ required 59 31 16 46 47 67; }; node_92(){ optional 24; }; node_93(){
required 59 31 16 46 48 22 23 92 67; }; node_94(){
required 59 31 16 46 49 22 23 25 67; }; node_95(){ either 22 11; }; node_96(){
required 95; }; node_97(){ required 59 31 16 46 82 96 67 83; }; node_98(){
required 59 31 16 50; }; node_99(){ optional 89; }; node_100(){
required 59 31 16 26 99; }; node_101(){ optional 28; }; node_102(){ optional 29
}; node_103(){ required 59 51 52 27 101 102; }; node_104(){ required 59 51 61; }
node_105(){ required 59 51 27 43; }; node_106(){ required 59 51 27 53; }
node_107(){ required 59 51 27 54 62; }; node_108(){ required 59 55; }
node_109(){ required 59 56; }; node_110(){ oneormore 30; }; node_111(){
optional 110; }; node_112(){ required 59 57 111; }; node_113(){
either 64 69 72 73 74 75 76 78 79 80 84 86 90 91 93 94 97 98 100 103 104 105 106 107 108 109 112
}; node_114(){ required 113; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1357}" >&2
exit 1; }'; unset var___help var___skip_update var___env var___stack \
_command generate; }; node_48(){ _command insert; }; node_49(){
_command undeploy; }; node_50(){ _command server; }; node_51(){ _command add; }
node_52(){ _command init; }; node_53(){ _command apps; }; node_54(){
_command upgrade; }; node_55(){ _command version; }; node_56(){ _command help; }
node_57(){ optional 0 1 2 3 4; }; node_58(){ optional 57; }; node_59(){
either 32 33; }; node_60(){ required 59; }; node_61(){ optional 5; }; node_62(){
optional 6; }; node_63(){ required 58 31 60 61 62; }; node_64(){ optional 7; }
node_65(){ optional 8; }; node_66(){ optional 9; }; node_67(){ optional 10; }
node_68(){ required 58 31 34 62 64 65 66 67 15; }; node_69(){ either 17 11; }
node_70(){ required 69; }; node_71(){ required 58 31 16 35 70; }; node_72(){
required 58 31 16 36; }; node_73(){ required 58 31 16 37; }; node_74(){
required 58 31 16 38; }; node_75(){ required 58 31 16 39 18 19; }; node_76(){
optional 17; }; node_77(){ required 58 31 16 40 76; }; node_78(){
required 58 31 16 41; }; node_79(){ required 58 31 16 42 70; }; node_80(){
either 43 44; }; node_81(){ required 80; }; node_82(){ optional 12; }
node_83(){ required 58 31 16 81 82; }; node_84(){ optional 20; }; node_85(){
required 58 31 16 42 17 84; }; node_86(){ optional 13; }; node_87(){ optional 14
}; node_88(){ oneormore 21; }; node_89(){ required 58 31 16 45 86 87 17 88; }
node_90(){ required 22 23; }; node_91(){ either 90 11; }; node_92(){ required 91
}; node_93(){ optional 24; }; node_94(){ required 58 31 16 46 47 92 93 66; }
node_95(){ required 58 31 16 46 48 22 23 25 66; }; node_96(){ either 22 11; }
node_97(){ required 96; }; node_98(){ required 58 31 16 46 81 97 66 82; }
node_99(){ required 58 31 16 49; }; node_100(){ optional 88; }; node_101(){
required 58 31 16 26 100; }; node_102(){ optional 28; }; node_103(){ optional 29
}; node_104(){ required 58 50 51 27 102 103; }; node_105(){ required 58 50 60; }
node_106(){ required 58 50 27 43; }; node_107(){ required 58 50 27 52; }
node_108(){ required 58 50 27 53 61; }; node_109(){ required 58 54; }
node_110(){ required 58 55; }; node_111(){ oneormore 30; }; node_112(){
optional 111; }; node_113(){ required 58 56 112; }; node_114(){
either 63 68 71 72 73 74 75 77 78 79 83 85 89 94 95 98 99 101 104 105 106 107 108 109 110 113
}; node_115(){ required 114; }; cat <<<' docopt_exit() {
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1320}" >&2
exit 1; }'; unset var___help var___stack var___env var___skip_update \
var___skip_check var___status var___server var___domain var___app_name \
var___pass var___auto var___all var___force var___no_tty var___user var__type_ \
var__app_ var__service_ var__src_ var__dst_ var__backup_file_ var__args_ \
var__secret_ var__version_ var__cmd_ var__data_ var__command_ var__host_ \
var__user_ var__port_ var__subcommands_ var_app var_list var_ls var_new \
var_backup var_deploy var_check var_config var_cp var_logs var_ps var_restore \
var_rm var_delete var_run var_secret var_auto var_generate var_insert \
var___pass var___secrets var___all var___force var___no_tty var___user \
var__type_ var__app_ var__service_ var__src_ var__dst_ var__backup_file_ \
var__args_ var__secret_ var__version_ var__cmd_ var__data_ var__command_ \
var__host_ var__user_ var__port_ var__subcommands_ var_app var_list var_ls \
var_new var_backup var_deploy var_check var_config var_cp var_logs var_ps \
var_restore var_rm var_delete var_run var_secret var_generate var_insert \
var_undeploy var_server var_add var_init var_apps var_upgrade var_version \
var_help; parse 114 "$@"; local prefix=${DOCOPT_PREFIX:-''}
unset "${prefix}__help" "${prefix}__skip_update" "${prefix}__env" \
"${prefix}__stack" "${prefix}__skip_check" "${prefix}__status" \
var_help; parse 115 "$@"; local prefix=${DOCOPT_PREFIX:-''}
unset "${prefix}__help" "${prefix}__stack" "${prefix}__env" \
"${prefix}__skip_update" "${prefix}__skip_check" "${prefix}__status" \
"${prefix}__server" "${prefix}__domain" "${prefix}__app_name" \
"${prefix}__pass" "${prefix}__auto" "${prefix}__all" "${prefix}__force" \
"${prefix}__pass" "${prefix}__secrets" "${prefix}__all" "${prefix}__force" \
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \
@ -227,21 +227,20 @@ unset "${prefix}__help" "${prefix}__skip_update" "${prefix}__env" \
"${prefix}app" "${prefix}list" "${prefix}ls" "${prefix}new" "${prefix}backup" \
"${prefix}deploy" "${prefix}check" "${prefix}config" "${prefix}cp" \
"${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \
"${prefix}delete" "${prefix}run" "${prefix}secret" "${prefix}auto" \
"${prefix}generate" "${prefix}insert" "${prefix}undeploy" "${prefix}server" \
"${prefix}add" "${prefix}init" "${prefix}apps" "${prefix}upgrade" \
"${prefix}version" "${prefix}help"
eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__env=${var___env:-}'
"${prefix}delete" "${prefix}run" "${prefix}secret" "${prefix}generate" \
"${prefix}insert" "${prefix}undeploy" "${prefix}server" "${prefix}add" \
"${prefix}init" "${prefix}apps" "${prefix}upgrade" "${prefix}version" \
"${prefix}help"; eval "${prefix}"'__help=${var___help:-false}'
eval "${prefix}"'__stack=${var___stack:-}'
eval "${prefix}"'__env=${var___env:-}'
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
eval "${prefix}"'__status=${var___status:-false}'
eval "${prefix}"'__server=${var___server:-}'
eval "${prefix}"'__domain=${var___domain:-}'
eval "${prefix}"'__app_name=${var___app_name:-}'
eval "${prefix}"'__pass=${var___pass:-false}'
eval "${prefix}"'__auto=${var___auto:-false}'
eval "${prefix}"'__secrets=${var___secrets:-false}'
eval "${prefix}"'__all=${var___all:-false}'
eval "${prefix}"'__force=${var___force:-false}'
eval "${prefix}"'__no_tty=${var___no_tty:-false}'
@ -275,7 +274,6 @@ eval "${prefix}"'rm=${var_rm:-false}'
eval "${prefix}"'delete=${var_delete:-false}'
eval "${prefix}"'run=${var_run:-false}'
eval "${prefix}"'secret=${var_secret:-false}'
eval "${prefix}"'auto=${var_auto:-false}'
eval "${prefix}"'generate=${var_generate:-false}'
eval "${prefix}"'insert=${var_insert:-false}'
eval "${prefix}"'undeploy=${var_undeploy:-false}'
@ -287,10 +285,10 @@ eval "${prefix}"'upgrade=${var_upgrade:-false}'
eval "${prefix}"'version=${var_version:-false}'
eval "${prefix}"'help=${var_help:-false}'; local docopt_i=1
[[ $BASH_VERSION =~ ^4.3 ]] && docopt_i=2; for ((;docopt_i>0;docopt_i--)); do
declare -p "${prefix}__help" "${prefix}__skip_update" "${prefix}__env" \
"${prefix}__stack" "${prefix}__skip_check" "${prefix}__status" \
declare -p "${prefix}__help" "${prefix}__stack" "${prefix}__env" \
"${prefix}__skip_update" "${prefix}__skip_check" "${prefix}__status" \
"${prefix}__server" "${prefix}__domain" "${prefix}__app_name" \
"${prefix}__pass" "${prefix}__auto" "${prefix}__all" "${prefix}__force" \
"${prefix}__pass" "${prefix}__secrets" "${prefix}__all" "${prefix}__force" \
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
"${prefix}_backup_file_" "${prefix}_args_" "${prefix}_secret_" \
@ -299,10 +297,10 @@ declare -p "${prefix}__help" "${prefix}__skip_update" "${prefix}__env" \
"${prefix}app" "${prefix}list" "${prefix}ls" "${prefix}new" "${prefix}backup" \
"${prefix}deploy" "${prefix}check" "${prefix}config" "${prefix}cp" \
"${prefix}logs" "${prefix}ps" "${prefix}restore" "${prefix}rm" \
"${prefix}delete" "${prefix}run" "${prefix}secret" "${prefix}auto" \
"${prefix}generate" "${prefix}insert" "${prefix}undeploy" "${prefix}server" \
"${prefix}add" "${prefix}init" "${prefix}apps" "${prefix}upgrade" \
"${prefix}version" "${prefix}help"; done; }
"${prefix}delete" "${prefix}run" "${prefix}secret" "${prefix}generate" \
"${prefix}insert" "${prefix}undeploy" "${prefix}server" "${prefix}add" \
"${prefix}init" "${prefix}apps" "${prefix}upgrade" "${prefix}version" \
"${prefix}help"; done; }
# docopt parser above, complete command for generating this parser is `docopt.sh abra`
PROGRAM_NAME=$(basename "$0")
@ -408,18 +406,8 @@ get_servers() {
}
get_app_secrets() {
get_app_passwords
get_app_keys
}
get_app_passwords() {
# FIXME 3wc: requires bash 4, use for loop instead
mapfile -t PASSWORDS < <(grep "SECRET.*PASSWORD.*VERSION.*" "$ENV_FILE")
}
get_app_keys() {
# FIXME 3wc: requires bash 4, use for loop instead
mapfile -t KEYS < <(grep "SECRET.*KEY.*VERSION.*" "$ENV_FILE")
mapfile -t PASSWORDS < <(grep "SECRET.*VERSION.*" "$ENV_FILE")
}
load_instance() {
@ -480,7 +468,9 @@ parse_secret() {
# shellcheck disable=SC2001
abra__length_="$(echo "$SECRET" | sed -e 's/.*[^0-9]\([0-9]\+\)[^0-9]*$/\1/')"
else
abra__length_=32
# Note(decentral1se): unset this so that a length value from another secret
# definition does not get passed on to another secret generation flow
unset abra__length_
fi
abra__secret_="${SECRET%_VERSION=*}" # strip _VERSION=v1
@ -489,7 +479,7 @@ parse_secret() {
abra__version_="$(echo "$SECRET" | sed -n 's/.*\(v[0-9]\).*/\1/p')"
if [[ "$SECRET" == *"length"* ]]; then
if [[ -n "$abra__length_" ]]; then
echo "Generating $abra__secret_, version: $abra__version_, length: $abra__length_"
else
echo "Generating $abra__secret_, version: $abra__version_"
@ -514,6 +504,14 @@ stack_logs (){
sleep infinity
}
auto_gen_secrets (){
get_app_secrets
for PASSWORD in "${PASSWORDS[@]}"; do
parse_secret "$PASSWORD"
done
}
#######################################
# abra app ..
#######################################
@ -682,8 +680,8 @@ sub_app_new (){
get_app_secrets
if [ "${#PASSWORDS[@]}" -gt 0 ] || [ "${#KEYS[@]}" -gt 0 ] && [ "$abra___auto" == "true" ]; then
sub_app_secret_auto
if [ "${#PASSWORDS[@]}" -gt 0 ] && [ "$abra___secrets" == "true" ]; then
auto_gen_secrets
fi
echo "$(tput setaf 4)Your new '$TYPE' is ready for action:$(tput sgr0)"
@ -1015,15 +1013,23 @@ sub_app_secret_generate(){
VERSION="$abra__version_"
LENGTH="$abra__length_"
if [[ "$SECRET" == *"password"* ]]; then
require_pwqgen
PWGEN="${abra__cmd_:-pwqgen}"
else
require_pwgen
PWGEN=${abra__cmd_:-pwgen -s "$LENGTH" 1}
if [ "$abra___all" == "true" ]; then
# Note(decentral1se): we need to reset the flag here to avoid the infinite
# recursion of auto_gen_secrets which calls this function itself
abra___all="false"
auto_gen_secrets
fi
if [ -z "$SECRET" ] || [ -z "$VERSION" ]; then
if [[ -n "$LENGTH" ]]; then
require_pwgen
PWGEN=${abra__cmd_:-pwgen -s "$LENGTH" 1}
else
require_pwqgen
PWGEN="${abra__cmd_:-pwqgen}"
fi
if [ -z "$SECRET" ] || [ -z "$VERSION" ] && [ "$abra___all" == "false" ]; then
error "Required arguments missing"
fi
@ -1038,21 +1044,6 @@ sub_app_secret_generate(){
sub_app_secret_insert
}
sub_app_secret_auto(){
load_instance
load_instance_env
get_app_secrets
for PASSWORD in "${PASSWORDS[@]}"; do
parse_secret "$PASSWORD"
done
for KEY in "${KEYS[@]}"; do
parse_secret "$KEY"
done
}
###### .. app run
help_app_run (){
echo "abra [options] app <app> run [--no-tty] [--user=<user>] <service> <args>...
@ -1062,7 +1053,7 @@ container.
OPTIONS
--no-tty Don't allocate a TTY; sometimes running \`mysql\` enjoys this
--user=<user> Run as the UNIX user <user>, e.g. for running Wordpress-CLI
--user=<user> Run as the UNIX user <user>, e.g. for running Wordpress-CLI
as www-data
EXAMPLES
@ -1410,7 +1401,7 @@ abra() {
abra__secret_ abra__version_ abra__data_ abra___user abra__host_ \
abra__type_ abra__port_ abra__user_ abra__service_ abra__src_ abra__dst_ \
abra___server abra___domain abra___force abra___pass \
abra___auto abra___status abra___no_tty abra___app_name \
abra___secrets abra___status abra___no_tty abra___app_name \
abra__subcommands_ abra___skip_update abra___skip_check \
abra__backup_file_