forked from andrewpuch/consul_demo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·32 lines (27 loc) · 984 Bytes
/
setup.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
#!/bin/bash
usage() {
echo ""
echo "${0} <hostname> <encrypt> <private ip 1> <private ip 2>"
echo ""
echo "Arguments"
echo "Hostname - [REQUIRED] The hostname you want to provide for your consul agent."
echo "Encrypt - [REQUIRED] This is acquired by running consul keygen."
echo "Private IP 1 - [REQUIRED] The private IP address of the bootstrap server."
echo "Private IP 2 - [REQUIRED] The private IP address of the non bootstrap server."
echo ""
return
}
# Check to make sure the correct number of arguments is passed.
if [ "$#" -ne 4 ];
then
usage
exit
fi
HOSTNAME=$1
ENCRYPT=$2
PRIVATE_IP1=$3
PRIVATE_IP2=$4
sed -i -- "s/__NODE_NAME__/$HOSTNAME/g" /root/consul_demo/config.json
sed -i -- "s/__ENCRYPT__/$ENCRYPT/g" /root/consul_demo/config.json
sed -i -- "s/__BOOTSTRAP_PRIVATE_IP__/$PRIVATE_IP1/g" /root/consul_demo/config.json
sed -i -- "s/__NON_BOOTSTRAP_PRIVATE_IP__/$PRIVATE_IP2/g" /root/consul_demo/config.json