Re-enable running commands as another user

Fixes #14
This commit is contained in:
3wc 2020-09-27 23:45:39 +02:00
parent dd9444b036
commit 7223dca951

27
abra
View File

@ -158,8 +158,7 @@ sub_help() {
echo " deploy let 'em rip" echo " deploy let 'em rip"
echo " logs SERVICE [ARGS] tail logs from a deployed service" echo " logs SERVICE [ARGS] tail logs from a deployed service"
echo " multilogs tail logs from a whole stackk" echo " multilogs tail logs from a whole stackk"
echo " run SERVICE CMD run a command in the specified service's container" echo " run [-u USER] SERVICE CMD run a command in the specified service's container"
echo " run_args SERVICE ARGS CMD run, passing extra args to docker exec"
echo " secret [--help] [SUBCOMMAND] manage secrets" echo " secret [--help] [SUBCOMMAND] manage secrets"
echo " upgrade upgrade to the latest version" echo " upgrade upgrade to the latest version"
echo " ... (custom commands)" echo " ... (custom commands)"
@ -217,16 +216,20 @@ sub_secret() {
###### Subcommand `run` ###### Subcommand `run`
sub_run_args(){ sub_run(){
require_stack require_stack
SERVICE=$1 if [ "$1" == "-u" ]; then
DOCKER_ARGS=$2 RUN_USER="-u $2"
shift 2 shift 2
fi
SERVICE=$1
shift
if [ -z "$SERVICE" ]; then if [ -z "$SERVICE" ]; then
echo "Usage: $PROGRAM_NAME run SERVICE DOCKER_ARGS [CMD]" echo "Usage: $PROGRAM_NAME run [-u USER] SERVICE [CMD]"
exit exit
fi fi
@ -239,19 +242,11 @@ sub_run_args(){
fi fi
# shellcheck disable=SC2086 # shellcheck disable=SC2086
docker exec $DOCKER_ARGS -it "$CONTAINER" "$@" docker exec $RUN_USER -it "$CONTAINER" "$@"
return return
} }
sub_run(){
SERVICE=$1
shift
sub_run_args "$SERVICE" "" "$@"
}
###### Subcommand `deploy` ###### Subcommand `deploy`
sub_deploy (){ sub_deploy (){