-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_cluster.sh
executable file
·62 lines (49 loc) · 1.14 KB
/
start_cluster.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
#!/bin/bash
TESTDIR=tests
CONF_DIR=${CONF_DIR:-./configs}
TEMPL_DIR=${CONF_DIR}/templates
TAIL=true
MAKECONFIGS=false
while (( "$#" )); do
case "$1" in
"notail")
TAIL=false
shift
;;
"makeconfigs")
MAKECONFIGS=true
shift
;;
*) # preserve positional arguments
PARAMS="$PARAMS $1"
shift
;;
esac
done
eval set -- "$PARAMS"
export PREFIX=$1
trap ctrl_c INT
( ! [ $EUID = 0 ] ) && SUDO="sudo -E" || SUDO=
function ctrl_c() {
echo down AND exit
sudo docker-compose down && exit 0
rm ./configs/*conf 2>/dev/null
}
function prepare_configs() {
rm ./configs/*.conf 2>/dev/null
for i in $(seq 1 5);do
cp $CONF_DIR/templates/sentinel.tmpl $CONF_DIR/sent_$i.conf
cp $CONF_DIR/templates/redis.tmpl $CONF_DIR/red_$i.conf
if [[ $i -gt 1 ]];then
echo slaveof redis1 6379 >> $CONF_DIR/red_$i.conf
fi
done
$SUDO chmod 777 $CONF_DIR/*.conf
}
cd $TESTDIR
prepare_configs
if $MAKECONFIGS;then echo "only configs";exit 0;fi
$SUDO docker-compose up -d --build
if $TAIL ;then
$SUDO docker-compose logs -f redis-sentinel-proxy client
fi