github.com/rclone/rclone@v1.66.1-0.20240517100346-7b89735ae726/fstest/testserver/init.d/TestSia (about) 1 #!/bin/bash 2 3 set -e 4 5 NAME=Sia 6 7 # shellcheck disable=SC1090 8 . "$(dirname "$0")"/docker.bash 9 10 # wait until Sia test network is up, 11 # the Sia renter forms contracts on the blockchain 12 # and the renter is upload ready 13 wait_for_sia() { 14 until curl -A Sia-Agent -s "$1" | grep -q '"ready":true' 15 do 16 sleep 5 17 done 18 } 19 export -f wait_for_sia 20 21 start() { 22 # use non-production sia port in test 23 SIA_CONN="127.0.0.1:39980" 24 # nebulouslabs/siaantfarm is stale, use up-to-date image 25 ANTFARM_IMAGE=ivandeex/sia-antfarm:latest 26 27 # pull latest antfarm image (dont use local image) 28 docker pull --quiet $ANTFARM_IMAGE 29 30 # start latest antfarm with default config 31 docker run --rm --detach --name "$NAME" \ 32 --publish "${SIA_CONN}:9980" \ 33 $ANTFARM_IMAGE 34 35 # wait until the test network is upload ready 36 timeout 300 bash -c "wait_for_sia ${SIA_CONN}/renter/uploadready" 37 38 # confirm backend type in the generated rclone.conf 39 echo "type=sia" 40 # override keys in the Sia section of generated rclone.conf 41 echo "api_url=http://${SIA_CONN}/" 42 # hint test harness where to probe for connection 43 echo "_connect=${SIA_CONN}" 44 } 45 46 stop() { 47 if status ; then 48 docker logs "$NAME" >> sia-test.log 2>&1 49 docker kill "$NAME" 50 echo "${NAME} stopped" 51 fi 52 } 53 54 # shellcheck disable=SC1090 55 . "$(dirname "$0")"/run.bash