diff --git a/scripts/walletsBalance.sh b/scripts/walletsBalance.sh index 6040f55..21d5304 100755 --- a/scripts/walletsBalance.sh +++ b/scripts/walletsBalance.sh @@ -1,44 +1,51 @@ #!/bin/bash -# Récupération du chemin absolut du répertoir du script actuel +# Récupération du chemin absolu du répertoire du script actuel GPATH="$( cd "$(dirname "$0")" ; pwd -P )/.." [[ ! -f $GPATH/.env ]] && cp $GPATH/.env.example $GPATH/.env source $GPATH/.env node=$(cut -d '/' -f3 <<<"$DUNITER") -#Check if Jaklis is installed -[[ -z $JAKLIS ]] && JAKLIS=$(which silkaj) -[[ -z $JAKLIS ]] && echo "Erreur: Vous devez installer Jaklis." && exit 1 +#Check if ed is installed +which ed || { echo "$0: Error: please install ed" >&2 ; exit 1 ; } + +#Check if Jaklis or silkaj is installed +if [[ "$JAKLIS" ]] ; then + exec() { + jsonResult=$($JAKLIS idBalance -p $i) || return $? + balance=$(echo "$jsonResult" | jq -r '.balance') + username=$(echo "$jsonResult" | jq -r '.username') + } +elif which silkaj ; then + exec() { + balance=$(silkaj -p "$node" balance "$i") || return $? + balance=$(sed -n 's,.* \([\.0-9]\+\) Ğ1.*,\1,p' <<<$balance) + username=$(silkaj -p "$node" id "$i") || return $? + username=$(sed -n 's,.*: \(.*\)$,\1,p' <<<$username) + } +else + echo "$0: Error: you should use Jaklis or install silkaj." >&2 + exit 1 +fi work() { - for i in $wallets; do - exec() { - jsonResult=$($JAKLIS idBalance -p $i 2>/dev/null) - } - exec - while [[ $? == 1 ]]; do echo "Erreur $k: $i"; ((k++)); exec; done - unset k + for i in $wallets; do + ((j++)) + # For tests only + #(( j > 42 )) && break - balance=$(echo "$jsonResult" | jq -r '.balance') - username=$(echo "$jsonResult" | jq -r '.username') - formatedBalance=$(printf "%-10s | %-45s | %-1s" $balance $i $username) + unset k + while ! exec ; do echo "Erreur $?: retry=$((k)) wallet=$i"; ((k++ > 9999)) && break ; sleep $((RANDOM%8)) ; done - if [[ $1 == "members" ]]; then - htmlBloc="$htmlBloc"$'\n'"
Solde (Ḡ1) | Clé publique | Identifiant utilisateur | |
---|---|---|---|
Position | Solde (Ḡ1) | Clé publique | Identifiant utilisateur |