From b0a83f63a3628bbf31f881e80faa31980cbe593b Mon Sep 17 00:00:00 2001 From: nahuhh <50635951+nahuhh@users.noreply.github.com> Date: Sat, 19 Oct 2024 03:35:41 +0000 Subject: [PATCH] autoupd8: use for loop --- bsx/auto_coinupd8.sh | 102 +++++++++++++------------------------------ 1 file changed, 30 insertions(+), 72 deletions(-) diff --git a/bsx/auto_coinupd8.sh b/bsx/auto_coinupd8.sh index 9e207d8..2c3cc14 100755 --- a/bsx/auto_coinupd8.sh +++ b/bsx/auto_coinupd8.sh @@ -1,85 +1,43 @@ #!/bin/bash #set -x SWAP_DATADIR=$HOME/coinswaps +BINDIR=$SWAP_DATADIR/bin echo "Checking for Coin updates" && sleep 1 -if [[ -d $SWAP_DATADIR/bin/bitcoin ]]; then - BTC=$($SWAP_DATADIR/bin/bitcoin/bitcoind --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $BTC ]]; then - echo "Updating Bitcoin" - Bitcoin="bitcoin," +chain=( +bitcoin +dash +decred +firo +litecoin +particl +pivx +monero +wownero +) + +list="" +select="" +for coin in "${chain[@]}"; do + if [[ -d $BINDIR/$coin ]]; then + if [[ $coin == decred ]]; then + UPDATE=$($BINDIR/$coin/dcrd --version | head -n 1 | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) + else + UPDATE=$($BINDIR/$coin/"$coin"d --version | head -n 1 | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) + fi + if [[ -z $UPDATE ]]; then + select+="$coin," + list=${select%,} + fi fi -fi +done -if [[ -d $SWAP_DATADIR/bin/dash ]]; then - DASH=$($SWAP_DATADIR/bin/dash/dashd --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $DASH ]]; then - echo "Updating Dash" - Dash="dash," - fi -fi +echo "Updating $list" -if [[ -d $SWAP_DATADIR/bin/decred ]]; then - DCR=$($SWAP_DATADIR/bin/decred/dcrd --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $DCR ]]; then - echo "Updating Decred" - Decred="decred," - fi -fi - -if [[ -d $SWAP_DATADIR/bin/firo ]]; then - FIRO=$($SWAP_DATADIR/bin/firo/firod --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $FIRO ]]; then - echo "Updating Firo" - Firo="firo," - fi -fi - -if [[ -d $SWAP_DATADIR/bin/litecoin ]]; then - LTC=$($SWAP_DATADIR/bin/litecoin/litecoind --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $LTC ]]; then - echo "Updating Litecoin" - Litecoin="litecoin," - fi -fi - -if [[ -d $SWAP_DATADIR/bin/particl ]]; then - PART=$($SWAP_DATADIR/bin/particl/particld --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $PART ]]; then - echo "Updating Particl" - fi -fi - -if [[ -d $SWAP_DATADIR/bin/pivx ]]; then - PIVX=$($SWAP_DATADIR/bin/pivx/pivxd --version | grep version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $PIVX ]]; then - echo "Updating PIVX" - Pivx="pivx," - fi -fi - -if [[ -d $SWAP_DATADIR/bin/monero ]]; then - XMR=$($SWAP_DATADIR/bin/monero/monerod --version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $XMR ]]; then - echo "Updating Monero" - Monero="monero," - fi -fi - -if [[ -d $SWAP_DATADIR/bin/wownero ]]; then - WOW=$($SWAP_DATADIR/bin/wownero/wownerod --version | grep -Fxf $SWAP_DATADIR/basicswap/core_versions) - if [[ -z $WOW ]]; then - echo "Updating Wownero" - Wownero="wownero," - fi -fi - -sleep 1 - -if [[ -n $Bitcoin ]] || [[ -n $Dash ]] || [[ -n $Decred ]] || [[ -n $Firo ]] || [[ -n $Litecoin ]] || [[ -n $Particl ]] || [[ -n $Pivx ]] || [[ -n $Monero ]] || [[ -n $Wownero ]]; then +if [[ -n $select ]]; then . $SWAP_DATADIR/venv/bin/activate - basicswap-prepare --datadir=$SWAP_DATADIR --preparebinonly --withcoins="$Bitcoin$Dash$Decred$Firo$Litecoin$Pivx$Monero$Wownero"particl + basicswap-prepare --datadir=$SWAP_DATADIR --preparebinonly --withcoins=$list else echo "Coin Cores are up to date" fi