diff --git a/Changelog.md b/Changelog.md index 79b3376..1e29445 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,7 @@ ## 0.9.12 (not yet released) * Added a workaround for Docker's inability to modify /etc/hosts in the container ([Docker bug 2267](https://github.com/dotcloud/docker/issues/2267)). Please refer to the README for details. + * The docker-bash tool now works on a regular sh shell too, instead of bash specifically. Closes GH-103. ## 0.9.11 (release date: 2014-06-24) diff --git a/tools/docker-bash b/tools/docker-bash index 6a14d37..22cdf35 100755 --- a/tools/docker-bash +++ b/tools/docker-bash @@ -1,11 +1,10 @@ -#!/bin/bash +#!/bin/sh set -e -set -o pipefail KNOWN_HOSTS_FILE= IP= -function usage() +usage() { echo "Usage: docker-bash [COMMAND...]" echo "Login to a Baseimage-based Docker container using SSH." @@ -13,19 +12,19 @@ function usage() echo "Otherwise, runs COMMAND inside the container." } -function cleanup() +cleanup() { local pids=`jobs -p` - if [[ "$pids" != "" ]]; then + if test "$pids" != ""; then kill $pids fi - if [[ "$KNOWN_HOSTS_FILE" != "" ]]; then + if test "$KNOWN_HOSTS_FILE" != ""; then rm -f "$KNOWN_HOSTS_FILE" fi } -if [[ $# = 0 ]]; then +if test $# = 0; then usage exit fi @@ -35,13 +34,13 @@ shift trap cleanup EXIT -if ! [[ -e ~/.baseimage_docker_insecure_key ]]; then - if [[ -e /usr/local/share/baseimage-docker/insecure_key ]]; then +if ! test -e ~/.baseimage_docker_insecure_key; then + if test -e /usr/local/share/baseimage-docker/insecure_key; then cp /usr/local/share/baseimage-docker/insecure_key ~/.baseimage_docker_insecure_key else dir=`dirname "$0"` dir=`cd "$dir/.." && pwd` - if [[ -e "$dir/image/insecure_key" ]]; then + if test -e "$dir/image/insecure_key"; then cp "$dir/image/insecure_key" ~/.baseimage_docker_insecure_key else echo "*** ERROR ***: Baseimage-docker insecure key not found." >&2 @@ -72,7 +71,7 @@ if ! ssh -i ~/.baseimage_docker_insecure_key \ "root@$IP" "$@" then STATUS=$? - if [[ $# = 0 ]]; then + if test $# = 0; then echo "----------------" echo "It appears that login to the Docker container failed. This could be caused by the following reasons:" echo "- The Docker container you're trying to login to is not based on Baseimage-docker. The docker-bash tool only works with Baseimage-docker-based containers."