-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathget_bot_db.sh
executable file
·59 lines (49 loc) · 995 Bytes
/
get_bot_db.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-"
help()
{
echo """
Usage: ./get_bot_db.sh [ -n | --id ]
[ -o | --outdir ]
[ -h | --help ]
"""
exit 2
}
SHORT=n:,o:,h
LONG=id:,output:,help
OPTS=$(getopt -a -n get_bot_db.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
-n | --id )
HBOT_ID="$2"
shift 2
;;
-o | --outdir )
OUTDIR="$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
if [ -z $OUTDIR ]; then
OUTDIR=./hbot-${HBOT_ID}-data
fi
CONTAINER_ID=$(docker run -d -v hbot-${HBOT_ID}-data:/hbot-data busybox true)
docker cp ${CONTAINER_ID}:/hbot-data ${OUTDIR}