su622b | f5b6899 | 2018-04-23 12:02:24 -0400 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -e |
| 4 | |
Gary Wu | 08fc50d | 2018-05-04 07:32:09 -0700 | [diff] [blame] | 5 | export NEXUS_DOCKER_REPO=$(cat /opt/config/nexus_docker_repo.txt) |
| 6 | |
su622b | f5b6899 | 2018-04-23 12:02:24 -0400 | [diff] [blame] | 7 | # do not change this, it is already matched with the git repo file structure |
| 8 | DOCKER_FILE_DIR='./docker_files' |
| 9 | |
su622b | f5b6899 | 2018-04-23 12:02:24 -0400 | [diff] [blame] | 10 | # commands to run docker and docker-compose |
| 11 | DOCKER_COMPOSE_EXE='/opt/docker/docker-compose' |
| 12 | |
| 13 | cd "${DOCKER_FILE_DIR}" |
| 14 | |
| 15 | while ! ifconfig |grep "docker0" > /dev/null; |
| 16 | do sleep 1 |
| 17 | echo 'waiting for docker operational' |
| 18 | done |
| 19 | |
| 20 | echo "prep any files with local configurations" |
| 21 | if ls __* 1> /dev/null 2>&1; then |
| 22 | IP_DOCKER0=$(ifconfig docker0 |grep "inet addr" | cut -d: -f2 |cut -d" " -f1) |
| 23 | TEMPLATES=$(ls -1 __*) |
| 24 | for TEMPLATE in $TEMPLATES |
| 25 | do |
| 26 | FILENAME=${TEMPLATE//_} |
| 27 | if [ ! -z "${IP_DOCKER0}" ]; then |
| 28 | sed -e "s/{{ ip.docker0 }}/${IP_DOCKER0}/" "$TEMPLATE" > "$FILENAME" |
| 29 | fi |
| 30 | done |
| 31 | fi |
| 32 | |
| 33 | if [ -z "$MTU" ]; then |
| 34 | export MTU=$(ifconfig docker0 |grep MTU |sed -e 's/.*MTU://' -e 's/\s.*$//') |
| 35 | fi |
| 36 | |
| 37 | echo "starting docker operations" |
| 38 | ${DOCKER_COMPOSE_EXE} up -d --build |