2 ################################################################################
4 # Copyright 2020 highstreet technologies GmbH and others
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 ################################################################################
18 if [ "$#" -ne 1 ]; then
19 echo "ID Parameter missing."
22 where id is the docker container id of the NTS Manager instance that we want to clean. "
26 echo "Cleaning up containers started by the NTS Manager $1..."
28 mapfile -t NTS_containers < <( docker ps -a --filter "label=NTS_Manager=$1" --format "{{.ID}}" )
32 if [ ${#NTS_containers[@]} -gt 0 ]
35 for container in "${NTS_containers[@]}"
37 CONTAINERS="$CONTAINERS $container"
39 echo "Cleaning up containers: $CONTAINERS"
40 docker kill $CONTAINERS > /dev/null 2>&1
41 docker rm $CONTAINERS > /dev/null 2>&1
44 echo "Cleaning NTS Manager $1..."
45 docker kill $1 > /dev/null 2>&1
46 docker rm $1 > /dev/null 2>&1
48 echo "All cleaned up!"