Skip to content

Commit

Permalink
Add support for older versions of Docker compose and improve code docs
Browse files Browse the repository at this point in the history
  • Loading branch information
drluckyspin committed Jun 19, 2019
1 parent 34d43ff commit 252aff2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 11 deletions.
27 changes: 20 additions & 7 deletions start.sh
@@ -1,6 +1,13 @@
#!/bin/bash
#!/usr/bin/env bash
#
# start.sh - is the main start script for our Demo cluster. Running it will launch a docker-compose environment
# that contains a fully connected ioFog ECN. Optionally, you can launch a different compose, e.g. tutorial.
#
# Usage : ./start.sh -h
#

set -o errexit -o pipefail -o noclobber -o nounset

cd "$(dirname "$0")"

# Import our helper functions
Expand All @@ -22,7 +29,7 @@ printHelp() {
echo " supported values: iofog, tutorial"
}

checkComposeFile() {
checkForComposeFile() {
local ENVIRONMENT="$1"
local COMPOSE_FILE="docker-compose-${ENVIRONMENT}.yml"
if [[ ! -f "${COMPOSE_FILE}" ]]; then
Expand All @@ -35,7 +42,8 @@ startIofog() {
echoInfo "Building containers for ioFog stack..."
local BUILD_ARGS="--build-arg LOCAL_CONTROLLER_PACKAGE=${CONTROLLER_PACKAGE} --build-arg LOCAL_CONNECTOR_PACKAGE=${CONNECTOR_PACKAGE} --build-arg LOCAL_AGENT_PACKAGE=${AGENT_PACKAGE}"
local COMPOSE_BUILD_ARGS="${IOFOG_BUILD_NO_CACHE} ${BUILD_ARGS:=""}"
docker-compose -f "docker-compose-iofog.yml" build ${COMPOSE_BUILD_ARGS} > /dev/null
local SERVICE_LIST="iofog-connector iofog-controller iofog-agent iofog-init"
docker-compose -f "docker-compose-iofog.yml" build ${COMPOSE_BUILD_ARGS} ${SERVICE_LIST} > /dev/null

echoInfo "Spinning up containers for ioFog stack..."
docker-compose -f "docker-compose-iofog.yml" up --detach --no-recreate
Expand Down Expand Up @@ -117,12 +125,17 @@ while [[ "$#" -ge 1 ]]; do
;;
esac
done
ENVIRONMENT=${ENVIRONMENT:="iofog"} # by default, setup only the ioFog stack

prettyHeader "Starting ioFog Demo (\"${ENVIRONMENT}\" environment)..."
prettyHeader "Starting ioFog Demo"

# Figure out which environment we are going to be starting. By default, setup only the ioFog stack
ENVIRONMENT=${ENVIRONMENT:="iofog"}

checkForComposeFile "iofog"

if [[ "${ENVIRONMENT}" != "iofog" ]]; then checkForComposeFile "${ENVIRONMENT}"; fi

checkComposeFile "iofog"
if [[ "${ENVIRONMENT}" != "iofog" ]]; then checkComposeFile "${ENVIRONMENT}"; fi
echoInfo "Starting \"${ENVIRONMENT}\" demo environment..."

# Create a new ssh key
echoInfo "Creating new ssh key for tests..."
Expand Down
2 changes: 1 addition & 1 deletion status.sh
@@ -1,6 +1,6 @@
#!/usr/bin/env bash
#
# status.sh - Print the status of the Demo cluster and it's components
# status.sh - Print the status of the Demo cluster and its components
#
# Usage: ./status.sh
#
Expand Down
8 changes: 7 additions & 1 deletion stop.sh
@@ -1,6 +1,12 @@
#!/bin/bash
#!/usr/bin/env bash
#
# stop.sh - will tear down a running docker-compose Demo environment
#
# Usage : ./stop.sh -h
#

set -o errexit -o pipefail -o noclobber -o nounset

cd "$(dirname "$0")"

# Import our helper functions
Expand Down
8 changes: 7 additions & 1 deletion test.sh
@@ -1,4 +1,9 @@
#!/bin/bash
#!/usr/bin/env bash
#
# test.sh - will pull and run the TestRunner suite against an already Demo compose cluster.
#
# Usage : ./test.sh -h
#

set -o errexit -o pipefail -o noclobber -o nounset
cd "$(dirname "$0")"
Expand Down Expand Up @@ -34,6 +39,7 @@ echoInfo "Retrieving endpoints for ioFog stack"
AGENT_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' iofog-agent)
CONTROLLER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' iofog-controller)
CONNECTOR_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' iofog-connector)

# Output the config for our Test suite config
echo "${CONNECTOR_IP}:8080" >| test/conf/connector.conf
echo "${CONTROLLER_IP}:51121" >| test/conf/controller.conf
Expand Down
4 changes: 3 additions & 1 deletion utils.sh
@@ -1,8 +1,9 @@
#!/usr/bin/env sh
#
# utils.sh - a simple set of functions for use throughout our bash scripts
#
# Usage : source utils.sh

#

# Export the name of the script for later use
THIS_SCRIPT="$(basename "${0}")"
Expand All @@ -11,6 +12,7 @@ export THIS_SCRIPT
#
# Check for DEBUG - looks for the DEBUG environment variable. If it
# is found, it enables more debugging output.
#
checkForDebug() {

# Allow anyone to set a DEBUG environment variable for extra output
Expand Down

0 comments on commit 252aff2

Please sign in to comment.