#!/bin/bash . /tmp/cic/config/env_reset OUT_DIR=out CONFIG_DIR=config confini-dump --schema-dir $CONFIG_DIR if [[ -d "$OUT_DIR" ]] then echo -e "\033[;96mfound existing IMPORT DIR cleaning up...\033[;96m" rm -rf "$OUT_DIR" mkdir -p "$OUT_DIR" else echo -e "\033[;96mIMPORT DIR does not exist creating it.\033[;96m" mkdir -p "$OUT_DIR" fi # using timeout because the timeout flag for celery inspect does not work timeout 5 celery inspect ping -b "$CELERY_BROKER_URL" if [[ $? -eq 124 ]] then >&2 echo -e "\033[;96mCelery workers not available. Is the CELERY_BROKER_URL ($CELERY_BROKER_URL) correct?\033[;96m" exit 1 fi echo -e "\033[;96mCreating seed data...\033[;96m" python create_import_users.py -vv -c "$CONFIG_DIR" --dir "$OUT_DIR" "$NUMBER_OF_USERS" wait $! echo -e "\033[;96mCheck for running celery workers ...\033[;96m" if [ -f ./cic-ussd-import.pid ]; then echo -e "\033[;96mFound a running worker. Killing ...\033[;96m" kill -TERM $( nohup.out 2> nohup.err < /dev/null & else echo -e "\033[;96mRunning worker with opening balance transactions\033[;96m" TARGET_TX_COUNT=$((NUMBER_OF_USERS*2)) nohup python cic_ussd/import_balance.py -vv -c "$CONFIG_DIR" -p "$ETH_PROVIDER" -r "$CIC_REGISTRY_ADDRESS" --include-balances --token-symbol "$TOKEN_SYMBOL" -y "$WALLET_KEY_FILE" "$OUT_DIR" & fi echo -e "\033[;96mTarget count set to ${TARGET_TX_COUNT}" until [ -f ./cic-import-ussd.pid ] do echo -e "\033[;96mPolling for celery worker pid file...\033[;96m" sleep 1 done IMPORT_BALANCE_JOB=$(