forked from efabless/foss-asic-tools
-
Notifications
You must be signed in to change notification settings - Fork 65
/
eda_server_stop.sh
executable file
·72 lines (67 loc) · 2.23 KB
/
eda_server_stop.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# ========================================================================
# Stops and removes multiple IIC-OSIC-TOOLS containers for many EDA users
#
# SPDX-FileCopyrightText: 2023 Harald Pretl
# Johannes Kepler University, Institute for Integrated Circuits
#
# 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.
# SPDX-License-Identifier: Apache-2.0
# ========================================================================
# get configuration variables
# shellcheck source=/dev/null
source eda_server_conf.sh
# variables for script control
DEBUG=0
# process input parameters
while getopts "hdm:" flag; do
case $flag in
d)
echo "[INFO] DEBUG is enabled"
DEBUG=1
;;
m)
[ $DEBUG = 1 ] && echo "[INFO] Flag -m is set to $OPTARG."
EDA_CONTAINER_PREFIX=${OPTARG}
;;
h)
echo
echo "Stopping Docker instances for EDA users (IIC@JKU)"
echo
echo "Usage: $0 [-h] [-d] [-m cont_prefix]"
echo
echo " -h shows a help screen"
echo " -d enables the debug mode"
echo " -m sets the name prefix of the container (default $EDA_CONTAINER_PREFIX)"
echo
exit
;;
*)
;;
esac
done
shift $((OPTIND-1))
# now search the containers and remove them
echo "[INFO] Stopping and removing EDA containers."
NO_INSTANCES=0
while [ "$(docker ps -q -f name="$EDA_CONTAINER_PREFIX")" ];
do
CONTAINER_ID=$(docker ps -q -f name="$EDA_CONTAINER_PREFIX" | head -n1)
[ $DEBUG = 1 ] && echo "[INFO] Container ID $CONTAINER_ID found, now stopping and removing!"
docker stop "$CONTAINER_ID" > /dev/null
docker rm "$CONTAINER_ID" > /dev/null
NO_INSTANCES=$((NO_INSTANCES + 1))
echo "[INFO] Container nr. $NO_INSTANCES stopped and removed."
done
echo "[INFO] All EDA containers have been stopped and removed!"
echo "[DONE] Bye!"