-
Notifications
You must be signed in to change notification settings - Fork 17
/
redis
executable file
·54 lines (47 loc) · 1.37 KB
/
redis
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
#!/bin/bash
if [ -z "$COOG_CODE_DIR" ] || [ ! -d "$COOG_CODE_DIR" ] || [ -z "$COOG_DATA_DIR" ]
then
{
echo "Please make sure that these two env vars are set:"
echo " COOG_CODE_DIR: your coog-admin install folder"
echo " COOG_DATA_DIR: the folder where to keep your custom config"
} >&2 && exit 1
fi
server() {
docker run \
$DOCKER_DAEMON_OPTS \
--network "$NETWORK_NAME" \
--name "$NETWORK_NAME-redis" \
-v /usr/share/zoneinfo:/usr/share/zoneinfo:ro \
-v /etc/timezone:/etc/timezone:ro \
-v "$REDIS_VOLUME:/data" \
"$REDIS_IMAGE" $REDIS_EXTRA_ARGS "$@"
}
client() {
docker run \
$DOCKER_INTERACTIVE_OPTS \
--network "$NETWORK_NAME" \
"$REDIS_IMAGE" \
redis-cli -h "$NETWORK_NAME-redis" "$@"
}
action() {
docker "$@" "$NETWORK_NAME-redis"
}
usage() {
echo
echo Available commands
echo
echo " server -> runs a redis docker image as a server"
echo " client -> runs a redis docker image as a client"
echo " <action> -> calls docker action on server container"
echo
}
main() {
source "$COOG_CODE_DIR/config"
[ -z "$1" ] && usage && return 0
local cmd; cmd=$1; shift
[ "$cmd" = "server" ] && { server "$@"; return $?; }
[ "$cmd" = "client" ] && { client "$@"; return $?; }
action "$cmd" "$@"
}
main "$@"