Load per-stack commands from abra-commands.sh..
.. and add a new `abra run_args` command to allow adding arguments to `docker exec`.
This commit is contained in:
		
							
								
								
									
										25
									
								
								abra
									
									
									
									
									
								
							
							
						
						
									
										25
									
								
								abra
									
									
									
									
									
								
							| @ -16,7 +16,11 @@ if type direnv > /dev/null 2>&1 && ! direnv status | grep -q 'Found RC allowed t | ||||
| 	exit | ||||
| fi | ||||
|  | ||||
| sub_help(){ | ||||
| if [ -f abra-commands.sh ]; then | ||||
| 	. abra-commands.sh | ||||
| fi | ||||
|  | ||||
| sub_help() { | ||||
| 	echo "Usage: $PROGRAM_NAME [-a STACK_NAME] <subcommand> [options]" | ||||
| 	echo "" | ||||
| 	echo "Subcommands:" | ||||
| @ -24,8 +28,9 @@ sub_help(){ | ||||
| 	echo "    secret_generate SECRET VERSION [CMD]  generate a secret, store it in pass & as a Docker secret" | ||||
| 	echo "    deploy [COMPOSE_FILE]                 let 'em rip" | ||||
| 	echo "    logs SERVICE                          tail logs from a deployed service" | ||||
| 	echo "    ... (custom commands)" | ||||
| 	echo "" | ||||
| 		echo "Make sure \$STACK_NAME is set (probably using direnv)" | ||||
| 	echo "Make sure \$STACK_NAME is set using direnv or -a" | ||||
| } | ||||
|  | ||||
| sub_secret_generate(){ | ||||
| @ -43,9 +48,11 @@ sub_secret_generate(){ | ||||
| 		>(pass insert "hosts/autonomic-swarm/${STACK_NAME}/${SECRET}" -m) | ||||
| } | ||||
|  | ||||
| sub_run(){ | ||||
| sub_run_args(){ | ||||
| 	SERVICE=$1 | ||||
| 	SH=${2:-/bin/sh} | ||||
| 	ARGS=$2 | ||||
|  | ||||
| 	shift 2 | ||||
|  | ||||
| 	if [ -z "$SERVICE" ]; then | ||||
| 		echo "Usage: $PROGRAM_NAME run SERVICE [CMD]" | ||||
| @ -60,11 +67,19 @@ sub_run(){ | ||||
| 		exit | ||||
| 	fi | ||||
|  | ||||
| 	docker exec -it "$CONTAINER" "$SH" | ||||
| 	docker exec $ARGS -it "$CONTAINER" $@ | ||||
|  | ||||
| 	return | ||||
| } | ||||
|  | ||||
| sub_run(){ | ||||
| 	SERVICE=$1 | ||||
|  | ||||
| 	shift | ||||
|  | ||||
| 	sub_run_args "$SERVICE" "" "$@" | ||||
| } | ||||
|  | ||||
| sub_deploy (){ | ||||
| 	COMPOSE=${1:-compose.yml} | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user