You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
#!/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 agent $consulopts
|