diff --git a/README.md b/README.md index 8115633..5e75bf1 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Message options **To use shapeshift API add the `-I 2` command:** ```bash -# Get Linux & SMS & Telegram notice when BTC is above 10000 USD (every time command is run) +# Get Linux notice when BTC is above 16 ETH (every time command is run) ./getPrice.sh -c BTC -C ETH -av 16 -l -I 2 ``` diff --git a/functions.sh b/functions.sh index b98a91e..37a9b23 100644 --- a/functions.sh +++ b/functions.sh @@ -351,7 +351,7 @@ function sendTime () { local target_type="$1" local target_value="$2" # build key send time - keySendTime=$(echo -n "${target_type}${target_value}${sendKey}" | md5sum) + keySendTime=$(echo -n "${target_type}${target_value}${sendKey}" | md5sum | sed 's/ .*$//') # check if we should send if (( "$sendSwitch" == 2 )) then diff --git a/getPrice.sh b/getPrice.sh index 9bc0e93..836d0f0 100755 --- a/getPrice.sh +++ b/getPrice.sh @@ -80,7 +80,10 @@ Getting Coin Value in Fiat Currency at set price ====================================================== -q Quiet - Turn off terninal output -t Send A Telegram Notice + -T Set notify Line number to use (first line is default) -s Send A SMS Notice + -M Set sms Line number to use (first line is default) + -S Set smsto Line number to use (first line is default) -l Show A Linux Notice via zenity -h display this help menu @@ -97,7 +100,7 @@ exit 1 # http://mywiki.wooledge.org/BashFAQ/035 # http://wiki.bash-hackers.org/howto/getopts_tutorial -while getopts hc:C:o:v:B:A:baqtslf:I: opt; do +while getopts hc:C:o:v:B:A:baqtT:sS:M:lf:I: opt; do case $opt in I) if (( "$OPTARG" == 2 )); then @@ -144,9 +147,21 @@ while getopts hc:C:o:v:B:A:baqtslf:I: opt; do t) Telegram=1 ;; + T) + TelegramID=$OPTARG + Telegram=1 + ;; s) SMS=1 ;; + S) + smstoID=$OPTARG + SMS=1 + ;; + M) + smsID=$OPTARG + SMS=1 + ;; l) LinuxNotice=1 ;; @@ -185,8 +200,11 @@ while getopts hc:C:o:v:B:A:baqtslf:I: opt; do esac done +# set call ID +CALL_ID=$(echo -n "${API_target}${smsID}${smstoID}${TelegramID}" | md5sum | sed 's/ .*$//') + # BUILD Cointracker file per/API -COINTracker="${VDMHOME}/.cointracker_${API_target}" +COINTracker="${VDMHOME}/.cointracker_${CALL_ID}" # make sure the tracker file is set if [ ! -f "$COINTracker" ] then diff --git a/main.sh b/main.sh index 4a53f30..81408af 100644 --- a/main.sh +++ b/main.sh @@ -20,10 +20,13 @@ # main is loaded MAINLOAD=1 + # Do some prep work command -v jq >/dev/null 2>&1 || { echo >&2 "We require jq for this script to run, but it's not installed. Aborting."; exit 1; } command -v curl >/dev/null 2>&1 || { echo >&2 "We require curl for this script to run, but it's not installed. Aborting."; exit 1; } command -v bc >/dev/null 2>&1 || { echo >&2 "We require bc for this script to run, but it's not installed. Aborting."; exit 1; } +command -v sed >/dev/null 2>&1 || { echo >&2 "We require sed for this script to run, but it's not installed. Aborting."; exit 1; } +command -v md5sum >/dev/null 2>&1 || { echo >&2 "We require md5sum for this script to run, but it's not installed. Aborting."; exit 1; } # load notify . "$DIR/functions.sh" @@ -36,6 +39,7 @@ command -v bc >/dev/null 2>&1 || { echo >&2 "We require bc for this script to ru # Some global defaults Factory=0 + # basic settings Currency="BTC" Target="USD" @@ -47,14 +51,18 @@ TargetBelow=0 TargetAbove=0 BelowValue=0 AboveValue=0 + # message settings send=0 sendSwitch=2 sendKey=$(TZ=":ZULU" date +"%m/%d/%Y" ) allowEcho=1 Telegram=0 +TelegramID=1 LinuxNotice=0 SMS=0 +smsID=1 +smstoID=1 # API URL API_show=1 diff --git a/notify.sh b/notify.sh index 2f94506..7aa07a7 100644 --- a/notify.sh +++ b/notify.sh @@ -28,10 +28,12 @@ function notifyMe() { exit 1 fi # get first line - local NOTIFY=$(head -n 1 "$DIR/notify") + local NOTIFY=$(sed -n "${TelegramID}p" < "$DIR/notify") + # get the keys IFS=$' ' local keys=( $NOTIFY ) + # set chatid & token local chatid="${keys[0]}" local token="${keys[1]}" diff --git a/sms.sh b/sms.sh index 3fdeb0f..1dedf36 100644 --- a/sms.sh +++ b/sms.sh @@ -36,8 +36,8 @@ function smsMe() { # set Args local message="$1" # get first line - local SMSd=$(head -n 1 "$DIR/sms") - local to=$(head -n 1 "$DIR/smsto") + local SMSd=$(sed -n "${smsID}p" < "$DIR/sms") + local to=$(sed -n "${smstoID}p" < "$DIR/smsto") # get the keys IFS=$' ' local keyss=( $SMSd )