From 184efef8647843e82a9217e1750a4a92f0b424b9 Mon Sep 17 00:00:00 2001 From: Evan Duffield Date: Fri, 20 May 2016 12:42:46 -0700 Subject: [PATCH] Added dash env files for testing environment --- env/evan-macosx-develop.bash | 72 +++++++++++++++++++++ env/{dash.bash => evan-ubuntu-develop.bash} | 62 +++--------------- env/misc.bash | 54 ++++++++++++++++ 3 files changed, 134 insertions(+), 54 deletions(-) create mode 100644 env/evan-macosx-develop.bash rename env/{dash.bash => evan-ubuntu-develop.bash} (69%) create mode 100644 env/misc.bash diff --git a/env/evan-macosx-develop.bash b/env/evan-macosx-develop.bash new file mode 100644 index 000000000..8d484cac4 --- /dev/null +++ b/env/evan-macosx-develop.bash @@ -0,0 +1,72 @@ +############## Dash Project Commands ##################### +# +# An easy to use way of testing dash core +# +# ATTENTION: +# **** change these each project, so that the default is correct usually **** +# + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $DIR/misc.bash + +DASHLOG="mnbudget,mnpayments" +DASHDEBUG="lldb --" +DASHBINARY="./dashd" +DASHDIR="dash/testnet" +DASHBINARY="./dashd" +DASHNETWORK="testnet" + +cmd_dash() +{ + if [ "$1" = "help" ]; then + echo "dash command center"; + echo " example: dash set debug on" + echo "-----------------------------------"; + echo ""; + echo "setting up environment:"; + echo " set debug on|off (lldb mode)"; + echo " set mode qt|daemon"; + echo " set log options"; + echo ""; + echo "starting/stopping the client:"; + echo " start"; + echo " stop"; + echo ""; + echo "using cli:"; + echo " cli [options]"; + echo ""; + fi; + + + #---- debug mode off/on + if [ "$1 $2 $3" = "set debug on" ]; then DASHDEBUG="lldb --"; echo "debug mode on"; return; fi; + if [ "$1 $2 $3" = "set debug off" ]; then DASHDEBUG=""; echo "debug mode off"; return; fi; + if [ "$1 $2" = "set debug" ]; then return; fi; + + #---- setup binaries + if [ "$1 $2 $3" = "set mode qt" ]; then DASHBINARY="./dash-qt";echo "qt mode on"; return; fi; + if [ "$1 $2 $3" = "set mode daemon" ]; then DASHBINARY="./dashd";echo "daemon mode on"; return; fi; + if [ "$1 $2" = "set mode" ]; then return; fi; + + #---- generic commands + if [ "$1" = "start" ]; then $DASHDEBUG ~/$DASHDIR/bin/$DASHBINARY --datadir=$DIR/../../data --debug=$DASHLOG -logthreadnames; return; fi; + if [ "$1 $2" = "hard start" ]; then $DASHDEBUG ~/$DASHDIR/bin/$DASHBINARY --datadir=$DIR/../../data --debug=$DASHLOG -reindex -logthreadnames; return; fi; + if [ "$1" = "cd" ]; then cd ~/$DASHDIR/src; return; fi; + + #---- tail $DASHDIR/network/debug.log + if [ "$1 $DASHNETWORK" = "tail testnet" ]; then cd ~/$DASHDIR/data/testnet3 && tail -f debug.log ; return; fi; + if [ "$1 $DASHNETWORK" = "tail mainnet" ]; then cd ~/$DASHDIR/data && tail -f debug.log ; return; fi; + if [ "$1 $DASHNETWORK" = "tail regtest" ]; then cd ~/$DASHDIR/data/regtest && tail -f debug.log ; return; fi; + + array=$@; + array="${array[@]:3}"; + + echo $array; + echo "$DIR/../../data" + #----- cli commands + if [ "$1" = "cli" ]; then cd ~/$DASHDIR/bin && ./dash-cli --datadir=$DIR/../../data $array; return; fi; + + echo "unknown dash command. see 'dash help'" +} + +alias dash=cmd_dash; \ No newline at end of file diff --git a/env/dash.bash b/env/evan-ubuntu-develop.bash similarity index 69% rename from env/dash.bash rename to env/evan-ubuntu-develop.bash index 516ab37ca..172a57631 100644 --- a/env/dash.bash +++ b/env/evan-ubuntu-develop.bash @@ -6,65 +6,17 @@ # **** change these each project, so that the default is correct usually **** # +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +source $DIR/misc.bash + HOMEUSER="evan" DASHLOG="mnbudget,mnpayments" DASHDEBUG="lldb --" -DASHBINARY="./dashd" DASHNETWORK="testnet" #mainnet, testnet, regtest -DASHDIR=".dash-develop" -#DASHBINARY="./dash-qt" +DASHDIR="./dash/develop" +DASHBINARY="./dash/bin/develop/dashd" -touch_logs() -{ - touch ~/.dash/debug.log; - for ((i=2;i<=9;i++)); - do - touch ~/.dash$i/debug.log; - done -} - -stop_cluster() -{ - ./dash-cli --datadir=/Users/$HOMEUSER/.dash stop - for ((i=2;i<=9;i++)); - do - echo "stopping dash$i " - ./dash-cli --datadir=/Users/$HOMEUSER/.dash$i stop - done -} - -start_cluster() -{ - for ((i=1;i<=9;i++)); - do - echo "starting dash$i " - ./dashd --datadir=/Users/$HOMEUSER/.dash$i --daemon - done -} - -cmd_cluster() -{ - array=$@; - re='^[0-9]$' - locked="any"; - if [[ $1 =~ $re ]] ; then - #if the first parameter is a number, we'll assume we want to execute that specific daemon - locked=$1; - array="${array[@]:1}"; - fi; - - for ((i=1;i<=9;i++)); - do - if [ $locked == $i ] ; then - echo "dash$i $array" - ./dash-cli --datadir=/Users/$HOMEUSER/.dash$i $array - fi; - if [ $locked = "any" ] ; then - echo "dash$i " - ./dash-cli --datadir=/Users/$HOMEUSER/.dash$i $array - fi; - done -} +source misc.bash cmd_dash() { @@ -96,6 +48,8 @@ cmd_dash() #---- setup binaries if [ "$1 $2 $3" = "set mode qt" ]; then DASHBINARY="./dash-qt";echo "qt mode on"; return; fi; if [ "$1 $2 $3" = "set mode daemon" ]; then DASHBINARY="./dashd";echo "daemon mode on"; return; fi; + if [ "$1 $2 $3" = "set mode testnet" ]; then DASHBINARY="./dash-qt";echo "qt mode on"; return; fi; + if [ "$1 $2 $3" = "set mode mainnet" ]; then DASHBINARY="./dashd";echo "daemon mode on"; return; fi; if [ "$1 $2" = "set mode" ]; then return; fi; #---- generic commands diff --git a/env/misc.bash b/env/misc.bash new file mode 100644 index 000000000..9daee03d7 --- /dev/null +++ b/env/misc.bash @@ -0,0 +1,54 @@ + + + +touch_logs() +{ + touch ~/.dash/debug.log; + for ((i=2;i<=9;i++)); + do + touch ~/.dash$i/debug.log; + done +} + +stop_cluster() +{ + ./dash-cli --datadir=/Users/$HOMEUSER/.dash stop + for ((i=2;i<=9;i++)); + do + echo "stopping dash$i " + ./dash-cli --datadir=/Users/$HOMEUSER/.dash$i stop + done +} + +start_cluster() +{ + for ((i=1;i<=9;i++)); + do + echo "starting dash$i " + ./dashd --datadir=/Users/$HOMEUSER/.dash$i --daemon + done +} + +cmd_cluster() +{ + array=$@; + re='^[0-9]$' + locked="any"; + if [[ $1 =~ $re ]] ; then + #if the first parameter is a number, we'll assume we want to execute that specific daemon + locked=$1; + array="${array[@]:1}"; + fi; + + for ((i=1;i<=9;i++)); + do + if [ $locked == $i ] ; then + echo "dash$i $array" + ./dash-cli --datadir=/Users/$HOMEUSER/.dash$i $array + fi; + if [ $locked = "any" ] ; then + echo "dash$i " + ./dash-cli --datadir=/Users/$HOMEUSER/.dash$i $array + fi; + done +} \ No newline at end of file