-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdocker-entry.sh
executable file
·94 lines (71 loc) · 1.71 KB
/
docker-entry.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
IMAGE_REPO="vyahello/badoo-liker"
IMAGE_VERSION="2.2.3"
CONFIG="template-setup.yaml"
COMPOSE="docker-compose.yaml"
DELAY_BETWEEN_RUN=1800
function helper {
cat <<HELP
This script provides badoo liker executor via docker.
Please use next commands:
- 'get-setup' to get latest config .yaml setup file
docker run ${IMAGE_REPO}:${IMAGE_VERSION} get-setup > config.yaml
- 'get-compose' to get latest docker-compose file
docker run ${IMAGE_REPO}:${IMAGE_VERSION} get-compose > docker-compose.yaml
- 'run-liker' to run badoo-liker script
docker run ${IMAGE_REPO}:${IMAGE_VERSION} run-liker -h
HELP
}
function get-setup {
cat ${CONFIG}
}
function get-compose {
cat ${COMPOSE}
}
function run-single-liker {
python liker.py $@
}
function run-infinite-liker {
iteration=0
while true; do
echo "Running #$iteration badoo iteration ..."
run-single-liker $@
echo "Waiting ${DELAY_BETWEEN_RUN} second(s) for next iteration ..."
sleep ${DELAY_BETWEEN_RUN}
let iteration+=1
done
}
function check-grid-is-ready {
while ! curl -sSL "http://localhost:4444/wd/hub/status" 2>&1 \
| jq -r '.value.ready' 2>&1 | grep "true" >/dev/null; do
echo 'Still waiting for the Grid ...'
sleep 1
done
}
function run-liker {
if [[ -z "$@" ]];
then python liker.py --help
else
check-grid-is-ready
if [[ "$1" == "--infinite" ]] || [[ "$1" == "-i" ]]; then
shift
run-infinite-liker $@
else
run-single-liker $@
fi
fi
}
function main {
if (
[[ "$1" == "-h" ]] ||
[[ "$1" == "--help" ]] ||
[[ "$1" == "help" ]] ||
[[ $# -eq 0 ]]
); then
helper
exit 0
fi
local cmd=$1; shift
eval "${cmd} $@"
}
main $@