X-Git-Url: http://git.treefish.org/~alex/bitvalue.git/blobdiff_plain/8f94a429314435cd96b90ac1d1a96a3b6196908d..a7e51dc32761a31f908f39fb59e5c1098384e5cd:/bitvalue?ds=inline diff --git a/bitvalue b/bitvalue index 831145d..9cb4ee9 100755 --- a/bitvalue +++ b/bitvalue @@ -1,15 +1,16 @@ #!/bin/bash CONFIG=~/.bitvaluerc +HOST=data.bitcoinity.org + +TIMESPAN="24h" USAGE="Usage: $(basename "$0") [-h] [-t val] Simple bash script to visualize the value of your bitcoin investment. Arguments: -h show this help text - -t set the timespan (default: 30d)" - -TIMESPAN="30d" + -t set the timespan (default: $TIMESPAN)" while getopts ':ht:' option; do case "$option" in @@ -42,12 +43,24 @@ fi source $CONFIG -cat << EOF | gnuplot +if ! ping -c 1 $HOST >/dev/null 2>&1; then + echo "Host $HOST is unreachable!" + exit 1 +fi + +cat << EOF | gnuplot 2>/dev/null set terminal dumb set datafile separator "," set xdata time set timefmt "%Y-%m-%d %H:%M:%S UTC" set title "EXCHANGE: $EXCHANGE | TIMESPAN: $TIMESPAN\nZERO RATE: $ZERO_RATE $CURRENCY | ZERO VALUE: $ZERO_VALUE $CURRENCY" -plot "< wget -q -O - \"https://data.bitcoinity.org/export_data.csv?currency=$CURRENCY&data_type=price&exchange=$EXCHANGE&t=l×pan=$TIMESPAN\"" \ +plot "< wget -q -O - \"https://$HOST/export_data.csv?currency=$CURRENCY&data_type=price&exchange=$EXCHANGE&t=l×pan=$TIMESPAN\"" \ using 1:(\$3/$ZERO_RATE*$ZERO_VALUE) with lines title "" EOF + +if [ $? -ne 0 ]; then + echo "Error while preparing data!" >&2 + exit 1 +fi + +exit 0