#!/bin/bash -ex

#####################################################################
# Change the following lines to match your IP addresses

PRIMARY_NODE="10.161.0.40"
NODE1="10.161.27.159"
NODE2="10.161.27.159"

#####################################################################
# Data Information:
#####################################################################
# Primary Node: ${PRIMARY_NODE}
# Other Nodes:  ${NODE1},${NODE2}
# Ports:
# - {"port": 19901, "start-hslot": 0,     "end-hslot": 1365}
# - {"port": 19902, "start-hslot": 1366,  "end-hslot": 2730}
# - {"port": 19903, "start-hslot": 2731,  "end-hslot": 4096}
# - {"port": 19904, "start-hslot": 4097,  "end-hslot": 5460}
# - {"port": 19905, "start-hslot": 5461,  "end-hslot": 6826}
# - {"port": 19906, "start-hslot": 6827,  "end-hslot": 8191}
# - {"port": 19907, "start-hslot": 8192,  "end-hslot": 9557}
# - {"port": 19908, "start-hslot": 9558,  "end-hslot": 10921}
# - {"port": 19909, "start-hslot": 10922, "end-hslot": 12287}
# - {"port": 19910, "start-hslot": 12288, "end-hslot": 13651}
# - {"port": 19911, "start-hslot": 13652, "end-hslot": 15017}
# - {"port": 19912, "start-hslot": 15018, "end-hslot": 16383}


#####################################################################
# Raft Group Setups!!


echo "Setting up Raft Groups - port 19901"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19901 raft.cluster join ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${NODE2} -p 19901 raft.cluster join ${PRIMARY_NODE}:19901


echo "Setting up Raft Groups - port 19902"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19902 raft.cluster join ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${NODE2} -p 19902 raft.cluster join ${PRIMARY_NODE}:19902


echo "Setting up Raft Groups - port 19903"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19903 raft.cluster join ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${NODE2} -p 19903 raft.cluster join ${PRIMARY_NODE}:19903


echo "Setting up Raft Groups - port 19904"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19904 raft.cluster join ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${NODE2} -p 19904 raft.cluster join ${PRIMARY_NODE}:19904


echo "Setting up Raft Groups - port 19905"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19905 raft.cluster join ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${NODE2} -p 19905 raft.cluster join ${PRIMARY_NODE}:19905


echo "Setting up Raft Groups - port 19906"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19906 raft.cluster join ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${NODE2} -p 19906 raft.cluster join ${PRIMARY_NODE}:19906


echo "Setting up Raft Groups - port 19907"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19907 raft.cluster join ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${NODE2} -p 19907 raft.cluster join ${PRIMARY_NODE}:19907


echo "Setting up Raft Groups - port 19908"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19908 raft.cluster join ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${NODE2} -p 19908 raft.cluster join ${PRIMARY_NODE}:19908


echo "Setting up Raft Groups - port 19909"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19909 raft.cluster join ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${NODE2} -p 19909 raft.cluster join ${PRIMARY_NODE}:19909


echo "Setting up Raft Groups - port 19910"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19910 raft.cluster join ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${NODE2} -p 19910 raft.cluster join ${PRIMARY_NODE}:19910


echo "Setting up Raft Groups - port 19911"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19911 raft.cluster join ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${NODE2} -p 19911 raft.cluster join ${PRIMARY_NODE}:19911


echo "Setting up Raft Groups - port 19912"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 raft.cluster init
/usr/local/bin/redis-cli -h ${NODE1} -p 19912 raft.cluster join ${PRIMARY_NODE}:19912
/usr/local/bin/redis-cli -h ${NODE2} -p 19912 raft.cluster join ${PRIMARY_NODE}:19912


#####################################################################
# Sleep until raft cluster is created

echo "Waiting for Raft to stabilize"
sleep 10

#####################################################################
# Set up Shard Clusters


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19901 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19902 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19903 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19904 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19905 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19906 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19907 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19908 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19909 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19910 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19911 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19912


echo "Setting up Shard Clusters"

/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19901
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19902
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19903
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19904
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19905
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19906
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19907
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19908
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19909
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19910
/usr/local/bin/redis-cli -h ${PRIMARY_NODE} -p 19912 RAFT.SHARDGROUP LINK ${PRIMARY_NODE}:19911

