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