github.com/FusionFoundation/efsn/v4@v4.2.0/docker-entrypoint-miner-local-gtw.sh (about)

     1  #!/bin/sh
     2  NODES_ROOT=/fusion-node
     3  # NODES_ROOT=/Users/work/dev/tmp/fusion-node
     4  DATA_DIR=$NODES_ROOT/data
     5  KEYSTORE_DIR=$DATA_DIR/keystore
     6  unlock=
     7  ethstats=
     8  testnet=
     9  autobt=false
    10  mining=true
    11  
    12  display_usage() {
    13      echo "Commands for Fusion efsn:"
    14      echo -e "-e value    Reporting name of a ethstats service"
    15      echo -e "-u value    Account to unlock"
    16      echo -e "-a          Auto buy tickets"
    17      echo -e "-tn         Connect to testnet"
    18      }
    19  
    20  while [ "$1" != "" ]; do
    21      case $1 in
    22          -u | --unlock )         shift
    23                                  unlock=$1
    24                                  ;;
    25          -e | --ethstats )       shift
    26                                  ethstats=$1
    27                                  ;;
    28          -tn | --testnet )       testnet=true
    29                                  ;;
    30          -a | --autobt )         autobt=true
    31                                  ;;
    32          --disable-mining )      mining=false
    33                                  ;;
    34          * )                     display_usage
    35                                  exit 1
    36      esac
    37      shift
    38  done
    39  
    40  # create data folder if does not exit
    41  if [ ! -d "$DATA_DIR" ]; then
    42      mkdir $DATA_DIR
    43  fi
    44  
    45  # create keystore folder if does not exit
    46  if [ ! -d "$KEYSTORE_DIR" ]; then
    47      mkdir $KEYSTORE_DIR
    48  fi
    49  
    50  # copy keystore file
    51  cp $NODES_ROOT/UTC* $KEYSTORE_DIR/ 2>/dev/null
    52  
    53  # format command option
    54  cmd_options="--datadir $DATA_DIR --password /fusion-node/password.txt"
    55  
    56  # Following the geth documentation at https://geth.ethereum.org/docs/rpc/server
    57  # cmd_options_local_gtw=' --identity 1 --rpc --rpcapi "eth,net,fsn,fsntx" --rpcaddr 127.0.0.1 --rpcport 9000 --rpccorsdomain "*" --ws  --wsapi "eth,net,fsn,fsntx" --wsaddr 127.0.0.1 --wsport 9001 --wsorigins "*"'
    58  cmd_options_local_gtw=' --identity 1 --http --http.api=eth,net,fsn,fsntx --http.addr=0.0.0.0 --http.port=9000 --http.corsdomain=* --ws --ws.api=eth,net,fsn,fsntx --ws.addr=0.0.0.0 --ws.port=9001 --ws.origins=*'
    59  
    60  if [ "$testnet" ]; then
    61      testnet=" --testnet"
    62      cmd_options=$cmd_options$testnet
    63  fi
    64  
    65  if [ "$ethstats" ]; then
    66      if [ "$testnet" ]; then
    67          ethstats=" --ethstats $ethstats:devFusioInfo2019142@devnodestats.fusionnetwork.io"
    68      else 
    69          ethstats=" --ethstats $ethstats:fsnMainnet@node.fusionnetwork.io"
    70      fi
    71      cmd_options=$cmd_options$ethstats
    72  fi
    73  
    74  if [ "$unlock" ]; then
    75  
    76      # pattern=$KEYSTORE_DIR/UTC*
    77      # echo "pater: $pattern"
    78  
    79      # keystore_files=($pattern)
    80  
    81      # # for f in "${keystore_files[@]}"; do
    82      # #     echo "file: $f"
    83      # # done
    84  
    85      # echo "file: ${keystore_files[0]}"
    86  
    87      # utc_json_address="$(cat < ${keystore_files[0]} | jq -r '.address')"
    88      # echo "utc_json_address: $utc_json_address"
    89  
    90      # if [ "$utc_json_address" = "$unlock" ]; then
    91      #     echo "$unlock is 'valid'"
    92      # fi
    93  
    94      # echo "unlock set to: $unlock"
    95      unlock=" --unlock $unlock"
    96      cmd_options=$cmd_options$unlock
    97  fi
    98  
    99  if [ "$autobt" = true ]; then
   100      autobt=" --autobt"
   101      cmd_options=$cmd_options$autobt
   102  fi
   103  
   104  if [ "$mining" = true ]; then
   105      mining=" --mine"
   106      cmd_options=$cmd_options$mining
   107  fi
   108  
   109  echo "efsn flags: $cmd_options$cmd_options_local_gtw"
   110  
   111  # efsn  --unlock $unlock --ethstats
   112  exec efsn $cmd_options$cmd_options_local_gtw