Permalink
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
grouper_training/gte
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
67 lines (55 sloc)
1.81 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
REPOSITORY=tier/gte | |
VERSION_TAG=202303 | |
EXTRA_ARGS= | |
show_help() { | |
echo "$0 [--sql] [--ldap] [--fg|-it] [docker args ...] <gte lesson id> [container cmd ...]" | |
echo " --sql: Expose port 3306" | |
echo " --ldap: Expose port 389" | |
echo " --fg: Don't detach (i.e., don't run container with -d flag" | |
echo " -h|--help: This help message" | |
echo "" | |
echo "If no GTE lesson id number is passed in, the command will list all the available ids" | |
} | |
for arg in $*; do | |
case $arg in | |
--sql) EXTRA_ARGS="$EXTRA_ARGS -p 3306:3306"; shift;; | |
--ldap) EXTRA_ARGS="$EXTRA_ARGS -p 389:389"; shift;; | |
--fg) is_foreground=1; shift;; | |
-it) is_foreground=1; EXTRA_ARGS="$EXTRA_ARGS $1"; shift;; | |
-h|--help) show_help; exit 0;; | |
-*) EXTRA_ARGS="$EXTRA_ARGS $1"; shift;; | |
*) break;; | |
esac | |
done | |
#echo args=$* | |
#echo EXTRA_ARGS=$EXTRA_ARGS | |
if [ "$is_foreground" != 1 ]; then | |
EXTRA_ARGS="$EXTRA_ARGS -d" | |
fi | |
if [ -z "$1" ] | |
then | |
echo "Pass in which gte environment to spin up:" | |
# Get all container tags for tier/gte:*-2021xx | |
my_array=( $(docker images "$REPOSITORY" --format '{{.Tag}}' | grep -- "-$VERSION_TAG$" | sed -e "s/-$VERSION_TAG$//" | sort ) ) | |
for i in "${my_array[@]}" | |
do | |
echo $i | |
done | |
exit 1 | |
fi | |
LESSON_ID=$1 | |
shift | |
# see if there is a container | |
CONTAINERS="$( docker ps -a | grep 'tier/gte' | awk '{print $1}' )" | |
# if so, then rm it | |
if [ ! -z "$CONTAINERS" ]; then | |
echo "Removing old containers" | |
docker rm -f $CONTAINERS | |
fi | |
# lets see which | |
#docker stop "$1" 2> /dev/null | |
#docker rm "$1" 2> /dev/null | |
#docker run -d -p 8443:443 --name $1 tier/gte:"$1"-202303 | |
echo "Starting container tier/gte:"$LESSON_ID"-$VERSION_TAG" | |
docker run -p 8443:443 $EXTRA_ARGS --name $LESSON_ID tier/gte:"$LESSON_ID"-$VERSION_TAG $* |