#!/bin/sh

RESP=$(/usr/local/bin/bee init --config /usr/local/etc/swarm-bee/bee.yaml 2>&1)
case "$RESP" in
    Error*)
        echo "
Enabled clef-signer but clef is not running.
Check https://docs.ethswarm.org/ for more info.
After you fix configuration run 'bee-get-addr' again.
        "
        ;;
    *)
        ETH_ADDRESS=$(echo "$RESP" | grep ethereum | cut -d' ' -f6 | tr -d '"')
        echo "
Please make sure there is sufficient eth and bzz available on $ETH_ADDRESS address.
You can get both Goerli ETH and Goerli BZZ now via the bzzaar at https://bzz.ethswarm.org/?transaction=buy&amount=%d&slippage=30&receiver=0x$ETH_ADDRESS

After you get the funds start service with 'brew services start swarm-bee'.
        "
        ;;
esac
