From d3796abac7b84665aec6bb28db48129ad7bc9735 Mon Sep 17 00:00:00 2001 From: Travis Person <165274+travisperson@users.noreply.github.com> Date: Mon, 27 Apr 2020 19:52:55 +0000 Subject: [PATCH] Quick setup script (#1352) * Quick setup script * Auto noncefix and properly record stderr of miner * Use new pledge sector command * Build native ffi * Add PreCommit1 and PreCommit2 * Move into scripts dir Co-authored-by: Travis Person --- scripts/quick-network-join.bash | 180 ++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+) create mode 100755 scripts/quick-network-join.bash diff --git a/scripts/quick-network-join.bash b/scripts/quick-network-join.bash new file mode 100755 index 000000000..cde40cd33 --- /dev/null +++ b/scripts/quick-network-join.bash @@ -0,0 +1,180 @@ +#!/usr/bin/env bash + +session="lotus-interop" +wdaemon="daemon" +wminer="miner" +wsetup="setup" +wpledging="pledging" +wcli="cli" +faucet="http://t01000.miner.interopnet.kittyhawk.wtf" + +PLEDGE_COUNT="${1:-20}" +BRANCH="interopnet" +BASEDIR=$(mktemp -d -t "lotus-interopnet.XXXX") + +git clone --branch "$BRANCH" https://github.com/filecoin-project/lotus.git "${BASEDIR}/build" + +mkdir -p "${BASEDIR}/scripts" +mkdir -p "${BASEDIR}/bin" + +cat > "${BASEDIR}/scripts/build.bash" </dev/null 2>&1 && pwd )" +pushd \$SCRIPTDIR/../build + +pwd +env RUSTFLAGS="-C target-cpu=native -g" FFI_BUILD_FROM_SOURCE=1 make clean deps lotus lotus-storage-miner lotus-shed +cp lotus lotus-storage-miner lotus-shed ../bin/ + +popd +EOF + +cat > "${BASEDIR}/scripts/env.fish" < "${BASEDIR}/scripts/env.bash" < "${BASEDIR}/scripts/create_miner.bash" < "${BASEDIR}/scripts/pledge_sectors.bash" < ${PLEDGE_COUNT} )); then + break + fi + + while true; do + state=\$(lotus-storage-miner sectors list | tail -n1 | awk '{print \$2}') + + if [ -z "\$state" ]; then + break + fi + + case \$state in + PreCommit1 | PreCommit2 | Packing | Unsealed | PreCommitting | Committing | CommitWait | FinalizeSector ) sleep 30 ;; + WaitSeed | Proving ) break ;; + * ) echo "Unknown Sector State: \$state" + lotus-storage-miner sectors status --log \$current + break ;; + esac + done + + lotus-storage-miner sectors pledge + + while [ "\$current" == "\$sector" ]; do + sector=\$(lotus-storage-miner sectors list | tail -n1 | awk '{print \$1}' | tr -d ':') + sleep 5 + done + + current="\$sector" +done +EOF + +cat > "${BASEDIR}/scripts/monitor.bash" <&1 | tee -a ${BASEDIR}/daemon.log" C-m + +sleep 30 + +tmux send-keys -t $session:$wminer "${BASEDIR}/scripts/create_miner.bash" C-m +tmux send-keys -t $session:$wminer "lotus-storage-miner run --api 48020 2>&1 | tee -a ${BASEDIR}/miner.log" C-m +tmux send-keys -t $session:$wcli "${BASEDIR}/scripts/monitor.bash" C-m +tmux send-keys -t $session:$wpleding "${BASEDIR}/scripts/pledge_sectors.bash" C-m + +tmux select-window -t $session:$wcli + +tmux attach-session -t $session +