
echo "wait until eth1 up";
sleep 3;

tc qdisc add dev eth0 root netem delay $DELAY rate $RATE
tc qdisc show dev eth0

tc qdisc add dev eth1 root netem delay $ETH1DELAY rate $ETH1RATE
tc qdisc show dev eth1

chmod +x /ipfs-abr-proxy

ping -c 2 172.17.0.1
#ping -c 10 192.168.155.1

mkdir /ipfs
ipfs init --config /ipfs --profile local-discovery
ipfs config --config /ipfs Addresses.Gateway /ip4/0.0.0.0/tcp/8080
ipfs config --config /ipfs --json Gateway.PublicGateways '{"localhost": null }'
ipfs bootstrap add --config /ipfs "/ip4/172.18.0.1/tcp/4001/p2p/12D3KooWBSRuJhj9zikv2UMvsRFyRPBQM5ftKAF1cQsYzQc1t7ax"
ipfs bootstrap add --config /ipfs "/ip4/34.127.100.239/tcp/4001/p2p/12D3KooWSmk1mhvn2s472GXVGFZ7qEUg8yQ89fntcABR4pmBcMJb"
#ipfs bootstrap add --config /ipfs "/ip4/67.85.143.117/tcp/4001/p2p/12D3KooWQosWLXB98kMSdyDPhRhnDtu8tqQxnQnDD8muwTAEuy8U"
ipfs id --config /ipfs

if [[ "$PROXY_SOURCE" == "" ]]; then
    echo "use default proxy source"
    PROXY_SOURCE="http://localhost:8080"
else
    echo "proxy $PROXY_SOURCE"
fi
export PROXY_SOURCE;
supervisord -c /supervisord.conf
