add consul bootstrap script
commit
66010a52ba
@ -0,0 +1,36 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Hashicorp Consul bootstrap script
|
||||||
|
# Params:
|
||||||
|
# server : if present, bootstraps a server
|
||||||
|
# bind : bind interface address
|
||||||
|
# server-ip : server ip address
|
||||||
|
|
||||||
|
# create directory if doesn't exist and set permissions
|
||||||
|
mkdir -p /opt/consul/{config, data} && chmod 700 /opt/consul
|
||||||
|
|
||||||
|
# parameter setup
|
||||||
|
consulopts="-config-dir=/opt/consul/config -data-dir=/opt/consul/data"
|
||||||
|
consultype="client"
|
||||||
|
|
||||||
|
# read parameters
|
||||||
|
while [[ "$#" -gt 0 ]]
|
||||||
|
do
|
||||||
|
case $1 in
|
||||||
|
-server)
|
||||||
|
consulopts+="-server "
|
||||||
|
consultype="server"
|
||||||
|
;;
|
||||||
|
-bind)
|
||||||
|
consulopts+="-bind=$2 "
|
||||||
|
;;
|
||||||
|
-server-ip)
|
||||||
|
consulopts+="-retry-join=$2 "
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
printf "initializing consul $consultype with following options: \n%s\n" "$consulopts"
|
||||||
|
|
||||||
|
consul=$(which consul)
|
||||||
|
$consul $consulopts
|
Loading…
Reference in New Issue