Fix run
subcommand
This commit is contained in:
parent
841e4fc61a
commit
6e38dc35e5
49
abra
49
abra
@ -609,6 +609,7 @@ sub_app_secret_auto(){
|
|||||||
###### .. app <domain> run <args>...
|
###### .. app <domain> run <args>...
|
||||||
sub_app_run(){
|
sub_app_run(){
|
||||||
load_instance
|
load_instance
|
||||||
|
load_instance_env
|
||||||
|
|
||||||
if [ -n "$abra___user" ]; then
|
if [ -n "$abra___user" ]; then
|
||||||
RUN_USER="-u $abra___user"
|
RUN_USER="-u $abra___user"
|
||||||
@ -618,7 +619,7 @@ sub_app_run(){
|
|||||||
| grep "${STACK_NAME}_${abra__app_}" | head -n1 | cut -d',' -f1)
|
| grep "${STACK_NAME}_${abra__app_}" | head -n1 | cut -d',' -f1)
|
||||||
|
|
||||||
if [ -z "$CONTAINER" ]; then
|
if [ -z "$CONTAINER" ]; then
|
||||||
error "Can't find a container for ${STACK_NAME}_${abra__app_}"
|
error "Can't find a container for ${STACK_NAME}_${abra__service_}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -681,7 +682,8 @@ sub_app_logs (){
|
|||||||
|
|
||||||
###### .. app <domain> cp <src> <dst>
|
###### .. app <domain> cp <src> <dst>
|
||||||
sub_app_cp() {
|
sub_app_cp() {
|
||||||
require_stack
|
load_instance
|
||||||
|
load_instance_env
|
||||||
|
|
||||||
SOURCE="${abra__src_}"
|
SOURCE="${abra__src_}"
|
||||||
DEST="${abra__dst_}"
|
DEST="${abra__dst_}"
|
||||||
@ -714,6 +716,19 @@ sub_app_cp() {
|
|||||||
# abra server ..
|
# abra server ..
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
|
###### .. server ls
|
||||||
|
sub_server_ls() {
|
||||||
|
sub_server_list
|
||||||
|
}
|
||||||
|
|
||||||
|
sub_server_list() {
|
||||||
|
get_servers
|
||||||
|
printf "%s servers:\n\n" "${#SERVERS[@]}"
|
||||||
|
for SERVER in "${SERVERS[@]}"; do
|
||||||
|
echo " ${SERVER##*/}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
###### .. server init <host>
|
###### .. server init <host>
|
||||||
sub_server_init() {
|
sub_server_init() {
|
||||||
export DOCKER_CONTEXT="${abra__host_}"
|
export DOCKER_CONTEXT="${abra__host_}"
|
||||||
@ -724,6 +739,7 @@ sub_server_init() {
|
|||||||
docker network create --driver=overlay proxy --scope swarm || true
|
docker network create --driver=overlay proxy --scope swarm || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###### .. server <add> <host> [<username>] [<password>]
|
||||||
sub_server_add() {
|
sub_server_add() {
|
||||||
require_abra_dir
|
require_abra_dir
|
||||||
|
|
||||||
@ -746,43 +762,35 @@ sub_server_add() {
|
|||||||
mkdir -p "$ABRA_DIR/servers/$HOST"
|
mkdir -p "$ABRA_DIR/servers/$HOST"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###### .. server <host> delete
|
||||||
sub_server_rm() {
|
sub_server_rm() {
|
||||||
|
sub_server_delete
|
||||||
|
}
|
||||||
|
sub_server_delete() {
|
||||||
docker context rm "$abra__host_"
|
docker context rm "$abra__host_"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###### .. server <host> use
|
||||||
sub_server_use() {
|
sub_server_use() {
|
||||||
docker context use "$abra__host_"
|
docker context use "$abra__host_"
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_server_ls() {
|
|
||||||
sub_server_list
|
|
||||||
}
|
|
||||||
|
|
||||||
sub_server_list() {
|
|
||||||
get_servers
|
|
||||||
printf "%s server(s):\n\n" "${#SERVERS[@]}"
|
|
||||||
for SERVER in "${SERVERS[@]}"; do
|
|
||||||
echo " ${SERVER##*/}"
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
#######################################
|
#######################################
|
||||||
# Misc commands
|
# Misc commands
|
||||||
#######################################
|
#######################################
|
||||||
|
|
||||||
###### Subcommand `upgrade`
|
###### .. upgrade
|
||||||
|
|
||||||
sub_upgrade() {
|
sub_upgrade() {
|
||||||
curl https://install.abra.autonomic.zone | bash
|
curl https://install.abra.autonomic.zone | bash
|
||||||
}
|
}
|
||||||
|
|
||||||
###### Docker alias subcommands
|
###### .. volume <args>...
|
||||||
|
|
||||||
sub_stack() {
|
sub_stack() {
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
docker stack $@
|
docker stack $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
###### .. stack <args>...
|
||||||
sub_volume() {
|
sub_volume() {
|
||||||
# shellcheck disable=SC2068
|
# shellcheck disable=SC2068
|
||||||
docker volume $@
|
docker volume $@
|
||||||
@ -803,8 +811,10 @@ abra() {
|
|||||||
DOCOPT_PREFIX=abra_
|
DOCOPT_PREFIX=abra_
|
||||||
eval "$(docopt "$@")"
|
eval "$(docopt "$@")"
|
||||||
|
|
||||||
|
# --stack <stack>
|
||||||
STACK_NAME=$abra___stack
|
STACK_NAME=$abra___stack
|
||||||
|
|
||||||
|
# --env <env>
|
||||||
if [ -n "$abra___env" ]; then
|
if [ -n "$abra___env" ]; then
|
||||||
# shellcheck disable=SC1090
|
# shellcheck disable=SC1090
|
||||||
source "$abra___env" || error "Unable to load env from '$abra___env'"
|
source "$abra___env" || error "Unable to load env from '$abra___env'"
|
||||||
@ -817,6 +827,7 @@ abra() {
|
|||||||
for SUBCOMMAND in $(declare -Ff | grep 'sub_' | cut -d' ' -f3 | sort -r); do
|
for SUBCOMMAND in $(declare -Ff | grep 'sub_' | cut -d' ' -f3 | sort -r); do
|
||||||
IFS='_' read -r -a PARTS <<< "$SUBCOMMAND"
|
IFS='_' read -r -a PARTS <<< "$SUBCOMMAND"
|
||||||
for PART in "${PARTS[@]:1}"; do
|
for PART in "${PARTS[@]:1}"; do
|
||||||
|
# TODO 3wc: probably a better way to check if a function is defined..
|
||||||
VAR=$(eval "echo \$abra_$PART")
|
VAR=$(eval "echo \$abra_$PART")
|
||||||
if [ ! "$VAR" == "true" ]; then
|
if [ ! "$VAR" == "true" ]; then
|
||||||
continue 2
|
continue 2
|
||||||
@ -825,7 +836,7 @@ abra() {
|
|||||||
abra__command_=$(IFS="_"; echo "${PARTS[*]:1}")
|
abra__command_=$(IFS="_"; echo "${PARTS[*]:1}")
|
||||||
done
|
done
|
||||||
|
|
||||||
# Fallback for non-docopt-defined options
|
# Use abra__command_ in case `command` is provided (i.e. `volume` or `stack`)
|
||||||
CMD="sub_${abra__command_}"
|
CMD="sub_${abra__command_}"
|
||||||
if type "$CMD" > /dev/null 2>&1; then
|
if type "$CMD" > /dev/null 2>&1; then
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
|
Loading…
Reference in New Issue
Block a user