go.etcd.io/etcd@v3.3.27+incompatible/contrib/systemd/etcd2-backup-coreos/etcd2-join (about)

     1  #!/bin/bash -e
     2  
     3  # Copyright 2015 CoreOS, Inc.
     4  #
     5  # Licensed under the Apache License, Version 2.0 (the "License");
     6  # you may not use this file except in compliance with the License.
     7  # You may obtain a copy of the License at
     8  #
     9  #     http:#www.apache.org/licenses/LICENSE-2.0
    10  #
    11  # Unless required by applicable law or agreed to in writing, software
    12  # distributed under the License is distributed on an "AS IS" BASIS,
    13  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    14  # See the License for the specific language governing permissions and
    15  # limitations under the License.
    16  
    17  if [ $# -lt 3 ];then
    18      echo "USAGE: $0  <master_advertise_peer_urls> <target_name> <target_peer_url>"
    19      exit 1
    20  fi
    21  
    22  function convertDropin {
    23      sed -e 's/^Added.*$/[Service]/g' -e 's/="/=/g' -e 's/^ETCD_/Environment="ETCD_/g'
    24  }
    25  masterAdvUrl=$1
    26  targetName=$2
    27  targetUrl=$3
    28  
    29  cmd="etcdctl --peers ${masterAdvUrl} member add ${targetName} ${targetUrl}"
    30  
    31  ENV_VARS=`$cmd`
    32  echo "${ENV_VARS}" | convertDropin  > 40-boostrap-cluster.conf
    33  
    34  sudo mv 40-boostrap-cluster.conf /var/run/systemd/system/etcd2.service.d/
    35  sudo systemctl daemon-reload
    36  sudo systemctl cat etcd2.service
    37  echo "You can now start etcd2"
    38  
    39