-
Notifications
You must be signed in to change notification settings - Fork 1
/
stop_bot.sh
executable file
·59 lines (48 loc) · 924 Bytes
/
stop_bot.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
#!/usr/bin/env bash
CONTAINER_PREFIX="hbot-"
COMPOSE_FILE_NAME="hbot.compose.yml"
ENV_FILE=".env"
help()
{
echo "
Usage: ./stop_bot.sh [ -n | --id ]
[ -h | --help ]"
exit 2
}
SHORT=n:,h
LONG=id:,help
OPTS=$(getopt -a -n rm_bot.sh --options $SHORT --longoptions $LONG -- "$@")
VALID_ARGUMENTS=$# # Returns the count of arguments that are in short or long options
if [ "$VALID_ARGUMENTS" -eq 0 ]; then
help
fi
eval set -- "$OPTS"
while :
do
case "$1" in
-n | --id )
HBOT_ID="$2"
shift 2
;;
-h | --help)
help
;;
--)
shift;
break
;;
*)
echo "Unexpected option: $1"
help
;;
esac
done
if [ -z $HBOT_ID ]; then
echo "[X] Error: HBOT_ID not set!"
exit 1
fi
CONTAINER_NAME="${CONTAINER_PREFIX}${HBOT_ID}"
set -o allexport
source $ENV_FILE
set +o allexport
docker container stop ${CONTAINER_NAME}