From 8b090d1d45fd1d38b8b24ed8145ccb8c8e97af94 Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Thu, 2 Aug 2018 20:55:30 -0400 Subject: Support for docker-compose in heat environment Enhanced the application startup script and renamed it. Removed unused files. Note that everything in catalog-db-adapter's afterMigrate.sql script has been commented out. It needs work to match the current schema. Change-Id: I7b738ca13599476b9720bdb4a9aebaf3a9f86736 Issue-ID: SO-710 Signed-off-by: Rob Daugherty --- packages/docker/pom.xml | 6 +- .../src/main/docker/docker-files/Dockerfile.aria | 44 -- .../src/main/docker/docker-files/Dockerfile.jacoco | 33 -- .../docker/docker-files/Dockerfile.mso-arquillian | 90 --- .../docker/docker-files/Dockerfile.mso-chef-final | 171 ------ .../src/main/docker/docker-files/Dockerfile.so-app | 23 +- .../docker/docker-files/Dockerfile.so-base-image | 4 +- .../docker-files/Dockerfile.ubuntu-16.04-update | 22 - .../main/docker/docker-files/Dockerfile.wildfly-10 | 32 -- .../main/docker/docker-files/chef-configs/solo.rb | 9 - .../configuration/application-roles.properties | 33 -- .../configuration/application-users.properties | 35 -- .../configuration/mgmt-groups.properties | 22 - .../configuration/mgmt-users.properties | 27 - .../configuration/standalone-full-ha.xml | 609 --------------------- .../jboss-configs/modules/mariadb/main/module.xml | 11 - .../main/docker/docker-files/scripts/start-app.sh | 90 +++ .../docker/docker-files/scripts/startService.sh | 44 -- .../main/docker/docker-files/scripts/wait-for.sh | 85 +++ .../src/main/docker/docker-files/settings.xml | 54 -- .../src/main/docker/docker-files/wait-for.sh | 85 --- 21 files changed, 197 insertions(+), 1332 deletions(-) delete mode 100644 packages/docker/src/main/docker/docker-files/Dockerfile.aria delete mode 100644 packages/docker/src/main/docker/docker-files/Dockerfile.jacoco delete mode 100644 packages/docker/src/main/docker/docker-files/Dockerfile.mso-arquillian delete mode 100644 packages/docker/src/main/docker/docker-files/Dockerfile.mso-chef-final delete mode 100644 packages/docker/src/main/docker/docker-files/Dockerfile.ubuntu-16.04-update delete mode 100644 packages/docker/src/main/docker/docker-files/Dockerfile.wildfly-10 delete mode 100644 packages/docker/src/main/docker/docker-files/chef-configs/solo.rb delete mode 100644 packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-roles.properties delete mode 100644 packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-users.properties delete mode 100644 packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-groups.properties delete mode 100644 packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-users.properties delete mode 100644 packages/docker/src/main/docker/docker-files/jboss-configs/configuration/standalone-full-ha.xml delete mode 100644 packages/docker/src/main/docker/docker-files/jboss-configs/modules/mariadb/main/module.xml create mode 100644 packages/docker/src/main/docker/docker-files/scripts/start-app.sh delete mode 100644 packages/docker/src/main/docker/docker-files/scripts/startService.sh create mode 100755 packages/docker/src/main/docker/docker-files/scripts/wait-for.sh delete mode 100644 packages/docker/src/main/docker/docker-files/settings.xml delete mode 100755 packages/docker/src/main/docker/docker-files/wait-for.sh (limited to 'packages/docker') diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index 41495ccb1e..9f96b2fcd0 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -105,7 +105,7 @@ - so/requests-db-adapter + so/request-db-adapter try docker-files @@ -155,7 +155,7 @@ - so/openstack-adapters + so/openstack-adapter try docker-files @@ -310,7 +310,7 @@ push - so/catalog-db-adapter,so/requests-db-adapter,so/sdnc-adapter,so/openstack-adapters,so/asdc-controller,so/bpmn-infra,so/api-handler-infra + so/catalog-db-adapter,so/request-db-adapter,so/sdnc-adapter,so/openstack-adapter,so/vfc-adapter,so/asdc-controller,so/bpmn-infra,so/api-handler-infra diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.aria b/packages/docker/src/main/docker/docker-files/Dockerfile.aria deleted file mode 100644 index 26f672e51d..0000000000 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.aria +++ /dev/null @@ -1,44 +0,0 @@ -# -# ============LICENSE_START=================================================== -# Copyright (c) 2017 Cloudify.co. All rights reserved. -# =================================================================== -# Licensed under the Apache License, Version 2.0 (the "License"); you may not -# use this file except in compliance with the License. You may obtain a copy -# of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations under -# the License. -# ============LICENSE_END==================================================== -# -FROM httpd:alpine -ARG aria_rest_url -ARG aria_rest_branch - -RUN apk update -RUN apk add python2 py2-pip gcc python2-dev linux-headers musl-dev git curl -WORKDIR /tmp -RUN git clone -b 0.1.1 https://github.com/cloudify-cosmo/aria-extension-cloudify -WORKDIR /tmp/aria-extension-cloudify -RUN pip install -U setuptools -RUN pip install . -RUN pip install apache-ariatosca==0.1.1 jinja2==2.8 -WORKDIR /tmp -RUN git clone -b ${aria_rest_branch} ${aria_rest_url} -WORKDIR /tmp/so/aria/aria-rest-server/src/main/python/aria-rest -RUN pip install . -WORKDIR /tmp -RUN git clone -b 2.0.1 https://github.com/cloudify-cosmo/cloudify-openstack-plugin -RUN wagon create ./cloudify-openstack-plugin -RUN aria plugins install cloudify_openstack_plugin-2.0.1-py27-none-linux_x86_64.wgn -RUN rm cloudify_openstack_plugin-2.0.1-py27-none-linux_x86_64.wgn -RUN git clone -b 1.4.10 https://github.com/cloudify-cosmo/cloudify-aws-plugin -RUN wagon create ./cloudify-aws-plugin -RUN aria plugins install cloudify_aws_plugin-1.4.10-py27-none-linux_x86_64.wgn -RUN rm cloudify_aws_plugin-1.4.10-py27-none-linux_x86_64.wgn - -CMD aria-rest diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.jacoco b/packages/docker/src/main/docker/docker-files/Dockerfile.jacoco deleted file mode 100644 index cd70b373f7..0000000000 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.jacoco +++ /dev/null @@ -1,33 +0,0 @@ -### Set the base image to Ubuntu -FROM ubuntu:14.04 - -### File Author / Maintainer -MAINTAINER "The ONAP Team" -LABEL Description="This image is used to get jacoco result from a jboss image" Version="1.0" - -ARG http_proxy -ARG https_proxy -ARG chef_repo_branch_name -ARG chef_repo_address -ARG chef_repo_git_name -ARG chef_repo_git_username -ENV HTTP_PROXY=$http_proxy -ENV HTTPS_PROXY=$https_proxy -ENV http_proxy=$HTTP_PROXY -ENV https_proxy=$HTTPS_PROXY -RUN echo "Acquire::http::Proxy \"$http_proxy\";" >> /etc/apt/apt.conf - -RUN apt-get update && apt-get install -y openssh-server -RUN mkdir /var/run/sshd -RUN echo 'root:screencast' | chpasswd -RUN sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/' /etc/ssh/sshd_config - -# SSH login fix. Otherwise user is kicked off after login -RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd - -ENV NOTVISIBLE "in users profile" -RUN echo "export VISIBLE=now" >> /etc/profile - -VOLUME /shared - -CMD ["/usr/sbin/sshd", "-D"] diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.mso-arquillian b/packages/docker/src/main/docker/docker-files/Dockerfile.mso-arquillian deleted file mode 100644 index 6dfdfa3d1b..0000000000 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.mso-arquillian +++ /dev/null @@ -1,90 +0,0 @@ -FROM openecomp/wildfly:1.0 - - -### File Author / Maintainer -MAINTAINER "The ONAP Team" -LABEL Description="This image contains the ONAP SO base for arquillian" Version="1.0" - -ENV CHEF_REPO_NAME="chef-repo" -ENV CHEF_CONFIG_NAME="mso-config" - -### Downloading dependencies - -USER root -RUN apt-get install -y curl && curl -LO https://packages.chef.io/stable/ubuntu/12.04/chefdk_0.17.17-1_amd64.deb && curl -LO http://central.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/1.5.4/mariadb-java-client-1.5.4.jar && curl -LO http://search.maven.org/remotecontent?filepath=org/jacoco/jacoco/0.7.7.201606060606/jacoco-0.7.7.201606060606.zip && apt-get remove --purge -y curl && apt-get autoremove -y -RUN apt-get install -y unzip && unzip jacoco-0.7.7.201606060606.zip -d /tmp/jacoco && apt-get remove --purge -y unzip && apt-get autoremove -y -RUN chown -R jboss:jboss /tmp/jacoco -### Install Chef -RUN dpkg -i chefdk_0.17.17-1_amd64.deb - -COPY scripts/start-jboss-server.sh /opt/mso/scripts/start-jboss-server.sh - -RUN chown jboss:jboss /opt/mso/scripts/* -RUN chmod u+rx /opt/mso/scripts/* - -RUN mkdir /etc/chef -RUN chown jboss:jboss /etc/chef -RUN chmod u+xrw /etc/chef - -RUN mkdir -p /etc/mso -RUN chown -R jboss:jboss /etc/mso -RUN chmod u+xrw /etc/mso - -# Setup shared folder -RUN mkdir /shared -RUN chown jboss:jboss /shared - -# Setup chef folders -RUN mkdir -p /var/chef/nodes -RUN chown jboss:jboss /var/chef/nodes -RUN mkdir /var/berks-cookbooks -RUN chown jboss:jboss /var/berks-cookbooks -RUN mkdir -p /home/jboss/.chef/nodes -RUN chown jboss:jboss /home/jboss/.chef/nodes - -COPY chef-configs/${CHEF_REPO_NAME} /var/berks-cookbooks/${CHEF_REPO_NAME} -COPY chef-configs/${CHEF_CONFIG_NAME} /var/berks-cookbooks/${CHEF_CONFIG_NAME} -COPY chef-configs/solo.rb /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb - -# Start Chef config -RUN sed "s/CHEF_REPO_NAME_TO_REPLACE/${CHEF_REPO_NAME}/g" -i /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -RUN chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra] - -RUN mv /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker-init.json -RUN echo "" > /shared/mso-docker.json -RUN ln -s /shared/mso-docker.json /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json - -# Jacoco config -RUN echo "" > /shared/jacoco-it.exec -RUN ls -latr / -RUN ls -latr /shared -RUN chown jboss:jboss /shared/jacoco-it.exec - -## Create the log folder for MSO -RUN mkdir -p /var/log/ecomp/MSO/ -RUN chown jboss:jboss /var/log/ecomp/MSO - -### Configure Jboss WildFly -RUN mkdir -p $JBOSS_HOME/modules/mariadb/main -RUN cp mariadb-java-client-1.5.4.jar $JBOSS_HOME/modules/mariadb/main -COPY jboss-configs/modules/mariadb/main/module.xml $JBOSS_HOME/modules/mariadb/main -COPY jboss-configs/configuration/standalone-full-ha.xml $JBOSS_HOME/standalone/configuration/standalone-full-ha-mso.xml -COPY jboss-configs/configuration/mgmt-users.properties $JBOSS_HOME/standalone/configuration/mgmt-users.properties -COPY jboss-configs/configuration/mgmt-groups.properties $JBOSS_HOME/standalone/configuration/mgmt-groups.properties -COPY jboss-configs/configuration/application-users.properties $JBOSS_HOME/standalone/configuration/application-users.properties -COPY jboss-configs/configuration/application-roles.properties $JBOSS_HOME/standalone/configuration/application-roles.properties - -RUN echo "JAVA_OPTS=\"\$JAVA_OPTS -Xms64m -Xmx4g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=1g -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 -Dmso.db=MARIADB -Dmso.config.path=/etc/mso/config.d/ -javaagent:/tmp/jacoco/lib/jacocoagent.jar=destfile=/shared/jacoco-it.exec,dumponexit=true,append=false,includes=com.att.*:org.openecomp.*\"" >> $JBOSS_HOME/bin/standalone.conf -RUN echo "LAUNCH_JBOSS_IN_BACKGROUND=true" >> $JBOSS_HOME/bin/standalone.conf - -RUN mkdir -p /etc/mso/config.d/ASDC && chown -R jboss:jboss /etc/mso/config.d/ASDC && chmod u+xrw /etc/mso/config.d/ASDC - -### Open Ports -EXPOSE 8080 9990 - -VOLUME /shared - -### Start EAP -USER root -CMD ["/opt/mso/scripts/start-jboss-server.sh"] - diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.mso-chef-final b/packages/docker/src/main/docker/docker-files/Dockerfile.mso-chef-final deleted file mode 100644 index bbb3d1e4bf..0000000000 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.mso-chef-final +++ /dev/null @@ -1,171 +0,0 @@ -FROM openecomp/wildfly:1.0 - - -### File Author / Maintainer -MAINTAINER "The ONAP Team" -LABEL Description="This image contains the ONAP SO" Version="1.0" - -ARG http_proxy -ARG https_proxy -ENV HTTP_PROXY=$http_proxy -ENV HTTPS_PROXY=$https_proxy -ENV http_proxy=$HTTP_PROXY -ENV https_proxy=$HTTPS_PROXY - -ENV CHEF_REPO_NAME="chef-repo" -ENV CHEF_CONFIG_NAME="mso-config" - -USER root - -### Downloading dependencies -# Install specific system libraries to fix CVE vulnerabilities -RUN echo "deb http://archive.ubuntu.com/ubuntu/ artful main restricted" >> /etc/apt/sources.list && \ - echo "deb http://security.ubuntu.com/ubuntu/ artful-security main restricted" >> /etc/apt/sources.list && \ - echo "deb http://archive.ubuntu.com/ubuntu/ bionic main restricted" >> /etc/apt/sources.list && \ - apt-get -y update - -# krb5 1.16-2build1 -# For CVE-2017-15088 CVE-2017-11462 -# libvorbis 1.3.5-4ubuntu0.2 -# For CVE-2017-14632 CVE-2017-14160 -# libx11 2:1.6.4-3 -# For CVE-2016-7943 CVE-2016-7942 -# libxtst 1.2.3-1 -# For CVE-2016-7951 -# ncurses 6.1-1ubuntu1 -# For CVE-2017-10685 CVE-2017-10684 -# libsqllite3-0 3.22.0-1 -# For CVE-2017-10989 -# libtiff5 4.0.8-5ubuntu0.1 -# For CVE-2017-9117 CVE-2016-9540 CVE-2016-9539 CVE-2016-9538 CVE-2016-9537 CVE-2016-9536 CVE-2016-9535 CVE-2016-9534 CVE-2016-9533 CVE-2015-8668 CVE-2015-7554 CVE-2016-6223 CVE-2017-5563 CVE-2016-3621 CVE-2016-8331 -# shadow 1:4.5-1ubuntu1 -# For CVE-2017-12424 -# perl-base 5.26.0-8ubuntu1.1 -# For CVE-2015-8608 CVE-2017-12883 -# openssl 1.1.0g-2ubuntu3 -# For CVE-2016-6303 CVE-2016-2182 CVE-2016-2177 CVE-2016-2176 -# zlib1g 1:1.2.11.dfsg-0ubuntu2 -# For CVE-2016-9843 CVE-2016-9841 CVE-2016-9842 CVE-2016-9840 -# libexpat1 2.2.5-3 -# For CVE-2016-0718 CVE-2016-4472 -# libc-bin libc6 2.26-0ubuntu2.1 -# For CVE-2018-6485 -# openssl 1.1.0g-2ubuntu3 -# For CVE-2016-6303 CVE-2016-2182 CVE-2016-2177 -# libpcre3 2:8.39-5ubuntu3 -# For CVE-2016-3191 CVE-2016-1283 -# berkeleydb -# For CVE-2016-3418 CVE-2016-0694 CVE-2016-0689 CVE-2016-0682 -# jetty -# For CVE-2017-9735 -# libxi -# For CVE-2016-7946 CVE-2016-7945 -# xalan -# For CVE-2014-0107 -# git -# For CVE-2017-14867 -# - -USER root -RUN apt-get -y --only-upgrade install \ - libkrb5-3 krb5-locales \ - libvorbis0a \ - libx11-6 libx11-data libx11-doc libx11-xcb1 \ - libxtst6 \ - ncurses-base ncurses-bin libncurses5 libncursesw5 \ - libsqlite3-0 \ - libtiff5 \ - passwd \ - perl-base \ - openssl \ - zlib1g \ - libdb5.3 \ - libc-bin libc6 multiarch-support \ - libxi6 \ - libpcre3 \ - expat \ - jetty9 \ - xalan \ - git - - -RUN apt-get install -y netcat curl && curl -LO https://packages.chef.io/files/stable/chefdk/2.5.3/ubuntu/16.04/chefdk_2.5.3-1_amd64.deb && curl -LO http://central.maven.org/maven2/org/mariadb/jdbc/mariadb-java-client/1.5.4/mariadb-java-client-1.5.4.jar && apt-get remove --purge -y curl && apt-get autoremove -y - -### Install Chef -#RUN dpkg -i chefdk_0.17.17-1_amd64.deb -RUN dpkg -i chefdk_2.5.3-1_amd64.deb - -COPY scripts/start-jboss-server.sh /opt/mso/scripts/start-jboss-server.sh - -RUN chown jboss:jboss /opt/mso/scripts/* -RUN chmod u+rx /opt/mso/scripts/* - -RUN mkdir /etc/chef -RUN chown jboss:jboss /etc/chef -RUN chmod u+xrw /etc/chef - -RUN mkdir -p /etc/mso -RUN chown -R jboss:jboss /etc/mso -RUN chmod u+xrw /etc/mso - -# Setup shared folder -RUN mkdir /shared -RUN chown jboss:jboss /shared - -# Setup chef folders -RUN mkdir -p /var/chef/nodes -RUN chown jboss:jboss /var/chef/nodes -RUN mkdir /var/berks-cookbooks -RUN chown jboss:jboss /var/berks-cookbooks -RUN mkdir -p /home/jboss/.chef/nodes -RUN chown jboss:jboss /home/jboss/.chef/nodes - -COPY chef-configs/${CHEF_REPO_NAME} /var/berks-cookbooks/${CHEF_REPO_NAME} -COPY chef-configs/${CHEF_CONFIG_NAME} /var/berks-cookbooks/${CHEF_CONFIG_NAME} -COPY chef-configs/solo.rb /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb - -# Start Chef config -RUN sed "s/CHEF_REPO_NAME_TO_REPLACE/${CHEF_REPO_NAME}/g" -i /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -RUN chef-solo -c /var/berks-cookbooks/${CHEF_REPO_NAME}/solo.rb -o recipe[mso-config::apih],recipe[mso-config::bpmn],recipe[mso-config::jra] - -RUN mv /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker-init.json -RUN echo "" > /shared/mso-docker.json -RUN ln -s /shared/mso-docker.json /var/berks-cookbooks/${CHEF_REPO_NAME}/environments/mso-docker.json - -## Create the log folder for MSO -RUN mkdir -p /var/log/ecomp/MSO/ -RUN chown jboss:jboss /var/log/ecomp/MSO - -### Configure Jboss WildFly -RUN mkdir -p $JBOSS_HOME/modules/mariadb/main -RUN cp mariadb-java-client-1.5.4.jar $JBOSS_HOME/modules/mariadb/main -COPY jboss-configs/modules/mariadb/main/module.xml $JBOSS_HOME/modules/mariadb/main -COPY jboss-configs/configuration/standalone-full-ha.xml $JBOSS_HOME/standalone/configuration/standalone-full-ha-mso.xml -COPY jboss-configs/configuration/mgmt-users.properties $JBOSS_HOME/standalone/configuration/mgmt-users.properties -COPY jboss-configs/configuration/mgmt-groups.properties $JBOSS_HOME/standalone/configuration/mgmt-groups.properties -COPY jboss-configs/configuration/application-users.properties $JBOSS_HOME/standalone/configuration/application-users.properties -COPY jboss-configs/configuration/application-roles.properties $JBOSS_HOME/standalone/configuration/application-roles.properties - -RUN echo "JAVA_OPTS=\"\$JAVA_OPTS -Xms64m -Xmx4g -XX:MetaspaceSize=96M -XX:MaxMetaspaceSize=1g -Djboss.bind.address=0.0.0.0 -Djboss.bind.address.management=0.0.0.0 -Dmso.db=MARIADB -Dmso.config.path=/etc/mso/config.d/\"" >> $JBOSS_HOME/bin/standalone.conf -RUN echo "LAUNCH_JBOSS_IN_BACKGROUND=true" >> $JBOSS_HOME/bin/standalone.conf - -COPY ./maven/artifacts/* $JBOSS_HOME/standalone/deployments/ - -RUN mkdir -p /etc/mso/config.d/ASDC && chown -R jboss:jboss /etc/mso/config.d/ASDC && chmod u+xrw /etc/mso/config.d/ASDC - -COPY wait-for.sh / - -## Install heatbridge -#RUN apt-get install -y python && apt-get install -y python-pip && echo 'PIP Installed, doing upgrade' && pip install --upgrade pip -#RUN mkdir /opt/mso/heatbridge -#COPY heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl /opt/mso/heatbridge -#RUN pip install /opt/mso/heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl - -### Open Ports -EXPOSE 8080 - -VOLUME /shared - -### Start EAP -USER root -CMD ["/opt/mso/scripts/start-jboss-server.sh"] diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-app b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app index 27c6b58cd2..69b88d8905 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-app +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-app @@ -7,16 +7,27 @@ ARG https_proxy ENV HTTPS_PROXY=$https_proxy ENV https_proxy=$HTTPS_PROXY -RUN mkdir /app +RUN mkdir /app && mkdir /app/config && mkdir /app/certificates && mkdir /app/logs COPY maven/app.jar /app COPY configs/logging/logback-spring.xml /app -COPY scripts/startService.sh /app +COPY scripts/start-app.sh /app +COPY scripts/wait-for.sh /app -RUN chown -R so:so /app && chmod 700 /app/startService.sh +RUN chown -R so:so /app && chmod 700 /app/*.sh -VOLUME /tmp +## TODO for Casablanca: install this in the openstack-adapter container +## Install heatbridge +#RUN apt-get install -y python && apt-get install -y python-pip && echo 'PIP Installed, doing upgrade' && pip install --upgrade pip +#RUN mkdir /opt/mso/heatbridge +#COPY heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl /opt/mso/heatbridge +#RUN pip install /opt/mso/heatbridge/heatbridge-0.3.0.dev0-py2-none-any.whl + +# Springboot configuration (required) +VOLUME /app/config + +# Root certificates (optional) +VOLUME /app/ca-certificates WORKDIR /app -USER so:so -ENTRYPOINT /app/startService.sh +CMD ["/app/start-app.sh"] diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image index 9780018325..de446b734a 100644 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image +++ b/packages/docker/src/main/docker/docker-files/Dockerfile.so-base-image @@ -11,7 +11,7 @@ ENV https_proxy=$HTTPS_PROXY RUN apk update && apk upgrade # Install commonly needed tools -RUN apk --no-cache add curl sudo bash +RUN apk --no-cache add curl netcat-openbsd sudo # Create 'so' user -RUN addgroup -g 1000 so && adduser -S -u 1000 -G so so +RUN addgroup -g 1000 so && adduser -S -u 1000 -G so -s /bin/sh so diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.ubuntu-16.04-update b/packages/docker/src/main/docker/docker-files/Dockerfile.ubuntu-16.04-update deleted file mode 100644 index 8ed710745a..0000000000 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.ubuntu-16.04-update +++ /dev/null @@ -1,22 +0,0 @@ -FROM ubuntu:16.04 - -### File Author / Maintainer -MAINTAINER "The ONAP Team" -LABEL Description="This image contains an updated version of ubuntu 16.04" Version="1.0" - -ARG http_proxy -ARG https_proxy -ARG chef_repo_branch_name -ARG chef_repo_address -ARG chef_repo_git_name -ARG chef_repo_git_username -ENV HTTP_PROXY=$http_proxy -ENV HTTPS_PROXY=$https_proxy -ENV http_proxy=$HTTP_PROXY -ENV https_proxy=$HTTPS_PROXY - -### update first the image to fix potential security issues -RUN apt-get update -RUN apt-get -y dist-upgrade - - diff --git a/packages/docker/src/main/docker/docker-files/Dockerfile.wildfly-10 b/packages/docker/src/main/docker/docker-files/Dockerfile.wildfly-10 deleted file mode 100644 index df39659efd..0000000000 --- a/packages/docker/src/main/docker/docker-files/Dockerfile.wildfly-10 +++ /dev/null @@ -1,32 +0,0 @@ -FROM openecomp/ubuntu-update:1.0 - -### File Author / Maintainer -MAINTAINER "The ONAP Team" -LABEL Description="This image contains ONAP SO ubuntu base" Version="1.0" - -ARG http_proxy -ARG https_proxy -ARG chef_repo_branch_name -ARG chef_repo_address -ARG chef_repo_git_name -ARG chef_repo_git_username -ENV HTTP_PROXY=$http_proxy -ENV HTTPS_PROXY=$https_proxy -ENV http_proxy=$HTTP_PROXY -ENV https_proxy=$HTTPS_PROXY - -### Install OpenJDK -RUN apt-get -y update; \ - apt-get -y install openjdk-8-jre-headless - -### Install Wildfly -ENV JBOSS_HOME=/opt/jboss - -RUN WILDFLY=wildfly-10.1.0.Final.tar.gz; apt-get -y install curl; curl -LO http://download.jboss.org/wildfly/10.1.0.Final/$WILDFLY ; tar xvfz $WILDFLY -C /opt/; mv /opt/${WILDFLY%.tar.gz} $JBOSS_HOME; rm $WILDFLY; apt-get remove -y --purge curl; apt-get autoremove -y -RUN adduser --system --group jboss -RUN chown -R jboss $JBOSS_HOME -RUN $JBOSS_HOME/bin/add-user.sh admin Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U --silent - -USER jboss -CMD ["/opt/jboss/bin/standalone.sh", "-b", "0.0.0.0", "-bmanagement", "0.0.0.0"] - diff --git a/packages/docker/src/main/docker/docker-files/chef-configs/solo.rb b/packages/docker/src/main/docker/docker-files/chef-configs/solo.rb deleted file mode 100644 index 5e8247503a..0000000000 --- a/packages/docker/src/main/docker/docker-files/chef-configs/solo.rb +++ /dev/null @@ -1,9 +0,0 @@ -current_dir = File.dirname(__FILE__) -log_level :info -log_location STDOUT -node_name "mso" -syntax_check_cache_path "#{current_dir}/syntaxcache" -cookbook_path ["/var/berks-cookbooks"] -environment_path "/var/berks-cookbooks/CHEF_REPO_NAME_TO_REPLACE/environments" -environment "mso-docker" - diff --git a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-roles.properties b/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-roles.properties deleted file mode 100644 index cff4865c3d..0000000000 --- a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-roles.properties +++ /dev/null @@ -1,33 +0,0 @@ -# -# Properties declaration of users roles for the realm 'ApplicationRealm' which is the default realm -# for application services on a new installation. -# -# This includes the following protocols: remote ejb, remote jndi, web, remote jms -# -# Users can be added to this properties file at any time, updates after the server has started -# will be automatically detected. -# -# The format of this file is as follows: - -# username=role1,role2,role3 -# -# A utility script is provided which can be executed from the bin folder to add the users: - -# - Linux -# bin/add-user.sh -# -# - Windows -# bin\add-user.bat -# -# The following illustrates how an admin user could be defined. -# -#admin=PowerUser,BillingAdmin, -#guest=guest -CSIClient=CSI-Client -CCDClient=CCD-Client -GUIClient=GUI-Client -BPMNClient=BPMN-Client -InfraPortalClient=InfraPortal-Client -MSOClient=MSO-Client -sitecontrol=SiteControl-Client -MSO=AAIEmul-Client -BPELClient=BPEL-Client -SDNCClient=SDNC-Client diff --git a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-users.properties b/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-users.properties deleted file mode 100644 index f7b44d4283..0000000000 --- a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/application-users.properties +++ /dev/null @@ -1,35 +0,0 @@ -# -# Properties declaration of users for the realm 'ApplicationRealm' which is the default realm -# for application services on a new installation. -# -# This includes the following protocols: remote ejb, remote jndi, web, remote jms -# -# Users can be added to this properties file at any time, updates after the server has started -# will be automatically detected. -# -# The format of this realm is as follows: - -# username=HEX( MD5( username ':' realm ':' password)) -# -# A utility script is provided which can be executed from the bin folder to add the users: - -# - Linux -# bin/add-user.sh -# -# - Windows -# bin\add-user.bat -# -#$REALM_NAME=ApplicationRealm$ This line is used by the add-user utility to identify the realm name already used in this file. -# -# The following illustrates how an admin user could be defined, this -# is for illustration only and does not correspond to a usable password. -# -#admin=2a0923285184943425d1f53ddd58ec7a -CSIClient=0024f53a4ec012c22d9575a3710ed362 -CCDClient=c5e97286d4251605d8ef72f727ac1da6 -GUIClient=583075cf28c7c69c3a8b08356830b856 -BPMNClient=42b98ca2e0cc976d91a26c1495ecd529 -InfraPortalClient=e5077b432685a94babe332893337f6fc -MSOClient=72bc85031ae67afe67014c7663ae1033 -sitecontrol=9a3a360d86758f69ec9508725c017335 -MSO=a05cb60a04f41f750ce1fc60a2633534 -BPELClient=f2b4ce8ae1964050c0ad7e69bd88fd62 -SDNCClient=3c98dfba582d79948496b319e3edcb4b diff --git a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-groups.properties b/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-groups.properties deleted file mode 100644 index 44742a83c4..0000000000 --- a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-groups.properties +++ /dev/null @@ -1,22 +0,0 @@ -# -# Properties declaration of users groups for the realm 'ManagementRealm'. -# -# This is used for domain management, users groups membership information is used to assign the user -# specific management roles. -# -# Users can be added to this properties file at any time, updates after the server has started -# will be automatically detected. -# -# The format of this file is as follows: - -# username=role1,role2,role3 -# -# A utility script is provided which can be executed from the bin folder to add the users: - -# - Linux -# bin/add-user.sh -# -# - Windows -# bin\add-user.bat -# -# The following illustrates how an admin user could be defined. -# -#admin=PowerUser,BillingAdmin, \ No newline at end of file diff --git a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-users.properties b/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-users.properties deleted file mode 100644 index 1576e76f4e..0000000000 --- a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/mgmt-users.properties +++ /dev/null @@ -1,27 +0,0 @@ -# -# Properties declaration of users for the realm 'ManagementRealm' which is the default realm -# for new installations. Further authentication mechanism can be configured -# as part of the in standalone.xml. -# -# Users can be added to this properties file at any time, updates after the server has started -# will be automatically detected. -# -# By default the properties realm expects the entries to be in the format: - -# username=HEX( MD5( username ':' realm ':' password)) -# -# A utility script is provided which can be executed from the bin folder to add the users: - -# - Linux -# bin/add-user.sh -# -# - Windows -# bin\add-user.bat -# On start-up the server will also automatically add a user $local - this user is specifically -# for local tools running against this AS installation. -# -# The following illustrates how an admin user could be defined, this -# is for illustration only and does not correspond to a usable password. -# -admin=281905e1b4420050a7f07eecba66ee68 -# -#$REALM_NAME=ManagementRealm$ This line is used by the add-user utility to identify the realm name already used in this file. -# diff --git a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/standalone-full-ha.xml b/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/standalone-full-ha.xml deleted file mode 100644 index 5a1b52200f..0000000000 --- a/packages/docker/src/main/docker/docker-files/jboss-configs/configuration/standalone-full-ha.xml +++ /dev/null @@ -1,609 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - jdbc:mariadb://mariadb:3306/mso_requests?autoReconnect=true&connectTimeout=60000&socketTimeout=60000 - mariadb - TRANSACTION_READ_COMMITTED - - 10 - 100 - true - false - FailingConnectionOnly - - - mso - mso123 - - - - false - true - 20000 - true - - - - 15 - 30 - 1 - 3000 - - - - jdbc:mariadb://mariadb:3306/mso_catalog?autoReconnect=true&connectTimeout=60000&socketTimeout=60000 - mariadb - TRANSACTION_READ_COMMITTED - - 10 - 100 - true - false - FailingConnectionOnly - - - catalog - catalog123 - - - - false - true - 20000 - true - - - - 15 - 30 - 1 - 3000 - - - - jdbc:mariadb://mariadb:3306/camundabpmn?autoReconnect=true&connectTimeout=60000&socketTimeout=60000 - mariadb - set autocommit=1 - TRANSACTION_READ_COMMITTED - - 10 - 100 - true - false - FailingConnectionOnly - - - camunda - camunda123 - - - - - - - 32 - true - - - - jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE - h2 - - sa - sa - - - - - org.h2.jdbcx.JdbcDataSource - - - org.mariadb.jdbc.MySQLDataSource - - - - - - - - - false - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${jboss.bind.address:127.0.0.1} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/docker/src/main/docker/docker-files/jboss-configs/modules/mariadb/main/module.xml b/packages/docker/src/main/docker/docker-files/jboss-configs/modules/mariadb/main/module.xml deleted file mode 100644 index 1b127358ed..0000000000 --- a/packages/docker/src/main/docker/docker-files/jboss-configs/modules/mariadb/main/module.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/packages/docker/src/main/docker/docker-files/scripts/start-app.sh b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh new file mode 100644 index 0000000000..df2e646138 --- /dev/null +++ b/packages/docker/src/main/docker/docker-files/scripts/start-app.sh @@ -0,0 +1,90 @@ +#!/bin/sh + +if [ `id -u` = 0 ] +then + # Install certificates found in the /app/ca-certificates volume, if any. + + needUpdate=FALSE + + for certificate in `ls -1 /app/ca-certificates`; do + echo "Installing $certificate in /usr/local/share/ca-certificates" + cp /app/ca-certificates/$certificate /usr/local/share/ca-certificates/$certificate + needUpdate=TRUE + done + + if [ $needUpdate = TRUE ]; then + update-ca-certificates --fresh + fi + + # Re-exec this script as the 'so' user. + this=`readlink -f $0` + exec su so -c "$this" +fi + +touch /app/app.jar + +if [ -z "$APP" ]; then + echo "CONFIG ERROR: APP environment variable not set" + exit 1 +fi + +if [ ! -z "$DB_HOST" -a -z "$DB_PORT" ]; then + export DB_PORT=3306 +fi + +if [ -z "${CONFIG_PATH}" ]; then + export CONFIG_PATH=/app/config/override.yaml +fi + +if [ -z "${LOG_PATH}" ]; then + export LOG_PATH="logs/${APP}" +fi + +if [ ${APP} = "asdc-controller" ]; then + ln -s ${LOG_PATH} ASDC +fi + +if [ ${APP} = "bpmn-infra" ]; then + ln -s ${LOG_PATH} BPMN +fi + +if [ ${APP} = "openstack-adapter" ]; then + export DISABLE_SNI="-Djsse.enableSNIExtension=false" +fi + +if [ "${SSL_DEBUG}" = "log" ]; then + export SSL_DEBUG="-Djavax.net.debug=all" +else + export SSL_DEBUG= +fi + +# Set java keystore and truststore options, if specified in the environment. + +jksargs= + +if [ ! -z "${KEYSTORE}" ]; then + jksargs="$jksargs -Dmso.load.ssl.client.keystore=true" + jksargs="$jksargs -Djavax.net.ssl.keyStore=$KEYSTORE" + jksargs="$jksargs -Djavax.net.ssl.keyStorePassword=${KEYSTORE_PASSWORD}" +fi + +if [ ! -z "${TRUSTSTORE}" ]; then + jksargs="$jksargs -Djavax.net.ssl.trustStore=${TRUSTSTORE}" + jksargs="$jksargs -Djavax.net.ssl.trustStorePassword=${TRUSTSTORE_PASSWORD}" +fi + +jvmargs="${JVM_ARGS} -Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml $jksargs -Dspring.config.location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}" + +echo "JVM Arguments: ${jvmargs}" + +java ${jvmargs} -jar app.jar +rc=$? + +echo "Application exiting with status code $rc" + +if [ ! -z "${EXIT_DELAY}" -a "${EXIT_DELAY}" != 0 ]; then + echo "Delaying $APP exit for $EXIT_DELAY seconds" + sleep $EXIT_DELAY +fi + +exit $rc diff --git a/packages/docker/src/main/docker/docker-files/scripts/startService.sh b/packages/docker/src/main/docker/docker-files/scripts/startService.sh deleted file mode 100644 index 67e575b334..0000000000 --- a/packages/docker/src/main/docker/docker-files/scripts/startService.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -touch /app/app.jar -if [ -z "${TARGET_ENV}" ]; then - export TARGET_ENV="dev" -fi -export CONFIG_PATH=/app/config/override.yaml -if [ -z "${LOG_PATH}" ]; then - export LOG_PATH="./logs/apih" -fi -if [ ${LOG_PATH} = "./logs/asdc/" ]; then - ln -s /app/logs/asdc ASDC -fi -if [ ${LOG_PATH} = "./logs/bpmn/" ]; then - ln -s /app/logs/bpmn BPMN -fi -if [ "${SSL_DEBUG}" = "log" ]; then - export SSL_DEBUG="-Djavax.net.debug=all" -else - export SSL_DEBUG="" -fi - -op=`basename $LOG_PATH` -if [ $op = "openstack" ]; then - export DISABLE_SNI="-Djsse.enableSNIExtension=false" -fi - -JAVA_VERSION_MAJOR=$(java -Xinternalversion | sed -n 's/.*JRE ([0-9]\.\([0-9]\+\)\.[0-9].*/\1/p') -JAVA_VERSION_MINOR=$(java -Xinternalversion | sed -n 's/.*JRE ([0-9]\.[0-9]\+\.[0-9]_\([0-9]\+\).*/\1/p') - -if [[ ${JAVA_VERSION_MAJOR} -eq 8 && ${JAVA_VERSION_MINOR} -lt 131 ]]; then - if [[ ${LOG_PATH} = "./logs/bpmn/" ]]; then - jvmargs="-Xmx8g " - else - jvmargs="-Xmx4g " - fi -elif [[ ${JAVA_VERSION_MAJOR} -eq 8 && ${JAVA_VERSION_MINOR} -ge 131 ]] || [[ ${JAVA_VERSION_MAJOR} -eq 9 ]]; then - jvmargs="-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:MaxRAMFraction=1 " -fi - -jvmargs=${jvmargs}"-Dlogs_dir=${LOG_PATH} -Dlogging.config=/app/logback-spring.xml -Dmso.load.ssl.client.keystore=true -Djavax.net.ssl.keyStore=msoClientKeyStore-${TARGET_ENV}.jks -Djavax.net.ssl.keyStorePassword=${MSO_KEYSTORE_PASSWORD} -Djavax.net.ssl.trustStore=msoTrustStore.jks -Djavax.net.ssl.trustStorePassword=${MSO_TRUSTSTORE_PASSWORD} -Dspring.config.location=$CONFIG_PATH ${SSL_DEBUG} ${DISABLE_SNI}" - -echo JVM Arguments: ${jvmargs} - -java ${jvmargs} -jar app.jar diff --git a/packages/docker/src/main/docker/docker-files/scripts/wait-for.sh b/packages/docker/src/main/docker/docker-files/scripts/wait-for.sh new file mode 100755 index 0000000000..2525821878 --- /dev/null +++ b/packages/docker/src/main/docker/docker-files/scripts/wait-for.sh @@ -0,0 +1,85 @@ +#!/bin/sh +# https://github.com/Eficode/wait-for.git +# MIT License + +TIMEOUT=15 +QUIET=0 + +echoerr() { + if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi +} + +usage() { + exitcode="$1" + cat << USAGE >&2 +Usage: + $cmdname host:port [-t timeout] [-- command args] + -q | --quiet Do not output any status messages + -t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout + -- COMMAND ARGS Execute command with args after the test finishes +USAGE + exit "$exitcode" +} + +wait_for() { + command="$*" + if [ "$QUIET" -ne 1 ]; then echo "$0: probing host $HOST port $PORT"; fi + for i in `seq $TIMEOUT` ; do + nc -z "$HOST" "$PORT" > /dev/null 2>&1 + result=$? + if [ $result -eq 0 ] ; then + if [ "$QUIET" -ne 1 ]; then echo "$0: operation succeeded on try $i"; fi + if [ -n "$command" ] ; then + if [ "$QUIET" -ne 1 ]; then echo "$0: exec-ing command $command"; fi + exec $command + fi + exit 0 + fi + if [ "$QUIET" -ne 1 ]; then echo "$0: sleeping after try $i"; fi + sleep 1 + done + echo "$0: Operation timed out" >&2 + exit 1 +} + +while [ $# -gt 0 ] +do + case "$1" in + *:* ) + HOST=$(printf "%s\n" "$1"| cut -d : -f 1) + PORT=$(printf "%s\n" "$1"| cut -d : -f 2) + shift 1 + ;; + -q | --quiet) + QUIET=1 + shift 1 + ;; + -t) + TIMEOUT="$2" + if [ "$TIMEOUT" = "" ]; then break; fi + shift 2 + ;; + --timeout=*) + TIMEOUT="${1#*=}" + shift 1 + ;; + --) + shift + break + ;; + --help) + usage 0 + ;; + *) + echoerr "Unknown argument: $1" + usage 1 + ;; + esac +done + +if [ "$HOST" = "" -o "$PORT" = "" ]; then + echoerr "Error: you need to provide a host and port to test." + usage 2 +fi + +wait_for "$@" diff --git a/packages/docker/src/main/docker/docker-files/settings.xml b/packages/docker/src/main/docker/docker-files/settings.xml deleted file mode 100644 index 57c2179bad..0000000000 --- a/packages/docker/src/main/docker/docker-files/settings.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - - - - - - optional - false - http - - 8080 - localhost,127.0.0.1 - - - - - - mso-releases - #USERNAME# - #PASSWORD# - - - mso-snapshots - #USERNAME# - #PASSWORD# - - - mso-3rd-party - #USERNAME# - #PASSWORD# - - - diff --git a/packages/docker/src/main/docker/docker-files/wait-for.sh b/packages/docker/src/main/docker/docker-files/wait-for.sh deleted file mode 100755 index 2525821878..0000000000 --- a/packages/docker/src/main/docker/docker-files/wait-for.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh -# https://github.com/Eficode/wait-for.git -# MIT License - -TIMEOUT=15 -QUIET=0 - -echoerr() { - if [ "$QUIET" -ne 1 ]; then printf "%s\n" "$*" 1>&2; fi -} - -usage() { - exitcode="$1" - cat << USAGE >&2 -Usage: - $cmdname host:port [-t timeout] [-- command args] - -q | --quiet Do not output any status messages - -t TIMEOUT | --timeout=timeout Timeout in seconds, zero for no timeout - -- COMMAND ARGS Execute command with args after the test finishes -USAGE - exit "$exitcode" -} - -wait_for() { - command="$*" - if [ "$QUIET" -ne 1 ]; then echo "$0: probing host $HOST port $PORT"; fi - for i in `seq $TIMEOUT` ; do - nc -z "$HOST" "$PORT" > /dev/null 2>&1 - result=$? - if [ $result -eq 0 ] ; then - if [ "$QUIET" -ne 1 ]; then echo "$0: operation succeeded on try $i"; fi - if [ -n "$command" ] ; then - if [ "$QUIET" -ne 1 ]; then echo "$0: exec-ing command $command"; fi - exec $command - fi - exit 0 - fi - if [ "$QUIET" -ne 1 ]; then echo "$0: sleeping after try $i"; fi - sleep 1 - done - echo "$0: Operation timed out" >&2 - exit 1 -} - -while [ $# -gt 0 ] -do - case "$1" in - *:* ) - HOST=$(printf "%s\n" "$1"| cut -d : -f 1) - PORT=$(printf "%s\n" "$1"| cut -d : -f 2) - shift 1 - ;; - -q | --quiet) - QUIET=1 - shift 1 - ;; - -t) - TIMEOUT="$2" - if [ "$TIMEOUT" = "" ]; then break; fi - shift 2 - ;; - --timeout=*) - TIMEOUT="${1#*=}" - shift 1 - ;; - --) - shift - break - ;; - --help) - usage 0 - ;; - *) - echoerr "Unknown argument: $1" - usage 1 - ;; - esac -done - -if [ "$HOST" = "" -o "$PORT" = "" ]; then - echoerr "Error: you need to provide a host and port to test." - usage 2 -fi - -wait_for "$@" -- cgit 1.2.3-korg