Allow multiple NTS Manager instances to run on the same machine.
[sim/o1-interface.git] / ntsimulator / scripts / clean.sh
index cc4daf7..2d9bd56 100755 (executable)
@@ -1,8 +1,31 @@
-#/bin/bash
+#!/bin/bash
+################################################################################
+#
+# Copyright 2020 highstreet technologies GmbH and others
+#
+# 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.
+################################################################################
+if [ "$#" -ne 1 ]; then
+    echo "ID Parameter missing."
+       echo "Usage: $0 id
+       
+where id is the docker container id of the NTS Manager instance that we want to clean. "
+       exit 1
+fi
 
-echo "Cleaning up..."
+echo "Cleaning up containers started by the NTS Manager $1..."
 
-mapfile -t NTS_containers < <( docker ps -a --filter "label=NTS" --format "{{.ID}}" )
+mapfile -t NTS_containers < <( docker ps -a --filter "label=NTS_Manager=$1" --format "{{.ID}}" )
 
 CONTAINERS=""
 
@@ -13,13 +36,13 @@ then
        do
                CONTAINERS="$CONTAINERS $container"
        done
-       echo "Cleaning up ontainers: $CONTAINERS"
+       echo "Cleaning up containers: $CONTAINERS"
        docker kill $CONTAINERS > /dev/null 2>&1
        docker rm $CONTAINERS > /dev/null 2>&1
 fi
 
-echo "Cleaning NTS Manager container"
-docker kill NTS_Manager > /dev/null 2>&1
-docker rm NTS_Manager > /dev/null 2>&1
+echo "Cleaning NTS Manager $1..."
+docker kill $1 > /dev/null 2>&1
+docker rm $1 > /dev/null 2>&1
 
 echo "All cleaned up!"