recursive_decompress.go: add .tar.gz support
[cmccabe-bin] / dssh
diff --git a/dssh b/dssh
index 710fdac..9799ec0 100755 (executable)
--- a/dssh
+++ b/dssh
@@ -19,16 +19,25 @@ options:
 -h:           show this help message.
 -i [ID]:      ssh into a docker node with this container ID
 -n [name]:    ssh into a docker node with this name
+-t [0 or 1]:  0 to avoid allocating a TTY; 1 to allocate one.
+              The default will be set based on whether this appears
+              to be an interactive shell.
 EOF
 }
 
 DOCKER_IMAGE_ID=""
 DOCKER_IMAGE_NAME=""
-while getopts  "hi:n:" flag; do
+if [ -t 0 ]; then
+    ALLOCATE_TTY=1
+else
+    ALLOCATE_TTY=0
+fi
+while getopts  "hi:n:t:" flag; do
     case $flag in
     h) usage; exit 0;;
     i) DOCKER_IMAGE_ID=${OPTARG};;
     n) DOCKER_IMAGE_NAME=${OPTARG};;
+    t) ALLOCATE_TTY=${OPTARG};;
     *) echo "getopts error"
         echo
         usage
@@ -39,7 +48,7 @@ shift $(expr $OPTIND - 1)
 if [ $# -eq 0 ]; then
     RUN_COMMAND="/bin/bash"
 else
-    RUN_COMMAND="${@}"
+    RUN_COMMAND=""
 fi
 
 which docker &>/dev/null || die "docker must be on the PATH."
@@ -61,4 +70,9 @@ else
         die "failed to find a docker image named ${DOCKER_IMAGE_NAME}"
 fi
 
-docker exec -it "${DOCKER_IMAGE_ID}" ${RUN_COMMAND}
+if [ ${ALLOCATE_TTY} == 1 ]; then
+    docker exec -it "${DOCKER_IMAGE_ID}" "${@}" ${RUN_COMMAND}
+else
+    docker exec -i "${DOCKER_IMAGE_ID}" "${@}" ${RUN_COMMAND} &
+    wait
+fi