File size: 894 Bytes
30b9f3f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
29
30
31
32
33
#!/usr/bin/env bash
set -euo pipefail
DBOPS=${DBOPS_ROOT:-/data/adaptai/platform/dbops}
BIN_DIR=$DBOPS/binaries/ipfs
BIN=$BIN_DIR/ipfs
IPFS_PATH=$DBOPS/data/ipfs
API_PORT=${IPFS_API_PORT:-17501}
GW_PORT=${IPFS_GATEWAY_PORT:-18080}
mkdir -p "$BIN_DIR" "$IPFS_PATH"

if [ ! -x "$BIN" ]; then
  echo "[ipfs] fetching Kubo (ipfs)"
  ver=v0.28.0
  url="https://dist.ipfs.tech/kubo/$ver/kubo_${ver}_linux-amd64.tar.gz"
  tmp=$(mktemp -d)
  curl -fsSL "$url" -o "$tmp/kubo.tgz"
  tar -xzf "$tmp/kubo.tgz" -C "$tmp"
  src=$(find "$tmp" -maxdepth 1 -type d -name "kubo_*" | head -n1)
  cp "$src/ipfs" "$BIN"
  chmod +x "$BIN"
  rm -rf "$tmp"
fi

export IPFS_PATH
if [ ! -f "$IPFS_PATH/config" ]; then
  "$BIN" init --profile server >/dev/null
  "$BIN" config Addresses.API "/ip4/0.0.0.0/tcp/$API_PORT"
  "$BIN" config Addresses.Gateway "/ip4/0.0.0.0/tcp/$GW_PORT"
fi

exec "$BIN" daemon --migrate=true