| 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 | |