-
Notifications
You must be signed in to change notification settings - Fork 1
/
ls_bots.sh
executable file
·45 lines (37 loc) · 911 Bytes
/
ls_bots.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
#!/usr/bin/env bash
CONTAINER_PREFIX="hbot-"
help()
{
echo "Usage: ./ls_bots.sh [ -h | --help ]"
exit 2
}
SHORT=h
LONG=help
OPTS=$(getopt -a -n ls_bots.sh --options $SHORT --longoptions $LONG -- "$@")
VALID_ARGUMENTS=$# # Returns the count of arguments that are in short or long options
eval set -- "$OPTS"
while :
do
case "$1" in
-h | --help)
help
;;
--)
shift;
break
;;
*)
echo "Unexpected option: $1"
help
;;
esac
done
echo 'Bots at [Exited] state'
echo '----------------------'
docker container ls -a --format 'table {{.Names}}\t{{.Status}}' -f 'status=exited' | grep ${CONTAINER_PREFIX}
echo '----------------------'
echo
echo 'Bots at [Running] state'
echo '-----------------------'
docker container ls -a --format 'table {{.Names}}\t{{.Status}}' -f 'status=running' | grep ${CONTAINER_PREFIX}
echo '-----------------------'