#!/bin/bash
#*******************************************************************************
# Copyright (c) 2019 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v2.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v20.html
#
# Contributors:
#     IBM Corporation - initial API and implementation
#*******************************************************************************

export APP_NAME=${PWD##*/}

export IDC_INSTALL_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

if [[ $1 ]]; then

	if [ $1 == "shell" ]; then

		export APP_ID=`java -jar $IDC_INSTALL_DIR/artifacts/IDC.jar appid`

		if [[ `uname -a` == *"Linux"* ]]; then
			sudo docker exec -it iterative-dev-$APP_NAME-$APP_ID bash
			exit 0
		else
			docker exec -it iterative-dev-$APP_NAME-$APP_ID bash
			exit 0
		fi 
	fi 

fi 

java -jar $IDC_INSTALL_DIR/artifacts/IDC.jar $*

