Compare commits
21 Commits
backup_res
...
0.5.0
Author | SHA1 | Date | |
---|---|---|---|
5bc702bf96 | |||
4bd842db66 | |||
a8f7faddb9 | |||
e5b2a426f0 | |||
29b22fe162 | |||
c082645da0 | |||
156d5d8fba | |||
d2cdb11fcc | |||
cef06a82a6 | |||
9a630a0440 | |||
1c6651b18b | |||
5f7df4694f | |||
7feeab24ec | |||
1a6688cfbf | |||
f90e1d154c | |||
6cc265e931 | |||
854ae23f60 | |||
43e7672725 | |||
4e913c426d | |||
8a08de51e4 | |||
1c7a51bce1 |
12
.drone.yml
12
.drone.yml
@ -26,6 +26,18 @@ steps:
|
||||
from_secret: codecov_token
|
||||
required: true
|
||||
|
||||
- name: notify rocket chat
|
||||
image: plugins/slack
|
||||
settings:
|
||||
webhook:
|
||||
from_secret: rc_builds_url
|
||||
username: comradebritney
|
||||
channel: "internal.builds"
|
||||
template: "{{repo.owner}}/{{repo.name}} build failed: {{build.link}}"
|
||||
when:
|
||||
status:
|
||||
- failure
|
||||
|
||||
trigger:
|
||||
branch:
|
||||
- main
|
||||
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,5 +1,7 @@
|
||||
# abra x.x.x (UNRELEASED)
|
||||
|
||||
# abra 0.5.0 (2021-03-01)
|
||||
|
||||
- `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 ([44d3ac3](https://git.autonomic.zone/coop-cloud/abra/commit/44d3ac3a1cb86edc9b9e91eea1a00e70eae14965))
|
||||
@ -17,10 +19,10 @@
|
||||
- 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
|
||||
[#70](https://git.autonomic.zone/coop-cloud/abra/issues/70)
|
||||
- Global `--skip-update|-U` / `--skip-check|-C` 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 ([#70](https://git.autonomic.zone/coop-cloud/abra/issues/70))
|
||||
- Rename per-type `abra-commands.sh` to `abra.sh`, and include config versions as type-level instead of app-level config ([#43](https://git.autonomic.zone/coop-cloud/abra/issues/43))
|
||||
- Show per-subcommand help by adding `-h/--help` to a command line ([#38](https://git.autonomic.zone/coop-cloud/abra/issues/78))
|
||||
|
||||
# abra 0.4.1 (2020-12-24)
|
||||
|
||||
|
369
abra
369
abra
@ -2,7 +2,8 @@
|
||||
|
||||
GIT_URL="https://git.autonomic.zone/coop-cloud/"
|
||||
ABRA_DIR="${ABRA_DIR:-$HOME/.abra}"
|
||||
ABRA_VERSION="0.4.1"
|
||||
ABRA_VERSION="0.5.0"
|
||||
ABRA_BACKUP_DIR="${ABRA_BACKUP_DIR:-$ABRA_DIR/backups}"
|
||||
|
||||
#######################################
|
||||
# Global help
|
||||
@ -38,13 +39,16 @@ Usage:
|
||||
abra [options] upgrade
|
||||
abra [options] version
|
||||
abra [options] help [<subcommands>...]
|
||||
abra [options]
|
||||
|
||||
Options:
|
||||
-e, --env=<path> Environment variables to load
|
||||
-h, --help Show this message and exit
|
||||
-s, --stack=<stack> Name of the target stack
|
||||
-C, --skip-check Don't verify app variables
|
||||
-U, --skip-update Don't pull latest app definitions
|
||||
-C, --skip-check Don't verify app variables
|
||||
-U, --skip-update Don't pull latest app definitions
|
||||
-v, --verbose Show INFO messages
|
||||
-d, --debug Show DEBUG messages
|
||||
|
||||
See 'abra help <subcommands>...' to read about a specific subcommand.
|
||||
"
|
||||
@ -148,79 +152,81 @@ 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: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 __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 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___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 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}__secrets" "${prefix}__all" "${prefix}__force" \
|
||||
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
|
||||
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
|
||||
printf -- "exit %d\n" "$1"; exit "$1"; }; set -e; trimmed_doc=${DOC:1:1800}
|
||||
usage=${DOC:40:1337}; digest=55732
|
||||
shorts=(-U -h -e -v -s -C -d '' '' '' '' '' '' '' '' '' '')
|
||||
longs=(--skip-update --help --env --verbose --stack --skip-check --debug --status --server --domain --app-name --pass --secrets --all --force --no-tty --user)
|
||||
argcounts=(0 0 1 0 1 0 0 0 1 1 1 0 0 0 0 0 1); node_0(){ switch __skip_update 0
|
||||
}; node_1(){ switch __help 1; }; node_2(){ value __env 2; }; node_3(){
|
||||
switch __verbose 3; }; node_4(){ value __stack 4; }; node_5(){
|
||||
switch __skip_check 5; }; node_6(){ switch __debug 6; }; node_7(){
|
||||
switch __status 7; }; node_8(){ value __server 8; }; node_9(){ value __domain 9
|
||||
}; node_10(){ value __app_name 10; }; node_11(){ switch __pass 11; }; node_12(){
|
||||
switch __secrets 12; }; node_13(){ switch __all 13; }; node_14(){
|
||||
switch __force 14; }; node_15(){ switch __no_tty 15; }; node_16(){
|
||||
value __user 16; }; node_17(){ value _type_ a; }; node_18(){ value _app_ a; }
|
||||
node_19(){ value _service_ a; }; node_20(){ value _src_ a; }; node_21(){
|
||||
value _dst_ a; }; node_22(){ value _backup_file_ a; }; node_23(){
|
||||
value _args_ a true; }; node_24(){ value _secret_ a; }; node_25(){
|
||||
value _version_ a; }; node_26(){ value _cmd_ a; }; node_27(){ value _data_ a; }
|
||||
node_28(){ value _command_ a; }; node_29(){ value _host_ a; }; node_30(){
|
||||
value _user_ a; }; node_31(){ value _port_ a; }; node_32(){
|
||||
value _subcommands_ a true; }; node_33(){ _command app; }; node_34(){
|
||||
_command list; }; node_35(){ _command ls; }; node_36(){ _command new; }
|
||||
node_37(){ _command backup; }; node_38(){ _command deploy; }; node_39(){
|
||||
_command check; }; node_40(){ _command config; }; node_41(){ _command cp; }
|
||||
node_42(){ _command logs; }; node_43(){ _command ps; }; node_44(){
|
||||
_command restore; }; node_45(){ _command rm; }; node_46(){ _command delete; }
|
||||
node_47(){ _command run; }; node_48(){ _command secret; }; node_49(){
|
||||
_command generate; }; node_50(){ _command insert; }; node_51(){
|
||||
_command undeploy; }; node_52(){ _command server; }; node_53(){ _command add; }
|
||||
node_54(){ _command init; }; node_55(){ _command apps; }; node_56(){
|
||||
_command upgrade; }; node_57(){ _command version; }; node_58(){ _command help; }
|
||||
node_59(){ optional 0 1 2 3 4 5 6; }; node_60(){ optional 59; }; node_61(){
|
||||
either 34 35; }; node_62(){ required 61; }; node_63(){ optional 7; }; node_64(){
|
||||
optional 8; }; node_65(){ required 60 33 62 63 64; }; node_66(){ optional 9; }
|
||||
node_67(){ optional 10; }; node_68(){ optional 11; }; node_69(){ optional 12; }
|
||||
node_70(){ required 60 33 36 64 66 67 68 69 17; }; node_71(){ either 19 13; }
|
||||
node_72(){ required 71; }; node_73(){ required 60 33 18 37 72; }; node_74(){
|
||||
required 60 33 18 38; }; node_75(){ required 60 33 18 39; }; node_76(){
|
||||
required 60 33 18 40; }; node_77(){ required 60 33 18 41 20 21; }; node_78(){
|
||||
optional 19; }; node_79(){ required 60 33 18 42 78; }; node_80(){
|
||||
required 60 33 18 43; }; node_81(){ required 60 33 18 44 72; }; node_82(){
|
||||
either 45 46; }; node_83(){ required 82; }; node_84(){ optional 14; }
|
||||
node_85(){ required 60 33 18 83 84; }; node_86(){ optional 22; }; node_87(){
|
||||
required 60 33 18 44 19 86; }; node_88(){ optional 15; }; node_89(){ optional 16
|
||||
}; node_90(){ oneormore 23; }; node_91(){ required 60 33 18 47 88 89 19 90; }
|
||||
node_92(){ required 24 25; }; node_93(){ either 92 13; }; node_94(){ required 93
|
||||
}; node_95(){ optional 26; }; node_96(){ required 60 33 18 48 49 94 95 68; }
|
||||
node_97(){ required 60 33 18 48 50 24 25 27 68; }; node_98(){ either 24 13; }
|
||||
node_99(){ required 98; }; node_100(){ required 60 33 18 48 83 99 68 84; }
|
||||
node_101(){ required 60 33 18 51; }; node_102(){ optional 90; }; node_103(){
|
||||
required 60 33 18 28 102; }; node_104(){ optional 30; }; node_105(){ optional 31
|
||||
}; node_106(){ required 60 52 53 29 104 105; }; node_107(){ required 60 52 62; }
|
||||
node_108(){ required 60 52 29 45; }; node_109(){ required 60 52 29 54; }
|
||||
node_110(){ required 60 52 29 55 63; }; node_111(){ required 60 56; }
|
||||
node_112(){ required 60 57; }; node_113(){ oneormore 32; }; node_114(){
|
||||
optional 113; }; node_115(){ required 60 58 114; }; node_116(){ required 60; }
|
||||
node_117(){
|
||||
either 65 70 73 74 75 76 77 79 80 81 85 87 91 96 97 100 101 103 106 107 108 109 110 111 112 115 116
|
||||
}; node_118(){ required 117; }; cat <<<' docopt_exit() {
|
||||
[[ -n $1 ]] && printf "%s\n" "$1" >&2; printf "%s\n" "${DOC:40:1337}" >&2
|
||||
exit 1; }'; unset var___skip_update var___help var___env var___verbose \
|
||||
var___stack var___skip_check var___debug var___status var___server \
|
||||
var___domain var___app_name 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 118 "$@"; local prefix=${DOCOPT_PREFIX:-''}
|
||||
unset "${prefix}__skip_update" "${prefix}__help" "${prefix}__env" \
|
||||
"${prefix}__verbose" "${prefix}__stack" "${prefix}__skip_check" \
|
||||
"${prefix}__debug" "${prefix}__status" "${prefix}__server" "${prefix}__domain" \
|
||||
"${prefix}__app_name" "${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_" \
|
||||
"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \
|
||||
"${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_subcommands_" \
|
||||
@ -230,11 +236,13 @@ unset "${prefix}__help" "${prefix}__stack" "${prefix}__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:-}'
|
||||
"${prefix}help"; eval "${prefix}"'__skip_update=${var___skip_update:-false}'
|
||||
eval "${prefix}"'__help=${var___help:-false}'
|
||||
eval "${prefix}"'__env=${var___env:-}'
|
||||
eval "${prefix}"'__skip_update=${var___skip_update:-false}'
|
||||
eval "${prefix}"'__verbose=${var___verbose:-false}'
|
||||
eval "${prefix}"'__stack=${var___stack:-}'
|
||||
eval "${prefix}"'__skip_check=${var___skip_check:-false}'
|
||||
eval "${prefix}"'__debug=${var___debug:-false}'
|
||||
eval "${prefix}"'__status=${var___status:-false}'
|
||||
eval "${prefix}"'__server=${var___server:-}'
|
||||
eval "${prefix}"'__domain=${var___domain:-}'
|
||||
@ -285,12 +293,12 @@ 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}__stack" "${prefix}__env" \
|
||||
"${prefix}__skip_update" "${prefix}__skip_check" "${prefix}__status" \
|
||||
"${prefix}__server" "${prefix}__domain" "${prefix}__app_name" \
|
||||
"${prefix}__pass" "${prefix}__secrets" "${prefix}__all" "${prefix}__force" \
|
||||
"${prefix}__no_tty" "${prefix}__user" "${prefix}_type_" "${prefix}_app_" \
|
||||
"${prefix}_service_" "${prefix}_src_" "${prefix}_dst_" \
|
||||
declare -p "${prefix}__skip_update" "${prefix}__help" "${prefix}__env" \
|
||||
"${prefix}__verbose" "${prefix}__stack" "${prefix}__skip_check" \
|
||||
"${prefix}__debug" "${prefix}__status" "${prefix}__server" "${prefix}__domain" \
|
||||
"${prefix}__app_name" "${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_" \
|
||||
"${prefix}_version_" "${prefix}_cmd_" "${prefix}_data_" "${prefix}_command_" \
|
||||
"${prefix}_host_" "${prefix}_user_" "${prefix}_port_" "${prefix}_subcommands_" \
|
||||
@ -324,6 +332,36 @@ success() {
|
||||
echo "$(tput setaf 2)SUCCESS: $*$(tput sgr0)"
|
||||
}
|
||||
|
||||
info() {
|
||||
if [ "$abra___verbose" = "false" ] && [ "$abra___debug" = "false" ]; then
|
||||
return
|
||||
fi
|
||||
echo "$(tput setaf 4)INFO: $*$(tput sgr0)"
|
||||
}
|
||||
|
||||
debug() {
|
||||
if [ "$abra___debug" = "false" ]; then
|
||||
return
|
||||
fi
|
||||
echo "$(tput setaf 13)DEBUG: $*$(tput sgr0)"
|
||||
}
|
||||
|
||||
# 3wc: temporarily disable debug and verbose
|
||||
|
||||
silence() {
|
||||
# FIXME 3wc: required otherwise we get debug output in the password
|
||||
_abra___debug="$abra___debug"
|
||||
_abra___verbose="$abra___verbose"
|
||||
abra___verbose="false"
|
||||
abra___debug="false"
|
||||
}
|
||||
|
||||
unsilence() {
|
||||
# FIXME 3wc: required otherwise we get debug output in the password
|
||||
abra___verbose="$_abra___verbose"
|
||||
abra___debug="$_abra___debug"
|
||||
}
|
||||
|
||||
###### Default settings
|
||||
|
||||
if [ -z "$COMPOSE_FILE" ]; then
|
||||
@ -358,6 +396,8 @@ require_app_latest() {
|
||||
APP="$1"
|
||||
APP_DIR="$ABRA_DIR/apps/$APP"
|
||||
|
||||
debug "Checking for type '$APP'"
|
||||
|
||||
if [ ! -d "$APP_DIR" ]; then
|
||||
warning "The app type '$APP' was not found, fetching via Git"
|
||||
if ! git clone "$GIT_URL/$APP.git" "$ABRA_DIR/apps/$APP" > /dev/null 2>&1 ; then
|
||||
@ -366,8 +406,10 @@ require_app_latest() {
|
||||
success "Fetched app configuration via Git"
|
||||
fi
|
||||
|
||||
debug "Using $APP_DIR"
|
||||
|
||||
if [ "$abra___skip_update" = "false" ]; then
|
||||
cd "$APP_DIR" && git pull > /dev/null 2>&1
|
||||
(cd "$APP_DIR" && git pull > /dev/null 2>&1)
|
||||
fi
|
||||
}
|
||||
|
||||
@ -378,10 +420,11 @@ fi
|
||||
|
||||
###### Run-time loading
|
||||
|
||||
load_custom_commands() {
|
||||
if [ -f abra-commands.sh ]; then
|
||||
load_abra_sh() {
|
||||
if [ -f abra.sh ]; then
|
||||
# shellcheck disable=SC1091
|
||||
source abra-commands.sh
|
||||
source abra.sh
|
||||
info "Loading abra.sh"
|
||||
fi
|
||||
|
||||
if [ -n "$abra__app_" ]; then
|
||||
@ -390,9 +433,10 @@ load_custom_commands() {
|
||||
require_app_latest "$TYPE"
|
||||
fi
|
||||
|
||||
if [ -f "$APP_DIR/abra-commands.sh" ]; then
|
||||
if [ -f "$APP_DIR/abra.sh" ]; then
|
||||
info "Loading $APP_DIR/abra.sh"
|
||||
# shellcheck disable=SC1090,SC1091
|
||||
source "$APP_DIR/abra-commands.sh"
|
||||
source "$APP_DIR/abra.sh"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -412,33 +456,48 @@ get_app_secrets() {
|
||||
|
||||
load_instance() {
|
||||
APP="$abra__app_"
|
||||
# FIXME 3wc: requires bash 4, use for loop instead
|
||||
|
||||
# load all files matching "$APP.env" into ENV_FILES array
|
||||
mapfile -t ENV_FILES < <(find -L "$ABRA_DIR" -name "$APP.env")
|
||||
# FIXME 3wc: requires bash 4, use for loop instead
|
||||
|
||||
case "${#ENV_FILES[@]}" in
|
||||
1 ) ;;
|
||||
0 ) error "Can't find app '$APP'"; return;;
|
||||
* ) error "Found $APP in multiple servers: ${ENV_FILES[*]}"; return;;
|
||||
esac
|
||||
|
||||
ENV_FILE="${ENV_FILES[0]}"
|
||||
debug "Selected ENV_FILE $ENV_FILE"
|
||||
|
||||
if [ ! -f "$ENV_FILE" ]; then
|
||||
error "Can't open ENV_FILE '$ENV_FILE'"
|
||||
fi
|
||||
|
||||
# split up the path by "/"
|
||||
IFS='/' read -r -a PARTS <<< "$ENV_FILE"
|
||||
|
||||
SERVER="${PARTS[-2]}"
|
||||
export STACK_NAME="$APP"
|
||||
export STACK_NAME="${APP//./_}"
|
||||
}
|
||||
|
||||
load_instance_env() {
|
||||
# 3wc: using set -a means we don't need `export` in the env files
|
||||
set -a
|
||||
# shellcheck disable=SC1090
|
||||
source "$ENV_FILE"
|
||||
set +a
|
||||
|
||||
debug "Loaded variables from $ENV_FILE"
|
||||
|
||||
if [ -z "$TYPE" ]; then
|
||||
error "TYPE not set, maybe $ENV_FILE is using an old format?"
|
||||
fi
|
||||
|
||||
APP_DIR="$ABRA_DIR/apps/$TYPE"
|
||||
export DOCKER_CONTEXT="$SERVER"
|
||||
info "Setting DOCKER_CONTEXT=$DOCKER_CONTEXT"
|
||||
|
||||
export DOMAIN
|
||||
}
|
||||
|
||||
@ -507,6 +566,10 @@ stack_logs (){
|
||||
auto_gen_secrets (){
|
||||
get_app_secrets
|
||||
|
||||
if [ "${#PASSWORDS[@]}" -eq 0 ]; then
|
||||
error "No secrets found in $ENV_FILE"
|
||||
fi
|
||||
|
||||
for PASSWORD in "${PASSWORDS[@]}"; do
|
||||
parse_secret "$PASSWORD"
|
||||
done
|
||||
@ -680,7 +743,10 @@ sub_app_new (){
|
||||
|
||||
get_app_secrets
|
||||
|
||||
if [ "${#PASSWORDS[@]}" -gt 0 ] && [ "$abra___secrets" == "true" ]; then
|
||||
if [ "$abra___secrets" == "true" ]; then
|
||||
if [ "${#PASSWORDS[@]}" -eq 0 ]; then
|
||||
warning "--secrets provided but no secrets found"
|
||||
fi
|
||||
auto_gen_secrets
|
||||
fi
|
||||
|
||||
@ -728,11 +794,78 @@ sub_app_restore (){
|
||||
$FUNCTION "$abra__backup_file_"
|
||||
}
|
||||
|
||||
###### backup utility functions
|
||||
|
||||
# Usage: _abra_backup_dir service:/path/to/src
|
||||
_abra_backup_dir() {
|
||||
{
|
||||
abra__src_="$1"
|
||||
abra__dst_="-"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
FILENAME="$ABRA_BACKUP_DIR/${abra__app_}_$(basename "$1")_$(date +%F).tar.gz"
|
||||
|
||||
debug "Copying '$1' to '$FILENAME'"
|
||||
|
||||
silence
|
||||
sub_app_cp | gzip > "$FILENAME"
|
||||
success "Backed up '$1' to $FILENAME"
|
||||
unsilence
|
||||
}
|
||||
|
||||
_abra_backup_db_prep() {
|
||||
# shellcheck disable=SC2034
|
||||
abra__service_="$1"
|
||||
# 3wc: necessary because $abra__service_ won't be set if we're coming from
|
||||
# `abra_backup`, i.e. `abra app ... backup --all`
|
||||
|
||||
# What's the name of the Docker secret? Default to db_root_password
|
||||
DB_PASSWORD_NAME=${4:-db_root_password}
|
||||
|
||||
debug "Looking up secret '$DB_PASSWORD_NAME'"
|
||||
silence
|
||||
DB_PASSWORD="$(sub_app_run cat "/run/secrets/$DB_PASSWORD_NAME")"
|
||||
unsilence
|
||||
|
||||
# 3wc: strip newline \r from variable
|
||||
DB_PASSWORD="${DB_PASSWORD//$'\015'}"
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
FILENAME="$ABRA_BACKUP_DIR/${abra__app_}_$(date +%F).sql.gz"
|
||||
}
|
||||
|
||||
# usage: _abra_backup_postgres <service> <database> [<user> <secret name>]
|
||||
_abra_backup_postgres() {
|
||||
_abra_backup_db_prep "$@"
|
||||
|
||||
debug "Running pg_dump to '$FILENAME'"
|
||||
|
||||
silence
|
||||
# shellcheck disable=SC2034
|
||||
PGPASSWORD="$DB_PASSWORD"
|
||||
sub_app_run pg_dump -U "${3:-postgres}" "$2" | gzip > "$FILENAME"
|
||||
unsilence
|
||||
|
||||
success "Backed up '$abra__service_:$2' to '$FILENAME'"
|
||||
}
|
||||
|
||||
_abra_backup_mysql() {
|
||||
_abra_backup_db_prep "$@"
|
||||
|
||||
silence
|
||||
# shellcheck disable=SC2086
|
||||
sub_app_run mysqldump -u root -p"${DB_PASSWORD}" "$2" | gzip > "$FILENAME"
|
||||
unsilence
|
||||
|
||||
success "Backed up '$abra__service_:$2' to $FILENAME"
|
||||
}
|
||||
|
||||
###### .. app deploy
|
||||
help_app_deploy (){
|
||||
echo "abra [options] app <domain> deploy [--skip-check]
|
||||
echo "abra [options] app <app> deploy [--skip-check]
|
||||
|
||||
Deploy app <domain> to the configured server.
|
||||
Deploy app <app> to the configured server.
|
||||
|
||||
POWERED BY
|
||||
docker stack deploy -c compose.yml <app>"
|
||||
@ -766,9 +899,9 @@ sub_app_deploy (){
|
||||
APP=$(basename "$APP_DIR")
|
||||
|
||||
(
|
||||
cd "$APP_DIR" || error "\$APP_DIR '$APP_DIR' not found"
|
||||
(cd "$APP_DIR" || error "\$APP_DIR '$APP_DIR' not found")
|
||||
# shellcheck disable=SC2086
|
||||
if docker stack deploy -c ${COMPOSE_FILE//:/ -c } "$STACK_NAME"; then
|
||||
if (cd "$APP_DIR" && docker stack deploy -c ${COMPOSE_FILE//:/ -c } "$STACK_NAME"); then
|
||||
if [ -n "$DOMAIN" ]; then
|
||||
success "Yay! App should be available at https://${DOMAIN}"
|
||||
else
|
||||
@ -780,7 +913,7 @@ sub_app_deploy (){
|
||||
)
|
||||
}
|
||||
|
||||
###### .. app <domain> undeploy
|
||||
###### .. app <app> undeploy
|
||||
help_app_undeploy (){
|
||||
echo "abra [options] app <app> undeploy
|
||||
|
||||
@ -853,8 +986,12 @@ sub_app_check (){
|
||||
load_instance
|
||||
load_instance_env
|
||||
|
||||
APP_ENV=$(grep -v '^#' "$ENV_FILE" | cut -d' ' -f2 | cut -d'=' -f1 | sort)
|
||||
STACK_ENV=$(grep -v '^#' "$APP_DIR/.env.sample" | cut -d' ' -f2 | cut -d'=' -f1 | sort)
|
||||
APP_ENV=$(grep -v '^#' "$ENV_FILE" | cut -d' ' -f2 | cut -d'=' -f1 | sort -u)
|
||||
STACK_ENV=$(grep -v '^#' "$APP_DIR/.env.sample" | cut -d' ' -f2 | cut -d'=' -f1 | sort -u)
|
||||
|
||||
debug "APP_ENV: $APP_ENV"
|
||||
|
||||
debug "STACK_ENV: $STACK_ENV"
|
||||
|
||||
# Only show "1", items in STACK_ENV which aren't in APP_ENV
|
||||
MISSING_VARS=$(comm -23 <(echo "$STACK_ENV") <(echo "$APP_ENV"))
|
||||
@ -996,11 +1133,14 @@ sub_app_secret_delete(){
|
||||
|
||||
###### .. app secret generate
|
||||
help_app_secret_generate (){
|
||||
echo "abra [options] app <app> secret generate <secret> <version> [<cmd>] [--pass]
|
||||
echo "abra [options] app <app> secret generate (<secret> <version>|--all) [<cmd>] [--pass]
|
||||
|
||||
Generate <secret>_<version> for <app> and store as a Docker secret.
|
||||
|
||||
OPTIONS
|
||||
<secret> Generate a single secret
|
||||
<version> Specify secret version (for single secret)
|
||||
--all Auto-generate all secrets
|
||||
<cmd> Run <cmd> to generate secret (default: pwqgen)
|
||||
--pass Save generated secrets in \`pass\`"
|
||||
}
|
||||
@ -1019,6 +1159,7 @@ sub_app_secret_generate(){
|
||||
abra___all="false"
|
||||
|
||||
auto_gen_secrets
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -n "$LENGTH" ]]; then
|
||||
@ -1029,6 +1170,8 @@ sub_app_secret_generate(){
|
||||
PWGEN="${abra__cmd_:-pwqgen}"
|
||||
fi
|
||||
|
||||
echo "SECRET: $SECRET, VERSION $VERSION, PW $PW, ALL $abra___all"
|
||||
|
||||
if [ -z "$SECRET" ] || [ -z "$VERSION" ] && [ "$abra___all" == "false" ]; then
|
||||
error "Required arguments missing"
|
||||
fi
|
||||
@ -1086,6 +1229,8 @@ sub_app_run(){
|
||||
exit
|
||||
fi
|
||||
|
||||
debug "Using Container ID ${CONTAINER}"
|
||||
|
||||
# 3wc: we want the "splitting" that shellcheck warns us about, so that -u and
|
||||
# $RUN_USER aren't treated as a single argument:
|
||||
# shellcheck disable=SC2086
|
||||
@ -1189,6 +1334,8 @@ sub_app_cp() {
|
||||
exit
|
||||
fi
|
||||
|
||||
debug "Using Container ID ${CONTAINER}"
|
||||
|
||||
# Replace $SERVICE with $CONTAINER in the original args
|
||||
CP_ARGS=$(echo "$SOURCE $DEST" | sed "s/$SERVICE:/$CONTAINER:/")
|
||||
# FIXME 3wc: this might cause problems for filenames with spaces..
|
||||
@ -1403,7 +1550,7 @@ abra() {
|
||||
abra___server abra___domain abra___force abra___pass \
|
||||
abra___secrets abra___status abra___no_tty abra___app_name \
|
||||
abra__subcommands_ abra___skip_update abra___skip_check \
|
||||
abra__backup_file_
|
||||
abra__backup_file_ abra___verbose abra___debug abra___help
|
||||
|
||||
if ! type tput > /dev/null 2>&1; then
|
||||
tput() {
|
||||
@ -1412,6 +1559,7 @@ abra() {
|
||||
fi
|
||||
|
||||
DOCOPT_PREFIX=abra_
|
||||
DOCOPT_ADD_HELP=false
|
||||
eval "$(docopt "$@")"
|
||||
|
||||
# --stack <stack>
|
||||
@ -1425,7 +1573,7 @@ abra() {
|
||||
set +a
|
||||
fi
|
||||
|
||||
load_custom_commands
|
||||
load_abra_sh
|
||||
|
||||
# Search for sub_* functions, and check if any of them matches enabled
|
||||
# arguments (i.e. is a command and is specified)
|
||||
@ -1442,6 +1590,19 @@ abra() {
|
||||
break
|
||||
done
|
||||
|
||||
if [ "$abra___help" = "true" ]; then
|
||||
if [ -z "$abra__command_" ]; then
|
||||
# shellcheck disable=SC2059
|
||||
printf "$DOC"
|
||||
exit
|
||||
elif type "help_${abra__command_}" > /dev/null 2>&1; then
|
||||
"help_${abra__command_}"
|
||||
exit
|
||||
else
|
||||
error "No help for '$abra__command_'"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Use abra__command_ in case `command` is provided (i.e. `volume` or `stack`)
|
||||
CMD="sub_${abra__command_}"
|
||||
if type "$CMD" > /dev/null 2>&1; then
|
||||
|
@ -1,13 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
ABRA_VERSION="0.4.1"
|
||||
ABRA_VERSION="0.5.0"
|
||||
ABRA_SRC="https://git.autonomic.zone/coop-cloud/abra/raw/tag/$ABRA_VERSION/abra"
|
||||
|
||||
function install_abra {
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
curl "$ABRA_SRC" > "$HOME/.local/bin/abra"
|
||||
chmod +x "$HOME/.local/bin/abra"
|
||||
echo "abra installed to $HOME/.loca/bin/abra"
|
||||
echo "abra installed to $HOME/.local/bin/abra"
|
||||
}
|
||||
|
||||
function run_installation {
|
||||
|
Reference in New Issue
Block a user