2024-05-24 18:01:58 +08:00
|
|
|
#!/usr/bin/env bash
|
2020-08-15 02:11:56 +08:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
NAME=Sia
|
|
|
|
|
2021-02-15 06:29:28 +08:00
|
|
|
# shellcheck disable=SC1090
|
|
|
|
. "$(dirname "$0")"/docker.bash
|
|
|
|
|
|
|
|
# wait until Sia test network is up,
|
|
|
|
# the Sia renter forms contracts on the blockchain
|
|
|
|
# and the renter is upload ready
|
|
|
|
wait_for_sia() {
|
|
|
|
until curl -A Sia-Agent -s "$1" | grep -q '"ready":true'
|
|
|
|
do
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
}
|
|
|
|
export -f wait_for_sia
|
2020-08-15 02:11:56 +08:00
|
|
|
|
|
|
|
start() {
|
2021-02-15 06:29:28 +08:00
|
|
|
# use non-production sia port in test
|
|
|
|
SIA_CONN="127.0.0.1:39980"
|
2023-03-25 15:30:54 +08:00
|
|
|
# nebulouslabs/siaantfarm is stale, use up-to-date image
|
2021-02-15 06:29:28 +08:00
|
|
|
ANTFARM_IMAGE=ivandeex/sia-antfarm:latest
|
2020-08-15 02:11:56 +08:00
|
|
|
|
2021-02-15 06:29:28 +08:00
|
|
|
# pull latest antfarm image (dont use local image)
|
|
|
|
docker pull --quiet $ANTFARM_IMAGE
|
2020-08-15 02:11:56 +08:00
|
|
|
|
2021-02-15 06:29:28 +08:00
|
|
|
# start latest antfarm with default config
|
|
|
|
docker run --rm --detach --name "$NAME" \
|
|
|
|
--publish "${SIA_CONN}:9980" \
|
|
|
|
$ANTFARM_IMAGE
|
2020-08-15 02:11:56 +08:00
|
|
|
|
2021-02-15 06:29:28 +08:00
|
|
|
# wait until the test network is upload ready
|
|
|
|
timeout 300 bash -c "wait_for_sia ${SIA_CONN}/renter/uploadready"
|
2020-08-15 02:11:56 +08:00
|
|
|
|
|
|
|
# confirm backend type in the generated rclone.conf
|
|
|
|
echo "type=sia"
|
|
|
|
# override keys in the Sia section of generated rclone.conf
|
|
|
|
echo "api_url=http://${SIA_CONN}/"
|
|
|
|
# hint test harness where to probe for connection
|
|
|
|
echo "_connect=${SIA_CONN}"
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
if status ; then
|
|
|
|
docker logs "$NAME" >> sia-test.log 2>&1
|
|
|
|
docker kill "$NAME"
|
|
|
|
echo "${NAME} stopped"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2021-02-15 06:29:28 +08:00
|
|
|
# shellcheck disable=SC1090
|
|
|
|
. "$(dirname "$0")"/run.bash
|