This is an automated email from the ASF dual-hosted git repository.
jonzeolla pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/metron-bro-plugin-kafka.git
The following commit(s) were added to refs/heads/master by this push:
new 9f2cb11 METRON-2347 [BRO-PLUGIN-KAFKA] Use docker compose in end to
end tests (JonZeolla) closes apache/metron-bro-plugin-kafka#42
9f2cb11 is described below
commit 9f2cb11c10722ee19eb57d213bb4af180ea4f12b
Author: JonZeolla <[email protected]>
AuthorDate: Wed Apr 29 14:36:35 2020 -0400
METRON-2347 [BRO-PLUGIN-KAFKA] Use docker compose in end to end tests
(JonZeolla) closes apache/metron-bro-plugin-kafka#42
---
NOTICE | 4 +-
docker/README.md | 219 +++++++--------------
.../{bro-localbuild-container => bro}/.screenrc | 0
.../{bro-localbuild-container => bro}/Dockerfile | 24 ++-
docker/containers/bro/Makefile | 2 +
docker/containers/bro/requirements-to-freeze.txt | 1 +
docker/containers/bro/requirements.txt | 7 +
.../kafka/Dockerfile} | 22 +--
.../zookeeper/Dockerfile} | 22 +--
docker/docker-compose.yml | 35 ++++
docker/finish_end_to_end.sh | 7 +-
docker/in_docker_scripts/wait-for-it.sh | 162 ---------------
docker/run_end_to_end.sh | 83 +++-----
docker/scripts/build_container.sh | 113 -----------
docker/scripts/cleanup_docker.sh | 91 ---------
docker/scripts/create_docker_network.sh | 79 --------
docker/scripts/destroy_docker_network.sh | 76 -------
docker/scripts/docker_execute_build_bro_plugin.sh | 6 +-
.../scripts/docker_execute_configure_bro_plugin.sh | 4 +-
....sh => docker_execute_create_topic_in_kafka.sh} | 22 +--
docker/scripts/docker_execute_process_data_file.sh | 6 +-
docker/scripts/docker_execute_shell.sh | 4 +-
docker/scripts/docker_run_bro_container.sh | 168 ----------------
docker/scripts/docker_run_consume_kafka.sh | 6 +-
docker/scripts/docker_run_get_offset_kafka.sh | 6 +-
docker/scripts/docker_run_kafka_container.sh | 82 --------
docker/scripts/docker_run_wait_for_kafka.sh | 82 --------
docker/scripts/docker_run_wait_for_zookeeper.sh | 82 --------
docker/scripts/docker_run_zookeeper_container.sh | 82 --------
docker/scripts/stop_container.sh | 85 --------
30 files changed, 190 insertions(+), 1392 deletions(-)
diff --git a/NOTICE b/NOTICE
index 7f966de..accd03e 100644
--- a/NOTICE
+++ b/NOTICE
@@ -1,7 +1,5 @@
Apache Metron
- Copyright 2015-2018 The Apache Software Foundation
+ Copyright 2015-2020 The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
-
- This product bundles wait-for-it.sh, which is available under a "MIT
Software License" license. For details, see
https://github.com/vishnubob/wait-for-it
diff --git a/docker/README.md b/docker/README.md
index c82e247..6fa1972 100644
--- a/docker/README.md
+++ b/docker/README.md
@@ -25,14 +25,18 @@ testing scripts to be added to a pull request, and
subsequently to a test suite.
```bash
├── containers
-│ └── bro-localbuild-container
+│ └── bro
+│ └── kafka
+│ └── zookeeper
├── data
├── in_docker_scripts
├── scripts
└── test_output
```
- `containers`: The parent of all of the containers that this project defines.
We use several containers, not all of them ours.
- - `bro-localbuild-container`: The docker container directory for our bro
container, used for building bro, the librdkafka, and our plugin, as well as
running bro.
+ - `bro`: The directory for our bro container, used for building bro, the
librdkafka, and our plugin, as well as running bro.
+ - `kafka`: The directory for our kafka container.
+ - `zookeeper`: The directory for our zookeeper container.
- `data`: The default path for pcap data to be used in tests.
- `in_docker_scripts`: This directory is mapped to the bro docker container as
/root/built_in_scripts. These represent the library of scripts we provide to
be run in the docker container.
- `scripts`: These are the scripts that are run on the host for creating the
docker bits, running containers, running or executing commands against
containers ( such as executing one of the built_in_scripts ), and cleaning up
resources.
@@ -45,43 +49,27 @@ testing scripts to be added to a pull request, and
subsequently to a test suite.
├── build_bro_plugin.sh
├── configure_bro_plugin.sh
├── process_data_file.sh
-├── wait-for-it.sh
-├── wait_for_kafka.sh
-└── wait_for_zk.sh
```
- `build_bro_plugin.sh`: Runs `bro-pkg` to build and install the provided
version of the plugin.
- `configure_bro_plugin.sh`: Configures the plugin for the kafka container,
and routes all traffic types.
- `process_data_file.sh`: Runs `bro -r` on the passed file
-- `wait-for-it.sh`: Waits for a port to be open, so we know something is
available.
-- `wait_for_kafka.sh`: Waits for the kafka to be available.
-- `wait_for_zk.sh`: Waits for zookeeper to be available.
#### Scripts executed on the host to setup and interact with the docker
containers
```bash
├── analyze_results.sh
-├── build_container.sh
-├── cleanup_docker.sh
-├── create_docker_network.sh
-├── destroy_docker_network.sh
├── docker_execute_build_bro_plugin.sh
├── docker_execute_configure_bro_plugin.sh
+├── docker_execute_create_topic_in_kafka.sh
├── docker_execute_process_data_file.sh
├── docker_execute_shell.sh
-├── docker_run_bro_container.sh
├── docker_run_consume_kafka.sh
-├── docker_run_create_topic_in_kafka.sh
├── docker_run_get_offset_kafka.sh
-├── docker_run_kafka_container.sh
-├── docker_run_wait_for_kafka.sh
-├── docker_run_wait_for_zookeeper.sh
-├── docker_run_zookeeper_container.sh
├── download_sample_pcaps.sh
├── print_results.sh
├── split_kakfa_output_by_log.sh
-└── stop_container.sh
```
- `analyze_results.sh`: Analyzes the `results.csv` files for any issues
@@ -89,102 +77,45 @@ testing scripts to be added to a pull request, and
subsequently to a test suite.
```bash
--test-directory [REQUIRED] The directory for the tests
```
-- `build_container.sh`: Runs docker build in the passed directory, and names
the results
- ###### Parameters
- ```bash
- --container-directory [REQUIRED] The directory with the Dockerfile
- --container-name [REQUIRED] The name to give the Docker
container
- ```
-- `cleanup_containers.sh`: Stops the containers and destroys the network
- ###### Parameters
- ```bash
- --container-name [OPTIONAL] The Docker container name.
Default: bro
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
- ```
-- `create_docker_network.sh`: Creates the Docker network that the containers
will use
+- `docker_execute_build_bro_plugin.sh`: Executes `build_bro_plugin.sh` in the
bro container
###### Parameters
```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
+ --container-name [OPTIONAL] The Docker container name.
Default: metron-bro-plugin-kafka_bro_1
```
-- `destroy_docker_network.sh`: Destroys a Docker network by calling `docker
network rm`
+- `docker_execute_configure_bro_plugin.sh`: Executes `configure_bro_plugin.sh`
in the bro container
###### Parameters
```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
+ --container-name [OPTIONAL] The Docker container name.
Default: metron-bro-plugin-kafka_bro_1
```
-- `docker_execute_build_bro_plugin.sh`: Executes `build_bro_plugin.sh` in the
bro container
+- `docker_execute_create_topic_in_kafka.sh`: Creates the specified kafka topic
in the kafka container
###### Parameters
```bash
- --container-name [OPTIONAL] The Docker container name.
Default: bro
- ```
-- `docker_execute_configure_bro_plugin.sh`: Executes `configure_bro_plugin.sh`
in the bro container
- ###### Parameters
- ```bash
- --container-name [OPTIONAL] The Docker container name.
Default: bro
+ --container-name [OPTIONAL] The Docker container name.
Default: metron-bro-plugin-kafka_kafka_1
+ --kafka-topic [OPTIONAL] The kafka topic to create.
Default: bro
```
-- `docker_execute_process_data_dir.sh`: Executes `process_data_dir.sh` in the
bro container
+- `docker_execute_process_data_file.sh`: Executes `process_data_file.sh` in
the bro container
###### Parameters
```bash
- --container-name [OPTIONAL] The Docker container name.
Default: bro
+ --container-name [OPTIONAL] The Docker container name.
Default: metron-bro-plugin-kafka_bro_1
```
- `docker_execute_shell.sh`: `docker execute -i -t bash` to get a shell in a
given container
###### Parameters
```bash
- --container-name [OPTIONAL] The Docker container name.
Default: bro
- ```
-- `docker_run_bro_container.sh`: Runs the bro docker container in the
background
- ###### Parameters
- ```bash
- --container-name [OPTIONAL] The Docker container name.
Default: bro
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
- --scripts-path [OPTIONAL] The path with the scripts you may
run in the container. These are your scripts, not the built in scripts
- --data-path [OPTIONAL] The name of the directory to map
to /root/data in the container
- --docker-parameter [OPTIONAL, MULTIPLE] Each parameter with
this name will be passed to docker run
+ --container-name [OPTIONAL] The Docker container name.
Default: metron-bro-plugin-kafka_bro_1
```
-
- > NOTE about `--scripts-path`
- > The scripts path provided with be mapped into the bro container at
`/root/scripts`. This allows you to _inject_ your own scripts (not managed as
part of this source project) into the container.
- > You can then execute these scripts or use them together as part of testing
etc. by creating `docker execute` scripts like those here.
- > The goal is to allow an individual to use and maintain their own library
of scripts to use instead of, or in concert with the scripts maintained by this
project.
-
- `docker_run_consume_kafka.sh`: Runs an instance of the kafka container, with
the console consumer `kafka-console-consumer.sh --topic $KAFKA_TOPIC --offset
$OFFSET --partition 0 --bootstrap-server kafka:9092`
###### Parameters
```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
+ --network-name [OPTIONAL] The Docker network name. Default:
metron-bro-plugin-kafka_default
--offset [OPTIONAL] The kafka offset. Default: 0
--kafka-topic [OPTIONAL] The kafka topic to consume from.
Default: bro
```
- `docker_run_get_offset_kafka.sh`: Runs an instance of the kafka container
and gets the current offset for the specified topic
###### Parameters
```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
+ --network-name [OPTIONAL] The Docker network name. Default:
metron-bro-plugin-kafka_default
--kafka-topic [OPTIONAL] The kafka topic to get the offset
from. Default: bro
```
-- `docker_run_create_topic_in_kafka.sh`: Runs an instance of the kafka
container, creating the specified topic
- ###### Parameters
- ```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
- --kafka-topic [OPTIONAL] The kafka topic to create.
Default: bro
- ```
-- `docker_run_kafka_container.sh`: Runs the main instance of the kafka
container in the background
- ###### Parameters
- ```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
- ```
-- `docker_run_wait_for_kafka.sh`: Runs the `wait_for_kafka.sh` in a base
centos container
- ###### Parameters
- ```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
- ```
-- `docker_run_wait_for_zookeeper.sh`: Runs the `wait_for_zk.sh` in a base
centos container
- ###### Parameters
- ```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
- ```
-- `docker_run_zookeeper_container.sh`: Runs the zookeeper container in the
background
- ###### Parameters
- ```bash
- --network-name [OPTIONAL] The Docker network name. Default:
bro-network
- ```
- `download_sample_pcaps.sh`: Downloads the sample pcaps to a specified
directory. If they exist, it is a no-op
> The sample pcaps are:
@@ -209,74 +140,60 @@ testing scripts to be added to a pull request, and
subsequently to a test suite.
```bash
--log-directory [REQUIRED] The directory with the logs
```
-- `stop_container.sh`: Stops and removes a Docker container with a given name
- ###### Parameters
- ```bash
- --container-name [REQUIRED] The Docker container name
- ```
#### The example end to end test script
`run_end_to_end.sh` is provided as an example of a testing script. Specific
or extended scripts can be created similar to this script to use the containers.
This script does the following:
-1. Creates the Docker network
-2. Runs the zookeeper container
-3. Waits for zookeeper to be available
-4. Runs the kafka container
-5. Waits for kafka to be available
-6. Creates the specified topic
-7. Downloads sample PCAP data
-8. Runs the bro container in the background
-
-> Note that all parameters passed to this script are passed to the
`docker_run_bro_container.sh` script
-
-9. Builds the bro plugin
-10. Configures the bro plugin
-11. Runs bro against all the pcap data, one at a time
-12. Executes a kafka client to read the data from bro for each pcap file
-13. Stores the output kafka messages and the bro logs into the test_output
directory
-
-```bash
->tree Tue_Jan__8_21_54_10_EST_2019
-Tue_Jan__8_21_54_10_EST_2019
-├── exercise-traffic_pcap
-│ ├── capture_loss.log
-│ ├── conn.log
-│ ├── dhcp.log
-│ ├── dns.log
-│ ├── files.log
-│ ├── http.log
-│ ├── kafka-output.log
-│ ├── known_certs.log
-│ ├── known_devices.log
-│ ├── loaded_scripts.log
-│ ├── notice.log
-│ ├── packet_filter.log
-│ ├── reporter.log
-│ ├── smtp.log
-│ ├── software.log
-│ ├── ssl.log
-│ ├── stats.log
-│ ├── weird.log
-│ └── x509.log
-├── ftp_pcap
-│ ├── capture_loss.log
-│ ├── conn.log
-│ ├── files.log
-│ ├── ftp.log
-│ ├── kafka-output.log
-│ ├── loaded_scripts.log
-│ ├── packet_filter.log
-│ ├── reporter.log
-│ ├── software.log
-│ └── stats.log
-```
-
-14. Creates a results.csv for each pcap that has the line counts of the kafka
and the bro output for each log
-15. Prints all the results.csv to the screen
-
-As we can see, the output is a folder named for the test run time, with a sub
folder per pcap, containing all the bro logs and the kafka_output.log.
+1. Runs docker compose
+1. Creates the specified topic
+1. Downloads sample PCAP data
+1. Runs the bro container in the background
+1. Builds the bro plugin
+1. Configures the bro plugin
+1. Runs bro against all the pcap data, one at a time
+1. Executes a kafka client to read the data from bro for each pcap file
+1. Stores the output kafka messages and the bro logs into the test_output
directory
+ ```bash
+ >tree Tue_Jan__8_21_54_10_EST_2019
+ Tue_Jan__8_21_54_10_EST_2019
+ ├── exercise-traffic_pcap
+ │ ├── capture_loss.log
+ │ ├── conn.log
+ │ ├── dhcp.log
+ │ ├── dns.log
+ │ ├── files.log
+ │ ├── http.log
+ │ ├── kafka-output.log
+ │ ├── known_certs.log
+ │ ├── known_devices.log
+ │ ├── loaded_scripts.log
+ │ ├── notice.log
+ │ ├── packet_filter.log
+ │ ├── reporter.log
+ │ ├── smtp.log
+ │ ├── software.log
+ │ ├── ssl.log
+ │ ├── stats.log
+ │ ├── weird.log
+ │ └── x509.log
+ ├── ftp_pcap
+ │ ├── capture_loss.log
+ │ ├── conn.log
+ │ ├── files.log
+ │ ├── ftp.log
+ │ ├── kafka-output.log
+ │ ├── loaded_scripts.log
+ │ ├── packet_filter.log
+ │ ├── reporter.log
+ │ ├── software.log
+ │ └── stats.log
+ ```
+1. Creates a results.csv for each pcap that has the line counts of the kafka
and the bro output for each log
+1. Prints all the results.csv to the screen
+
+As we can see, the output is a folder named for the test run time, with a sub
folder per pcap, containing all the bro logs and the `kafka_output.log`.
At this point the containers are up and running in the background.
@@ -286,7 +203,7 @@ Other scripts may then be used to do your testing, for
example running:
./scripts/docker_execute_shell.sh
```
-> NOTE: If the scripts are run repeatedly, and there is no change in bro or
the librdkafka, the line `./run_end_to_end.sh` can be replaced by
`./run_end_to_end.sh --skip-docker-build`, which uses the `--skip-docker-build`
flag to not rebuild the bro container, saving the time of rebuilding bro and
librdkafka.
+> NOTE: If the scripts are run repeatedly, and there is no change in bro or
the librdkafka, the line `./run_end_to_end.sh` can be replaced by
`./run_end_to_end.sh --skip-docker-build`, which uses the `--skip-docker-build`
flag to not rebuild the containers, saving the significant time of rebuilding
bro and librdkafka.
> NOTE: After you are done, you must call the `finish_end_to_end.sh` script to
> cleanup.
diff --git a/docker/containers/bro-localbuild-container/.screenrc
b/docker/containers/bro/.screenrc
similarity index 100%
rename from docker/containers/bro-localbuild-container/.screenrc
rename to docker/containers/bro/.screenrc
diff --git a/docker/containers/bro-localbuild-container/Dockerfile
b/docker/containers/bro/Dockerfile
similarity index 77%
rename from docker/containers/bro-localbuild-container/Dockerfile
rename to docker/containers/bro/Dockerfile
index 9b34baa..3de49e6 100644
--- a/docker/containers/bro-localbuild-container/Dockerfile
+++ b/docker/containers/bro/Dockerfile
@@ -15,7 +15,8 @@
# limitations under the License.
#
FROM centos:7
-WORKDIR /root
+ARG BRO_VERSION
+ARG LIBRDKAFKA_VERSION
# install development tools
RUN yum -y groupinstall "Development Tools" && \
@@ -26,13 +27,14 @@ RUN yum -y groupinstall "Development Tools" && \
cyrus-sasl cyrus-sasl-devel cyrus-sasl-gssapi \
git jq screen tree vim
-# copy in the screen -rc
+# copy in the .screenrc
COPY .screenrc /root
# install bro
+WORKDIR /root
RUN git clone https://github.com/bro/bro
WORKDIR bro/
-RUN git checkout v2.5.5
+RUN git checkout "v${BRO_VERSION}"
RUN git submodule update --init --recursive
RUN ./configure
RUN make
@@ -40,19 +42,21 @@ RUN make install
ENV PATH="${PATH}:/usr/local/bro/bin"
ENV PATH="${PATH}:/usr/bin"
-# install pip
+# install pip3 and bro-pkg
+WORKDIR /root
+COPY requirements.txt requirements.txt
RUN yum -y update && \
yum -y install epel-release && \
- yum -y install python-pip && \
+ yum -y install python3-pip && \
yum clean all && \
- pip install --upgrade pip && \
- pip install bro-pkg && \
+ python3 -m pip install --upgrade pip && \
+ python3 -m pip install -r requirements.txt && \
bro-pkg autoconfig
# install librdkafka
-RUN curl -L https://github.com/edenhill/librdkafka/archive/v0.11.5.tar.gz |
tar xvz
-WORKDIR librdkafka-0.11.5/
+WORKDIR /root
+RUN curl -L
"https://github.com/edenhill/librdkafka/archive/v${LIBRDKAFKA_VERSION}.tar.gz"
| tar xvz
+WORKDIR "librdkafka-${LIBRDKAFKA_VERSION}/"
RUN ./configure --enable-sasl
RUN make
RUN make install
-WORKDIR /root
diff --git a/docker/containers/bro/Makefile b/docker/containers/bro/Makefile
new file mode 100644
index 0000000..d54f398
--- /dev/null
+++ b/docker/containers/bro/Makefile
@@ -0,0 +1,2 @@
+requirements: requirements-to-freeze.txt
+ @docker run --rm -v $$(pwd):/usr/src/app/ python:3 /bin/bash -c
"python3 -m pip install --upgrade pip && python3 -m pip install -r
/usr/src/app/requirements-to-freeze.txt && python3 -m pip freeze >
/usr/src/app/requirements.txt"
diff --git a/docker/containers/bro/requirements-to-freeze.txt
b/docker/containers/bro/requirements-to-freeze.txt
new file mode 100644
index 0000000..04cb725
--- /dev/null
+++ b/docker/containers/bro/requirements-to-freeze.txt
@@ -0,0 +1 @@
+bro-pkg
diff --git a/docker/containers/bro/requirements.txt
b/docker/containers/bro/requirements.txt
new file mode 100644
index 0000000..6303830
--- /dev/null
+++ b/docker/containers/bro/requirements.txt
@@ -0,0 +1,7 @@
+bro-pkg==2.1.2
+btest==0.61
+configparser==5.0.0
+gitdb==4.0.4
+GitPython==3.1.1
+semantic-version==2.8.4
+smmap==3.0.2
diff --git a/docker/in_docker_scripts/wait_for_kafka.sh
b/docker/containers/kafka/Dockerfile
old mode 100755
new mode 100644
similarity index 73%
rename from docker/in_docker_scripts/wait_for_kafka.sh
rename to docker/containers/kafka/Dockerfile
index 56045f4..3755d35
--- a/docker/in_docker_scripts/wait_for_kafka.sh
+++ b/docker/containers/kafka/Dockerfile
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -16,20 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-shopt -s nocasematch
-
-#
-# Waits until kafka is available on the default port
-#
-
-cd /root || exit 1
-
-if [ ! -d /root/scripts ]; then
- echo "DOCKER_SCRIPTS_PATH has not been set and mapped"
- exit 1
-fi
-
-cd /root/scripts || exit 1
-bash ./wait-for-it.sh kafka:9092
-
+FROM ches/kafka:0.10.2.1
+HEALTHCHECK --interval=5s --timeout=10s --start-period=2s --retries=2 \
+ CMD JMX_PORT= /kafka/bin/kafka-configs.sh --describe --zookeeper
zookeeper:2181 --entity-type brokers || exit 1
diff --git a/docker/in_docker_scripts/wait_for_zk.sh
b/docker/containers/zookeeper/Dockerfile
old mode 100755
new mode 100644
similarity index 73%
rename from docker/in_docker_scripts/wait_for_zk.sh
rename to docker/containers/zookeeper/Dockerfile
index db8c1ff..71af679
--- a/docker/in_docker_scripts/wait_for_zk.sh
+++ b/docker/containers/zookeeper/Dockerfile
@@ -1,5 +1,3 @@
-#!/usr/bin/env bash
-
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
@@ -16,20 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-
-shopt -s nocasematch
-
-#
-# Waits until zookeeper is available on the default port
-#
-
-cd /root || exit 1
-
-if [ ! -d /root/scripts ]; then
- echo "DOCKER_SCRIPTS_PATH has not been set and mapped"
- exit 1
-fi
-
-cd /root/scripts || exit 1
-bash ./wait-for-it.sh zookeeper:2181
-
+FROM zookeeper:3.4
+HEALTHCHECK --interval=2s --timeout=1s --start-period=.5s --retries=4 \
+ CMD echo ruok | nc localhost 2181 && echo stat | nc localhost 2181 | grep
Mode || exit 1
diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml
new file mode 100644
index 0000000..88b6b71
--- /dev/null
+++ b/docker/docker-compose.yml
@@ -0,0 +1,35 @@
+version: '2.4'
+services:
+ zookeeper:
+ build: containers/zookeeper
+ image: metron-bro-plugin-kafka_zookeeper:latest
+ ports:
+ - "2181:2181"
+ kafka:
+ build: containers/kafka
+ image: metron-bro-plugin-kafka_kafka:latest
+ depends_on:
+ zookeeper:
+ condition: service_healthy
+ environment:
+ - ZOOKEEPER_IP=zookeeper
+ ports:
+ - "9092:9092"
+ bro:
+ build:
+ context: containers/bro
+ args:
+ BRO_VERSION: "2.5.5"
+ LIBRDKAFKA_VERSION: "0.11.5"
+ image: metron-bro-plugin-kafka_bro:latest
+ depends_on:
+ zookeeper:
+ condition: service_healthy
+ kafka:
+ condition: service_healthy
+ volumes:
+ - "${DATA_PATH}:/root/data"
+ - "${TEST_OUTPUT_PATH}:/root/test_output"
+ - "${PLUGIN_ROOT_DIR}:/root/code"
+ - "${OUR_SCRIPTS_PATH}:/root/built_in_scripts"
+ tty: true
diff --git a/docker/finish_end_to_end.sh b/docker/finish_end_to_end.sh
index 1c43d79..bb753e4 100755
--- a/docker/finish_end_to_end.sh
+++ b/docker/finish_end_to_end.sh
@@ -28,8 +28,7 @@ set -e # errexit
set -E # errtrap
set -o pipefail
-ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
-
-# Stop all the containers and remote the networks
-bash "${ROOT_DIR}"/scripts/cleanup_docker.sh
+PROJECT_NAME="metron-bro-plugin-kafka"
+# Stop docker compose
+COMPOSE_PROJECT_NAME="${PROJECT_NAME}" docker-compose down
diff --git a/docker/in_docker_scripts/wait-for-it.sh
b/docker/in_docker_scripts/wait-for-it.sh
deleted file mode 100755
index 73abf05..0000000
--- a/docker/in_docker_scripts/wait-for-it.sh
+++ /dev/null
@@ -1,162 +0,0 @@
-#!/usr/bin/env bash
-# shellcheck disable=SC2064,SC2124,SC2206,SC2086
-# Use this script to test if a given TCP host/port are available
-
-cmdname=$(basename $0)
-
-echoerr() { if [[ $QUIET -ne 1 ]]; then echo "$@" 1>&2; fi }
-
-usage()
-{
- cat << USAGE >&2
-Usage:
- $cmdname host:port [-s] [-t timeout] [-- command args]
- -h HOST | --host=HOST Host or IP under test
- -p PORT | --port=PORT TCP port under test
- Alternatively, you specify the host and port
as host:port
- -s | --strict Only execute subcommand if the test succeeds
- -q | --quiet Don't 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 1
-}
-
-wait_for()
-{
- if [[ $TIMEOUT -gt 0 ]]; then
- echoerr "$cmdname: waiting $TIMEOUT seconds for $HOST:$PORT"
- else
- echoerr "$cmdname: waiting for $HOST:$PORT without a timeout"
- fi
- start_ts=$(date +%s)
- while :
- do
- (echo > /dev/tcp/$HOST/$PORT) >/dev/null 2>&1
- result=$?
- if [[ $result -eq 0 ]]; then
- end_ts=$(date +%s)
- echoerr "$cmdname: $HOST:$PORT is available after $((end_ts -
start_ts)) seconds"
- break
- fi
- sleep 1
- done
- return $result
-}
-
-wait_for_wrapper()
-{
- # In order to support SIGINT during timeout:
http://unix.stackexchange.com/a/57692
- if [[ $QUIET -eq 1 ]]; then
- timeout $TIMEOUT $0 --quiet --child --host=$HOST --port=$PORT
--timeout=$TIMEOUT &
- else
- timeout $TIMEOUT $0 --child --host=$HOST --port=$PORT
--timeout=$TIMEOUT &
- fi
- PID=$!
- trap "kill -INT -$PID" INT
- wait $PID
- RESULT=$?
- if [[ $RESULT -ne 0 ]]; then
- echoerr "$cmdname: timeout occurred after waiting $TIMEOUT seconds for
$HOST:$PORT"
- fi
- return $RESULT
-}
-
-# process arguments
-while [[ $# -gt 0 ]]
-do
- case "$1" in
- *:* )
- hostport=(${1//:/ })
- HOST=${hostport[0]}
- PORT=${hostport[1]}
- shift 1
- ;;
- --child)
- CHILD=1
- shift 1
- ;;
- -q | --quiet)
- QUIET=1
- shift 1
- ;;
- -s | --strict)
- STRICT=1
- shift 1
- ;;
- -h)
- HOST="$2"
- if [[ $HOST == "" ]]; then break; fi
- shift 2
- ;;
- --host=*)
- HOST="${1#*=}"
- shift 1
- ;;
- -p)
- PORT="$2"
- if [[ $PORT == "" ]]; then break; fi
- shift 2
- ;;
- --port=*)
- PORT="${1#*=}"
- shift 1
- ;;
- -t)
- TIMEOUT="$2"
- if [[ $TIMEOUT == "" ]]; then break; fi
- shift 2
- ;;
- --timeout=*)
- TIMEOUT="${1#*=}"
- shift 1
- ;;
- --)
- shift
- CLI="$@"
- break
- ;;
- --help)
- usage
- ;;
- *)
- echoerr "Unknown argument: $1"
- usage
- ;;
- esac
-done
-
-if [[ "$HOST" == "" || "$PORT" == "" ]]; then
- echoerr "Error: you need to provide a host and port to test."
- usage
-fi
-
-TIMEOUT=${TIMEOUT:-15}
-STRICT=${STRICT:-0}
-CHILD=${CHILD:-0}
-QUIET=${QUIET:-0}
-
-if [[ $CHILD -gt 0 ]]; then
- wait_for
- RESULT=$?
- exit $RESULT
-else
- if [[ $TIMEOUT -gt 0 ]]; then
- wait_for_wrapper
- RESULT=$?
- else
- wait_for
- RESULT=$?
- fi
-fi
-
-if [[ $CLI != "" ]]; then
- if [[ $RESULT -ne 0 && $STRICT -eq 1 ]]; then
- echoerr "$cmdname: strict mode, refusing to execute subprocess"
- exit $RESULT
- fi
- exec $CLI
-else
- exit $RESULT
-fi
diff --git a/docker/run_end_to_end.sh b/docker/run_end_to_end.sh
index 6d003b0..1fcd553 100755
--- a/docker/run_end_to_end.sh
+++ b/docker/run_end_to_end.sh
@@ -49,18 +49,19 @@ NO_PCAP=false
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
PLUGIN_ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && cd .. > /dev/null &&
pwd)"
SCRIPT_DIR="${ROOT_DIR}"/scripts
-CONTAINER_DIR="${ROOT_DIR}"/containers/bro-localbuild-container
DATA_PATH="${ROOT_DIR}"/data
DATE=$(date)
LOG_DATE=${DATE// /_}
TEST_OUTPUT_PATH="${ROOT_DIR}/test_output/"${LOG_DATE//:/_}
KAFKA_TOPIC="bro"
+PROJECT_NAME="metron-bro-plugin-kafka"
+OUR_SCRIPTS_PATH="${PLUGIN_ROOT_DIR}/docker/in_docker_scripts"
cd "${PLUGIN_ROOT_DIR}" || { echo "NO PLUGIN ROOT" ; exit 1; }
# we may not be checked out from git, check and make it so that we are since
# bro-pkg requires it
-git status 2&>1
+git status &>/dev/null
rc=$?; if [[ ${rc} != 0 ]]; then
echo "bro-pkg requires the plugin to be a git repo, creating..."
git init .
@@ -147,80 +148,48 @@ for i in "$@"; do
esac
done
-EXTRA_ARGS="$*"
cd "${ROOT_DIR}" || { echo "NO ROOT" ; exit 1; }
-echo "Running build_container with "
+echo "Running docker compose with "
echo "SKIP_REBUILD_BRO = ${SKIP_REBUILD_BRO}"
echo "DATA_PATH = ${DATA_PATH}"
echo "KAFKA_TOPIC = ${KAFKA_TOPIC}"
echo "PLUGIN_VERSION = ${PLUGIN_VERSION}"
echo "==================================================="
-# Create the network
-bash "${SCRIPT_DIR}"/create_docker_network.sh
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-# Run the zookeeper container
-bash "${SCRIPT_DIR}"/docker_run_zookeeper_container.sh
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-# Wait for zookeeper to be up
-bash "${SCRIPT_DIR}"/docker_run_wait_for_zookeeper.sh
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-# Run the kafka container
-bash "${SCRIPT_DIR}"/docker_run_kafka_container.sh
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-# Wait for kafka to be up
-bash "${SCRIPT_DIR}"/docker_run_wait_for_kafka.sh
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
+# Run docker compose, rebuilding as specified
+if [[ "$SKIP_REBUILD_BRO" = false ]]; then
+ COMPOSE_PROJECT_NAME="${PROJECT_NAME}" \
+ DATA_PATH=${DATA_PATH} \
+ TEST_OUTPUT_PATH=${TEST_OUTPUT_PATH} \
+ PLUGIN_ROOT_DIR=${PLUGIN_ROOT_DIR} \
+ OUR_SCRIPTS_PATH=${OUR_SCRIPTS_PATH} \
+ docker-compose up -d --build
+ rc=$?; if [[ ${rc} != 0 ]]; then
+ exit ${rc}
+ fi
+else
+ COMPOSE_PROJECT_NAME="${PROJECT_NAME}" \
+ DATA_PATH=${DATA_PATH} \
+ TEST_OUTPUT_PATH=${TEST_OUTPUT_PATH} \
+ PLUGIN_ROOT_DIR=${PLUGIN_ROOT_DIR} \
+ OUR_SCRIPTS_PATH=${OUR_SCRIPTS_PATH} \
+ docker-compose up -d
+ rc=$?; if [[ ${rc} != 0 ]]; then
+ exit ${rc}
+ fi
fi
# Create the kafka topic
-bash "${SCRIPT_DIR}"/docker_run_create_topic_in_kafka.sh
--kafka-topic="${KAFKA_TOPIC}"
+bash "${SCRIPT_DIR}"/docker_execute_create_topic_in_kafka.sh
--kafka-topic="${KAFKA_TOPIC}"
rc=$?; if [[ ${rc} != 0 ]]; then
exit ${rc}
fi
-# Build the bro container
-if [[ "$SKIP_REBUILD_BRO" = false ]]; then
- bash "${SCRIPT_DIR}"/build_container.sh \
- --container-directory="${CONTAINER_DIR}" \
- --container-name=metron-bro-docker-container:latest
-
- rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
- fi
-fi
-
# Download the pcaps
bash "${SCRIPT_DIR}"/download_sample_pcaps.sh --data-path="${DATA_PATH}"
-
# By not catching $? here we are accepting that a failed pcap download will not
# exit the script
-mkdir "${TEST_OUTPUT_PATH}" || exit 1
-
-# Run the bro container and optionally the passed script _IN_ the container
-bash "${SCRIPT_DIR}"/docker_run_bro_container.sh \
- --data-path="${DATA_PATH}" \
- --test-output-path="${TEST_OUTPUT_PATH}" \
- "$EXTRA_ARGS"
-
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
# Build the bro plugin
bash "${SCRIPT_DIR}"/docker_execute_build_bro_plugin.sh
--plugin-version="${PLUGIN_VERSION}"
rc=$?; if [[ ${rc} != 0 ]]; then
diff --git a/docker/scripts/build_container.sh
b/docker/scripts/build_container.sh
deleted file mode 100755
index 40810db..0000000
--- a/docker/scripts/build_container.sh
+++ /dev/null
@@ -1,113 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-#
-# Runs docker build in a provided directory, with a provided name
-#
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --container-directory [REQUIRED] The directory with the
Dockerfile"
- echo " --container-name [REQUIRED] The name to give the
Docker container"
- echo " -h/--help Usage information."
- echo " "
- echo " "
-}
-
-SCRIPT_NAME=$(basename -- "$0")
-CONTAINER_DIRECTORY=
-CONTAINER_NAME=
-
-# Handle command line options
-for i in "$@"; do
- case $i in
- #
- # CONTAINER_DIRECTORY
- #
- # --container-directory
- #
- --container-directory=*)
- CONTAINER_DIRECTORY="${i#*=}"
- shift # past argument=value
- ;;
-
- #
- # CONTAINER_NAME
- #
- # --container-name
- #
- --container-name=*)
- CONTAINER_NAME="${i#*=}"
- shift # past argument=value
- ;;
-
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-if [[ -z "$CONTAINER_DIRECTORY" ]]; then
- echo "CONTAINER_DIRECTORY must be passed"
- exit 1
-fi
-
-if [[ -z "$CONTAINER_NAME" ]]; then
- echo "CONTAINER_NAME must be passed"
- exit 1
-fi
-
-echo "Running ${SCRIPT_NAME} with"
-echo "CONTAINER_DIRECTORY = $CONTAINER_DIRECTORY"
-echo "CONTAINER_NAME = $CONTAINER_NAME"
-echo "==================================================="
-
-# Move over to the docker area
-cd "${CONTAINER_DIRECTORY}" || exit 1
-echo "==================================================="
-echo "docker build of ${CONTAINER_NAME}"
-echo "==================================================="
-
-docker build . --no-cache --tag="${CONTAINER_NAME}"
-
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
diff --git a/docker/scripts/cleanup_docker.sh b/docker/scripts/cleanup_docker.sh
deleted file mode 100755
index 5a95e3a..0000000
--- a/docker/scripts/cleanup_docker.sh
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-#
-# Stops the containers, and shuts down the NETWORK_NAME
-#
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --container-name [OPTIONAL] The Docker container
name. Default: bro"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " -h/--help Usage information."
- echo " "
- echo " "
-}
-
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && pwd)"
-
-CONTAINER_NAME=bro
-NETWORK_NAME=bro-network
-
-# handle command line options
-for i in "$@"; do
- case $i in
-
- #
- # CONTAINER_NAME
- #
- # --container-name
- #
- --container-name=*)
- CONTAINER_NAME="${i#*=}"
- shift # past argument
- ;;
-
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument
- ;;
-
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
- esac
-done
-
-echo "Running cleanup_containers with "
-echo "CONTAINER_NAME = $CONTAINER_NAME"
-echo "NETWORK_NAME = $NETWORK_NAME"
-echo "==================================================="
-
-"${SCRIPT_DIR}"/stop_container.sh --container-name="${CONTAINER_NAME}"
-
-"${SCRIPT_DIR}"/stop_container.sh --container-name=kafka
-
-"${SCRIPT_DIR}"/stop_container.sh --container-name=zookeeper
-
-"${SCRIPT_DIR}"/destroy_docker_network.sh --network-name="${NETWORK_NAME}"
-
diff --git a/docker/scripts/create_docker_network.sh
b/docker/scripts/create_docker_network.sh
deleted file mode 100755
index efa1684..0000000
--- a/docker/scripts/create_docker_network.sh
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " -h/--help Usage information."
- echo " "
-}
-
-NETWORK_NAME=bro-network
-
-# handle command line options
-for i in "$@"; do
- case $i in
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument=value
- ;;
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-echo "Running create_docker_network with "
-echo "NETWORK_NAME = $NETWORK_NAME"
-echo "==================================================="
-
-docker network create "${NETWORK_NAME}"
-
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-echo "Created network ${NETWORK_NAME}"
-
diff --git a/docker/scripts/destroy_docker_network.sh
b/docker/scripts/destroy_docker_network.sh
deleted file mode 100755
index 516c33c..0000000
--- a/docker/scripts/destroy_docker_network.sh
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " -h/--help Usage information"
- echo " "
-}
-
-NETWORK_NAME=bro-network
-
-# handle command line options
-for i in "$@"; do
- case $i in
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument=value
- ;;
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-echo "Running destroy_docker_network with "
-echo "NETWORK_NAME = $NETWORK_NAME"
-echo "==================================================="
-
-docker network rm "${NETWORK_NAME}"
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
diff --git a/docker/scripts/docker_execute_build_bro_plugin.sh
b/docker/scripts/docker_execute_build_bro_plugin.sh
index 2db600d..4c4d9ee 100755
--- a/docker/scripts/docker_execute_build_bro_plugin.sh
+++ b/docker/scripts/docker_execute_build_bro_plugin.sh
@@ -1,4 +1,4 @@
-#!/usr/bin/env bash
+#!/usr/bin/env bash -x
#
# Licensed to the Apache Software Foundation (ASF) under one or more
@@ -30,14 +30,14 @@ set -o pipefail
function help {
echo " "
echo "usage: ${0}"
- echo " --container-name [OPTIONAL] The Docker container
name. Default: bro"
+ echo " --container-name [OPTIONAL] The Docker container
name. Default: metron-bro-plugin-kafka_bro_1"
echo " --plugin-version [REQUIRED] The plugin version."
echo " -h/--help Usage information."
echo " "
echo " "
}
-CONTAINER_NAME="bro"
+CONTAINER_NAME="metron-bro-plugin-kafka_bro_1"
PLUGIN_VERSION=
# handle command line options
diff --git a/docker/scripts/docker_execute_configure_bro_plugin.sh
b/docker/scripts/docker_execute_configure_bro_plugin.sh
index c4011c4..69162c3 100755
--- a/docker/scripts/docker_execute_configure_bro_plugin.sh
+++ b/docker/scripts/docker_execute_configure_bro_plugin.sh
@@ -30,13 +30,13 @@ set -o pipefail
function help {
echo " "
echo "usage: ${0}"
- echo " --container-name [OPTIONAL] The Docker container
name. Default: bro"
+ echo " --container-name [OPTIONAL] The Docker container
name. Default: metron-bro-plugin-kafka_bro_1"
echo " -h/--help Usage information."
echo " "
echo " "
}
-CONTAINER_NAME=bro
+CONTAINER_NAME=metron-bro-plugin-kafka_bro_1
# Handle command line options
for i in "$@"; do
diff --git a/docker/scripts/docker_run_create_topic_in_kafka.sh
b/docker/scripts/docker_execute_create_topic_in_kafka.sh
similarity index 74%
rename from docker/scripts/docker_run_create_topic_in_kafka.sh
rename to docker/scripts/docker_execute_create_topic_in_kafka.sh
index f140469..46435ef 100755
--- a/docker/scripts/docker_run_create_topic_in_kafka.sh
+++ b/docker/scripts/docker_execute_create_topic_in_kafka.sh
@@ -26,25 +26,25 @@ set -o pipefail
function help {
echo " "
echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
+ echo " --container-name [OPTIONAL] The Docker container
name. Default: metron-bro-plugin-kafka_kafka_1"
echo " --kafka-topic [OPTIONAL] The kafka topic to
create. Default: bro"
echo " -h/--help Usage information."
echo " "
}
-NETWORK_NAME=bro-network
+CONTAINER_NAME="metron-bro-plugin-kafka_kafka_1"
KAFKA_TOPIC=bro
# handle command line options
for i in "$@"; do
case $i in
#
- # NETWORK_NAME
+ # CONTAINER_NAME
#
- # --network-name
+ # --container-name
#
- --network-name=*)
- NETWORK_NAME="${i#*=}"
+ --container-name=*)
+ CONTAINER_NAME="${i#*=}"
shift # past argument=value
;;
#
@@ -76,13 +76,13 @@ for i in "$@"; do
esac
done
-echo "Running docker_run_create_topic_in_kafka with "
-echo "NETWORK_NAME = $NETWORK_NAME"
+echo "Running docker_execute_create_topic_in_kafka.sh with "
+echo "CONTAINER_NAME = ${CONTAINER_NAME}"
+echo "KAFKA_TOPIC = ${KAFKA_TOPIC}"
echo "==================================================="
-docker run --rm --network "${NETWORK_NAME}" ches/kafka \
- kafka-topics.sh --create --topic "${KAFKA_TOPIC}" --replication-factor 1
--partitions 1 --zookeeper zookeeper:2181
+docker exec -w /kafka/bin/ "${CONTAINER_NAME}" \
+ bash -c "JMX_PORT= ./kafka-topics.sh --create --topic ${KAFKA_TOPIC}
--replication-factor 1 --partitions 1 --zookeeper zookeeper:2181"
rc=$?; if [[ ${rc} != 0 ]]; then
exit ${rc}
fi
-
diff --git a/docker/scripts/docker_execute_process_data_file.sh
b/docker/scripts/docker_execute_process_data_file.sh
index a944fb2..b227bd2 100755
--- a/docker/scripts/docker_execute_process_data_file.sh
+++ b/docker/scripts/docker_execute_process_data_file.sh
@@ -30,7 +30,7 @@ set -o pipefail
function help {
echo " "
echo "usage: ${0}"
- echo " --container-name [OPTIONAL] The Docker container
name. Default: bro"
+ echo " --container-name [OPTIONAL] The Docker container
name. Default: metron-bro-plugin-kafka_bro_1"
echo " --pcap-file-name [REQUIRED] The name of the pcap
file"
echo " --output-directory-name [REQUIRED] The name of the output
directory"
echo " -h/--help Usage information."
@@ -38,7 +38,7 @@ function help {
echo " "
}
-CONTAINER_NAME=bro
+CONTAINER_NAME=metron-bro-plugin-kafka_bro_1
PCAP_FILE_NAME=
OUTPUT_DIRECTORY_NAME=
@@ -110,4 +110,4 @@ rc=$?; if [[ ${rc} != 0 ]]; then
exit ${rc};
fi
-echo "done processing ${PCAP_FILE_NAME}"
\ No newline at end of file
+echo "done processing ${PCAP_FILE_NAME}"
diff --git a/docker/scripts/docker_execute_shell.sh
b/docker/scripts/docker_execute_shell.sh
index 1c7ff9f..c280e8c 100755
--- a/docker/scripts/docker_execute_shell.sh
+++ b/docker/scripts/docker_execute_shell.sh
@@ -30,13 +30,13 @@ set -o pipefail
function help {
echo " "
echo "usage: ${0}"
- echo " --container-name [OPTIONAL] The Docker container
name. Default: bro"
+ echo " --container-name [OPTIONAL] The Docker container
name. Default: metron-bro-plugin-kafka_bro_1"
echo " -h/--help Usage information."
echo " "
echo " "
}
-CONTAINER_NAME=bro
+CONTAINER_NAME=metron-bro-plugin-kafka_bro_1
# handle command line options
for i in "$@"; do
diff --git a/docker/scripts/docker_run_bro_container.sh
b/docker/scripts/docker_run_bro_container.sh
deleted file mode 100755
index aba5d5f..0000000
--- a/docker/scripts/docker_run_bro_container.sh
+++ /dev/null
@@ -1,168 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-#
-# Runs the bro container
-#
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --container-name [OPTIONAL] The Docker container
name. Default: bro"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " --scripts-path [OPTIONAL] The path with the
scripts you may run in the container. These are your scripts, not the built in
scripts"
- echo " --data-path [OPTIONAL] The name of the
directory to map to /root/data in the container"
- echo " --test-output-path [REQUIRED] The path to log test
data to"
- echo " --docker-parameter [OPTIONAL, MULTIPLE] Each
parameter with this name will be passed to docker run"
- echo " -h/--help Usage information."
- echo " "
-}
-
-BRO_PLUGIN_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && cd ../..
&& pwd)"
-CONTAINER_NAME=bro
-NETWORK_NAME=bro-network
-OUR_SCRIPTS_PATH="${BRO_PLUGIN_PATH}/docker/in_docker_scripts"
-SCRIPTS_PATH=
-DATA_PATH=
-TEST_OUTPUT_PATH=
-
-declare -a DOCKER_PARAMETERS
-
-# Handle command line options
-for i in "$@"; do
- case $i in
- #
- # CONTAINER_NAME
- #
- # --container-name
- #
- --container-name=*)
- CONTAINER_NAME="${i#*=}"
- shift # past argument=value
- ;;
-
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument=value
- ;;
-
- #
- # DATA_PATH
- #
- # --data-path
- #
- --data-path=*)
- DATA_PATH="${i#*=}"
- shift # past argument=value
- ;;
-
- #
- # SCRIPTS_PATH
- #
- # --scripts-path
- #
- --scripts-path=*)
- SCRIPTS_PATH="${i#*=}"
- shift # past argument=value
- ;;
-
- #
- # TEST_OUTPUT_PATH
- #
- # --test-output-path
- #
- --test-output-path=*)
- TEST_OUTPUT_PATH="${i#*=}"
- shift # past argument=value
- ;;
-
- #
- # DOCKER_PARAMETERS
- #
- # --docker-parameter
- #
- --docker-parameter=*)
- DOCKER_PARAMETERS=( "${DOCKER_PARAMETERS[@]}" "${i#*=}" )
- shift # past argument=value
- ;;
-
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
- esac
-done
-
-echo "Running docker_run_bro_container with "
-echo "CONTAINER_NAME = $CONTAINER_NAME"
-echo "NETWORK_NAME = ${NETWORK_NAME}"
-echo "SCRIPT_PATH = ${SCRIPTS_PATH}"
-echo "DATA_PATH = ${DATA_PATH}"
-echo "TEST_OUTPUT_PATH = ${TEST_OUTPUT_PATH}"
-echo "DOCKER_PARAMETERS = " "${DOCKER_PARAMETERS[@]}"
-echo "==================================================="
-
-
-# Build the docker command line
-declare -a DOCKER_CMD_BASE
-DOCKER_CMD="bash"
-DOCKER_CMD_BASE[0]="docker run -d -t --name ${CONTAINER_NAME} --network
${NETWORK_NAME} "
-DOCKER_CMD_BASE[1]="-v \"${OUR_SCRIPTS_PATH}:/root/built_in_scripts\" "
-DOCKER_CMD_BASE[2]="-v \"${BRO_PLUGIN_PATH}:/root/code\" "
-DOCKER_CMD_BASE[3]="-v \"${TEST_OUTPUT_PATH}:/root/test_output\" "
-OFFSET=4
-if [[ -n "$SCRIPTS_PATH" ]]; then
- DOCKER_CMD_BASE[$OFFSET]="-v \"${SCRIPTS_PATH}:/root/scripts\" "
- OFFSET=5
-fi
-
-if [[ -n "$DATA_PATH" ]]; then
- DOCKER_CMD_BASE[$OFFSET]="-v \"${DATA_PATH}:/root/data\" "
-fi
-
-echo "===============Running Docker==============="
-echo ""
-echo "eval command is: "
-echo "${DOCKER_CMD_BASE[@]}" "${DOCKER_PARAMETERS[@]}" "${CONTAINER_NAME}"
"${DOCKER_CMD}"
-echo ""
-echo "============================================"
-echo ""
-eval "${DOCKER_CMD_BASE[@]}" "${DOCKER_PARAMETERS[@]}"
metron-bro-docker-container:latest "${DOCKER_CMD}"
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-echo "Started bro container"
-echo " "
-echo " "
-
diff --git a/docker/scripts/docker_run_consume_kafka.sh
b/docker/scripts/docker_run_consume_kafka.sh
index 71e7cf9..a45b218 100755
--- a/docker/scripts/docker_run_consume_kafka.sh
+++ b/docker/scripts/docker_run_consume_kafka.sh
@@ -31,14 +31,14 @@ set -o pipefail
function help {
echo " "
echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
+ echo " --network-name [OPTIONAL] The Docker network
name. Default: metron-bro-plugin-kafka_default"
echo " --offset [OPTIONAL] The kafka offset to
read from. Default: -1"
echo " --kafka-topic [OPTIONAL] The kafka topic to
consume from. Default: bro"
echo " -h/--help Usage information."
echo " "
}
-NETWORK_NAME=bro-network
+NETWORK_NAME=metron-bro-plugin-kafka_default
OFFSET=-1
KAFKA_TOPIC=bro
@@ -92,7 +92,7 @@ for i in "$@"; do
esac
done
-docker run --rm --network "${NETWORK_NAME}" ches/kafka \
+docker run --rm --network "${NETWORK_NAME}" metron-bro-plugin-kafka_kafka \
kafka-console-consumer.sh --topic "${KAFKA_TOPIC}" --offset "${OFFSET}"
--partition 0 --bootstrap-server kafka:9092 --timeout-ms 1000
rc=$?; if [[ ${rc} != 0 ]]; then
exit ${rc}
diff --git a/docker/scripts/docker_run_get_offset_kafka.sh
b/docker/scripts/docker_run_get_offset_kafka.sh
index 7d658fc..5a2c2ba 100755
--- a/docker/scripts/docker_run_get_offset_kafka.sh
+++ b/docker/scripts/docker_run_get_offset_kafka.sh
@@ -31,13 +31,13 @@ set -o pipefail
function help {
echo " "
echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
+ echo " --network-name [OPTIONAL] The Docker network
name. Default: metron-bro-plugin-kafka_default"
echo " --kafka-topic [OPTIONAL] The kafka topic to pull
the offset from. Default: bro"
echo " -h/--help Usage information."
echo " "
}
-NETWORK_NAME=bro-network
+NETWORK_NAME=metron-bro-plugin-kafka_default
KAFKA_TOPIC=bro
# handle command line options
@@ -81,7 +81,7 @@ for i in "$@"; do
esac
done
-docker run --rm --network "${NETWORK_NAME}" ches/kafka \
+docker run --rm --network "${NETWORK_NAME}" metron-bro-plugin-kafka_kafka \
kafka-run-class.sh kafka.tools.GetOffsetShell --topic "${KAFKA_TOPIC}"
--broker-list kafka:9092
rc=$?; if [[ ${rc} != 0 ]]; then
exit ${rc}
diff --git a/docker/scripts/docker_run_kafka_container.sh
b/docker/scripts/docker_run_kafka_container.sh
deleted file mode 100755
index a7d6781..0000000
--- a/docker/scripts/docker_run_kafka_container.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-#
-# Runs the kafka container
-#
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " -h/--help Usage information."
- echo " "
-}
-
-NETWORK_NAME=bro-network
-
-# Handle command line options
-for i in "$@"; do
- case $i in
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument=value
- ;;
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-echo "Running docker_run_kafka_container with "
-echo "NETWORK_NAME = $NETWORK_NAME"
-echo "==================================================="
-
-docker run -d --name kafka --network "${NETWORK_NAME}" --env
ZOOKEEPER_IP=zookeeper ches/kafka
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-echo "Started the kafka container with network ${NETWORK_NAME}"
-
diff --git a/docker/scripts/docker_run_wait_for_kafka.sh
b/docker/scripts/docker_run_wait_for_kafka.sh
deleted file mode 100755
index 3d659c9..0000000
--- a/docker/scripts/docker_run_wait_for_kafka.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-#
-# Executes a wait script for kafka
-#
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " -h/--help Usage information."
- echo " "
-}
-
-DOCKER_SCRIPTS_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && cd
.. > /dev/null && cd in_docker_scripts && pwd)"
-
-NETWORK_NAME=bro-network
-
-# Handle command line options
-for i in "$@"; do
- case $i in
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument=value
- ;;
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-echo "Running docker_run_wait_for_kakfa with"
-echo "NETWORK_NAME = $NETWORK_NAME"
-echo "==================================================="
-
-docker run --rm -i -t -w /root --network "${NETWORK_NAME}" -v
"${DOCKER_SCRIPTS_PATH}":/root/scripts centos bash -c "bash
/root/scripts/wait_for_kafka.sh"
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
diff --git a/docker/scripts/docker_run_wait_for_zookeeper.sh
b/docker/scripts/docker_run_wait_for_zookeeper.sh
deleted file mode 100755
index 5ce60ae..0000000
--- a/docker/scripts/docker_run_wait_for_zookeeper.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-#
-# Executes a wait script for zookeeper
-#
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " -h/--help Usage information."
- echo " "
-}
-
-DOCKER_SCRIPTS_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" > /dev/null && cd
.. > /dev/null && cd in_docker_scripts && pwd)"
-
-NETWORK_NAME=bro-network
-
-# handle command line options
-for i in "$@"; do
- case $i in
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument=value
- ;;
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-echo "Running docker_run_wait_for_zookeeper with "
-echo "NETWORK_NAME = $NETWORK_NAME"
-echo "==================================================="
-
-docker run --rm -i -t -w /root --network "${NETWORK_NAME}" -v
"${DOCKER_SCRIPTS_PATH}":/root/scripts centos bash -c "bash
/root/scripts/wait_for_zk.sh"
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
diff --git a/docker/scripts/docker_run_zookeeper_container.sh
b/docker/scripts/docker_run_zookeeper_container.sh
deleted file mode 100755
index b35b813..0000000
--- a/docker/scripts/docker_run_zookeeper_container.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-#
-# Runs the zookeeper container
-#
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --network-name [OPTIONAL] The Docker network
name. Default: bro-network"
- echo " -h/--help Usage information."
- echo " "
-}
-
-NETWORK_NAME=bro-network
-
-# Handle command line options
-for i in "$@"; do
- case $i in
- #
- # NETWORK_NAME
- #
- # --network-name
- #
- --network-name=*)
- NETWORK_NAME="${i#*=}"
- shift # past argument=value
- ;;
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-echo "Running docker_run_zookeeper_container with "
-echo "NETWORK_NAME = $NETWORK_NAME"
-echo "==================================================="
-
-docker run -d --name zookeeper --network "${NETWORK_NAME}" zookeeper:3.4
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-echo "Started the zookeeper container with network ${NETWORK_NAME}"
-
diff --git a/docker/scripts/stop_container.sh b/docker/scripts/stop_container.sh
deleted file mode 100755
index a26e2c7..0000000
--- a/docker/scripts/stop_container.sh
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/usr/bin/env bash
-
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership.
-# The ASF licenses this file to You 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.
-#
-
-shopt -s nocasematch
-set -u # nounset
-set -e # errexit
-set -E # errtrap
-set -o pipefail
-
-# Stops the Docker container with a given name
-
-function help {
- echo " "
- echo "usage: ${0}"
- echo " --container-name [REQUIRED] The Docker container
name"
- echo " -h/--help Usage information."
- echo " "
-}
-
-CONTAINER_NAME=
-
-# Handle command line options
-for i in "$@"; do
- case $i in
- #
- # CONTAINER_NAME
- #
- # --container-name
- #
- --container-name=*)
- CONTAINER_NAME="${i#*=}"
- shift # past argument=value
- ;;
- #
- # -h/--help
- #
- -h | --help)
- help
- exit 0
- shift # past argument with no value
- ;;
-
- #
- # Unknown option
- #
- *)
- UNKNOWN_OPTION="${i#*=}"
- echo "Error: unknown option: $UNKNOWN_OPTION"
- help
- ;;
- esac
-done
-
-if [[ -z "$CONTAINER_NAME" ]]; then
- echo "CONTAINER_NAME must be passed"
- exit 1
-fi
-
-echo "Running stop_container with"
-echo "CONTAINER_NAME= $CONTAINER_NAME"
-echo "==================================================="
-
-docker stop "${CONTAINER_NAME}"
-rc=$?; if [[ ${rc} != 0 ]]; then
- exit ${rc}
-fi
-
-docker rm "${CONTAINER_NAME}"
-