github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/deploy/apecloud-mysql/scripts/etcd-post-start.sh (about)

     1  #!/bin/bash
     2  etcd_port=${ETCD_PORT:-'2379'}
     3  etcd_server=${ETCD_SERVER:-'127.0.0.1'}
     4  
     5  cell=${CELL:-'zone1'}
     6  export ETCDCTL_API=2
     7  
     8  etcdctl --endpoints "http://127.0.0.1:${etcd_port}" get "/vitess/global" >/dev/null 2>&1
     9  if [[ $? -eq 1 ]]; then
    10    exit 0
    11  fi
    12  
    13  echo "add /vitess/global"
    14  etcdctl --endpoints "http://127.0.0.1:${etcd_port}" mkdir /vitess/global
    15  
    16  echo "add /vitess/$cell"
    17  etcdctl --endpoints "http://127.0.0.1:${etcd_port}" mkdir /vitess/$cell
    18  
    19  # And also add the CellInfo description for the cell.
    20  # If the node already exists, it's fine, means we used existing data.
    21  echo "add $cell CellInfo"
    22  set +e
    23  vtctl --topo_implementation etcd2 \
    24    --topo_global_server_address "127.0.0.1:${etcd_port}" \
    25    --topo_global_root /vitess/global VtctldCommand AddCellInfo \
    26    --root /vitess/$cell \
    27    --server-address "${etcd_server}:${etcd_port}" \
    28    $cell