igneum/infra/seed-nodes/provision-seed.sh
2026-10-05 15:58:18 +00:00

52 lines
4.4 KiB
Bash
Executable file

#!/usr/bin/env bash
# Install igneumd on a seed and start it.
# ./provision-seed.sh <seed-name> build on the seed VM from the source tarball (BUILD_WHERE=seed, default)
# BUILD_WHERE=bin ./provision-seed.sh <name> use ../cloud-devnet/build/bin/igneumd (built by the 20-node route)
# Same binary route as the 20-node network: ../cloud-devnet/make-source.sh exports vendor/igneum-node (HEAD plus
# uncommitted work) and igneum-pow; builder/build-on-builder.sh compiles `-p kaspad -p igneum-miner --features
# igneum-pow`. On a 4 GB seed the build gets a 6 GB swap file and 2 jobs; expect about an hour (approximate).
# Other seeds already in seeds.txt become --addpeer entries, so the seeds form a full mesh among themselves.
. "$(dirname "$0")/lib.sh"
name="${1:-$SEED_NAME}"; ip=$(seed_ip "$name"); [ -n "$ip" ] || die "$name not in seeds.tsv"
mkdir -p "$BUILD_DIR"
CD="$HERE/../cloud-devnet"
for try in $(seq 1 20); do sssh "$ip" true >/dev/null 2>&1 && break; log "waiting for ssh ($try)"; sleep 10; done
sssh "$ip" true || die "ssh to $ip failed"
if [ "$BUILD_WHERE" = bin ] || [ "$BUILD_WHERE" = cross ]; then
# bin: ../cloud-devnet/build/bin; cross: infra/cross/out, where infra/cross/build-linux.sh and the PC build job
# (tools/build-job.mjs, Linux target) leave igneumd and igneum-miner; BIN_DIR overrides either
bindir="$CD/build/bin"; [ "$BUILD_WHERE" = cross ] && bindir="$REPO/infra/cross/out"; bindir="${BIN_DIR:-$bindir}"
[ -x "$bindir/igneumd" ] || die "no $bindir/igneumd (run ../cloud-devnet/provision.sh build, infra/cross/build-linux.sh or a Linux build job)"
file "$bindir/igneumd" | grep -q "x86-64" || die "$bindir/igneumd is not an x86-64 binary"
# the glibc the binary wants against the one the seed has (the class of the 5 October 2026 failure: a PC-built binary
# on debian-12); both printed, the upload refused when the binary asks for more than the seed can give
want=$(strings -a "$bindir/igneumd" 2>/dev/null | grep -o 'GLIBC_2\.[0-9]*' | sort -t. -k2 -n | tail -1 | cut -d_ -f2)
have=$(sssh "$ip" 'ldd --version 2>/dev/null | head -1 | grep -o "[0-9]*\.[0-9]*$"' || echo 0)
log "glibc: binary wants ${want:-?}, $name has ${have:-?}"
if [ -n "$want" ] && [ -n "$have" ] && [ "$(printf '%s\n%s\n' "$want" "$have" | sort -t. -k2 -n | tail -1)" != "$have" ]; then
die "$bindir/igneumd needs glibc $want, $name has $have (rebuild the seed on debian-13, or cross-build with infra/cross/build-linux.sh)"
fi
log "uploading prebuilt binaries from $bindir ($(sha256sum "$bindir/igneumd" 2>/dev/null || shasum -a 256 "$bindir/igneumd" | cut -c1-16))"
sssh "$ip" 'mkdir -p /opt/igneum/bin'
sscp "$bindir/igneumd" "$bindir/igneum-miner" "$SSH_USER@$ip:/opt/igneum/bin/"
sssh "$ip" 'chmod +x /opt/igneum/bin/igneumd /opt/igneum/bin/igneum-miner; /opt/igneum/bin/igneumd --version | head -1' || die "the uploaded igneumd does not run on $name"
else
NODE_SRC="$NODE_SRC" POW_SRC="$POW_SRC" SRC_MODE="$SRC_MODE" "$CD/make-source.sh"
cp "$CD/build/src.stamp" "$BUILD_DIR/src.stamp"
log "uploading the source tarball ($(du -h "$CD/build/src.tar.gz" | cut -f1)) and the build script"
sscp "$CD/build/src.tar.gz" "$CD/builder/build-on-builder.sh" "$SSH_USER@$ip:/root/"
log "swap and build on the seed (log: $BUILD_DIR/build-$name.log)"
sssh "$ip" 'if [ ! -f /swapfile ]; then fallocate -l 6G /swapfile && chmod 600 /swapfile && mkswap /swapfile >/dev/null && swapon /swapfile && echo "/swapfile none swap sw 0 0" >> /etc/fstab; fi; free -m | head -3'
sssh "$ip" 'export CARGO_BUILD_JOBS=2; bash /root/build-on-builder.sh' 2>&1 | tee "$BUILD_DIR/build-$name.log" | grep -E 'build running|build finished|error|igneumd|installing' || true
sssh "$ip" 'mkdir -p /opt/igneum/bin && cp /root/out/igneumd /root/out/igneum-miner /opt/igneum/bin/ && /opt/igneum/bin/igneumd --version | head -1' || die "build did not produce igneumd (see $BUILD_DIR/build-$name.log)"
fi
peers=$(awk -F'\t' -v n="$name" -v p="$P2P_PORT" '$1 != n { print $4 ":" p }' "$SEEDS_TSV" | paste -sd, -)
[ -n "$SEED_PEERS" ] && peers="${peers:+$peers,}$SEED_PEERS"
sscp "$CD/node/wrpc.py" "$HERE/node/run-seed.sh" "$SSH_USER@$ip:/opt/igneum/bin/"
sscp "$HERE/node/install-seed.sh" "$HERE/node/igneumd.service" "$SSH_USER@$ip:/root/"
sssh "$ip" "bash /root/install-seed.sh '$name' '$ip' '$NETWORK_ARGS' '$peers' $P2P_PORT $RPC_PORT $RPC_JSON_PORT $EVM_RPC_PORT"
log "started. Health in 30 s:"; sleep 30
"$HERE/health.sh" "$name" || true