File size: 844 Bytes
b8bb38f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env bash
set -euo pipefail
DBOPS=${DBOPS_ROOT:-/data/adaptai/platform/dbops}
BIN_DIR=$DBOPS/binaries/etcd
BIN=$BIN_DIR/etcd
DATA=$DBOPS/data/etcd
LOG=$DBOPS/logs/etcd
PORT=${ETCD_CLIENT_PORT:-18150}
mkdir -p "$BIN_DIR" "$DATA" "$LOG"
if [ ! -x "$BIN" ]; then
  echo "[etcd] fetching binary"
  ver=v3.5.14
  url="https://github.com/etcd-io/etcd/releases/download/$ver/etcd-$ver-linux-amd64.tar.gz"
  tmp=$(mktemp -d)
  curl -fsSL "$url" -o "$tmp/etcd.tgz"
  tar -xzf "$tmp/etcd.tgz" -C "$tmp"
  src=$(find "$tmp" -maxdepth 1 -type d -name "etcd-*" | head -n1)
  cp "$src/etcd" "$BIN_DIR/etcd"
  cp "$src/etcdctl" "$BIN_DIR/etcdctl"
  chmod +x "$BIN_DIR/etcd" "$BIN_DIR/etcdctl"
  rm -rf "$tmp"
fi
exec "$BIN" \
  --data-dir "$DATA" \
  --listen-client-urls "http://0.0.0.0:$PORT" \
  --advertise-client-urls "http://127.0.0.1:$PORT"