Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

script: Added support for Mac user for using docker compose script #409

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
Binary file added bin/.DS_Store
Binary file not shown.
58 changes: 56 additions & 2 deletions bin/docker-compose
@@ -1,9 +1,63 @@
#!/bin/sh

command -v docker-compose >/dev/null 2>&1 || { echo >&2 "ERROR: Please install docker-compose."; exit 1; }
# Subfunction: Checks the rquirements
check_requirement() {
command -v $1 >/dev/null 2>&1 || fatal "\
$1 is not available on your system.
Please install it and try again. Good bye and hope we see you soon!"
}

WORKDIR=$(dirname $(readlink -f $0))/../
# Subfunction: Print out the Error message
fatal() {
echo >&2 "ERROR: $*"
exit 1
}

# Check if following packages are installed:
# -) docker-compose
# -) on Linux: readlink
# -) on Darwin(Mac): greadlink
check_requirement docker-compose
check_requirement readlink || check_requirement greadlink

# Store the command for detecting the OS (operating system)
# [Host: command output]; Linux: Linux; Mac: Darwin
unameOut="$(uname -s)"

# Comment for future tasks - Include other operating systems
# ==> these OS checks can be included in the case-esac statement and mybe some other changes are requiered
# CYGWIN*) machine=Cygwin;; Another OS => currently not supported;
# Translater to run GNU/Linux, BSD, and Unix programms on Windows
# MINGW*) machine=MinGw;; Another OS => currently not supported;
# open source software development environment to create Microsoft Windows applications

# Detect the OS
case "${unameOut}" in
# Supported OS
Linux*) OS=Linux;;
Darwin*) OS=Darwin;;

# The OS is not supported. Give feedback and terminate with error
*) fatal "You are not working on a supported OS! Currently ShellHub supports Linux and Darwin(Mac)."
esac

# OS is already checked before in the case statement -> as of now the OS is supported
echo "You are working on a supported OS! Happy dockering!"
echo "Your OS is: " ${OS}

# Set the appropriate working directories for the specific OS
# Supported Linux OS
if [ $OS == 'Linux' ]
then
WORKDIR=$(dirname $(readlink -f $0))/../
fi
# Supported Darwin (Mac) OS
if [ $OS == 'Darwin' ]
then
WORKDIR=$(dirname $(greadlink -f $0))/../
fi

# Change to working directory
cd $WORKDIR

set -o allexport
Expand Down