2023-05-17 21:11:56 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
lotus --version
|
|
|
|
|
2023-08-09 11:54:47 +00:00
|
|
|
# remove old bootnode peer info if present
|
|
|
|
if [ -f /root/.lotus-shared/miner.addr ]; then
|
|
|
|
rm /root/.lotus-shared/miner.addr
|
|
|
|
fi
|
2023-05-17 21:11:56 +00:00
|
|
|
|
2023-08-09 11:54:47 +00:00
|
|
|
# Check if filecoin-proof-parameters exist; avoid fetching if they do
|
|
|
|
if [ -z "$(find "/var/tmp/filecoin-proof-parameters" -maxdepth 1 -type f)" ]; then
|
|
|
|
echo "Proof params not found, fetching..."
|
|
|
|
lotus fetch-params 2048
|
|
|
|
else
|
|
|
|
echo "Existing proof params found"
|
|
|
|
fi
|
2023-05-17 21:11:56 +00:00
|
|
|
|
2023-08-14 07:16:04 +00:00
|
|
|
# if genesis is not already setup
|
|
|
|
if [ ! -f /root/data/localnet.json ]; then
|
|
|
|
lotus-seed --sector-dir /root/data/.genesis-sectors pre-seal --sector-size 2KiB --num-sectors 2
|
|
|
|
lotus-seed --sector-dir /root/data/.genesis-sectors genesis new /root/data/localnet.json
|
|
|
|
lotus-seed --sector-dir /root/data/.genesis-sectors genesis add-miner /root/data/localnet.json /root/data/.genesis-sectors/pre-seal-t01000.json
|
|
|
|
fi
|
2023-05-17 21:11:56 +00:00
|
|
|
|
|
|
|
# start daemon
|
2023-08-14 07:16:04 +00:00
|
|
|
nohup lotus daemon --lotus-make-genesis=/root/.lotus-shared/devgen.car --profile=bootstrapper --genesis-template=/root/data/localnet.json --bootstrap=false > /var/log/lotus.log 2>&1 &
|
2023-05-17 21:11:56 +00:00
|
|
|
|
|
|
|
# Loop until the daemon is started
|
|
|
|
echo "Waiting for daemon to start..."
|
|
|
|
while ! grep -q "started ChainNotify channel" /var/log/lotus.log ; do
|
2023-08-09 11:54:47 +00:00
|
|
|
sleep 5
|
2023-05-17 21:11:56 +00:00
|
|
|
done
|
|
|
|
echo "Daemon started."
|
|
|
|
|
|
|
|
# if miner not already initialized
|
2023-08-09 11:54:47 +00:00
|
|
|
if [ ! -d $LOTUS_MINER_PATH ]; then
|
2023-05-17 21:11:56 +00:00
|
|
|
# initialize miner
|
2023-08-14 07:16:04 +00:00
|
|
|
lotus wallet import --as-default /root/data/.genesis-sectors/pre-seal-t01000.key
|
2023-08-09 11:54:47 +00:00
|
|
|
|
|
|
|
# fund a known account for usage
|
|
|
|
/fund-account.sh
|
|
|
|
|
2023-08-30 10:35:16 +00:00
|
|
|
echo "Initializing miner..."
|
2023-08-14 07:16:04 +00:00
|
|
|
lotus-miner init --genesis-miner --actor=t01000 --sector-size=2KiB --pre-sealed-sectors=/root/data/.genesis-sectors --pre-sealed-metadata=/root/data/.genesis-sectors/pre-seal-t01000.json --nosync
|
2023-05-17 21:11:56 +00:00
|
|
|
fi
|
|
|
|
|
2023-08-14 08:47:21 +00:00
|
|
|
# publish bootnode peer info to shared volume
|
|
|
|
lotus net listen | grep "$(ip addr | grep inet | grep -v '127.0.0.1' | sort | head -1 | awk '{print $2}' | cut -d '/' -f1)" | head -1 > /root/.lotus-shared/miner.addr
|
|
|
|
|
2023-05-17 21:11:56 +00:00
|
|
|
# start miner
|
|
|
|
nohup lotus-miner run --nosync &
|
|
|
|
|
|
|
|
tail -f /dev/null
|