Linux Wallet notifier script (Stake and recieve notifier)

Hi,

I wrote for my stake server (LOL, it’s only a NAS :slight_smile: ) a script to get notifications by mail when i recieve a stake or a payment.
Maybe i can make someone happy by sharing this script.

Greetings,

Elkan

You love it? RfzGpXcTwFagGGt192V6yPyKGk1fRk53au for tips… :slight_smile:

#!/bin/bash

REDDCOIND=/home/user/.reddcoin/bin/64/reddcoind    #Your reddcoind client
STAKEFILE=/home/user/.reddcoin/stake.tmp               #File for saving stake amount (auto created)
AMOUNTFILE=/home/user/.reddcoin/amount.tmp             #File for wallet amount (auto created)
SUBJECT="YEEY, i got ReddCoins!!"                       #Your email subject
EMAIL="youremail.nl"                                 #Your email address

#######################################################################################
#Name:   SimpleWalletCheck.sh
#Author: Elkan Roelen
#Email:  Roelenelkan.nl
#
#Nice and simple cron script for stake and recieve RDD in linux
#Needs:
#- change the variable before this info block
#- bc (most of the time already installed) http://www.gnu.org/software/bc/
#- mail (test with $: mail youremail.com -s TESTSubject
#
#Extra:
#- Add this script to your cron so it will be automaticly checked!
#
#Donation address for tips :) : RfzGpXcTwFagGGt192V6yPyKGk1fRk53au
#Happy Staking, Goodluck and thank you!
#######################################################################################




if [ ! -f $STAKEFILE ]; then
        echo 0 > $STAKEFILE
        echo "File $STAKEFILE created!"
fi

if [ ! -f $AMOUNTFILE ]; then
        echo 0 > $AMOUNTFILE
        echo "File $AMOUNTFILE created!"
fi

NEW=$($REDDCOIND getinterest)
OLD=$(cat $STAKEFILE)
NOW=$(date)
declare -i OLD
SENDMAIL=0
STAKE=$(echo $NEW - $OLD | bc)

echo "========================="
echo "$NOW"
#echo "$OLD"
#echo "$NEW"
#echo "$STAKE"


STAKED=${STAKE%.*}
#echo "$STAKED"
if [ $STAKED -gt 0 ]
then
        echo "Er is $STAKE RDD gestaked!"
        echo $NEW > $STAKEFILE
        echo ""
        SENDMAIL=1
else
        echo "Nothing staked!"
        echo ""
fi



#BALANCE_NEW=$($REDDCOIND getinfo | grep '"balance" : ' | grep -o -P '(?<="balance" : ).*(?=,)')
BALANCE_NEW=$($REDDCOIND getbalance)
BALANCE_OLD=$(cat $AMOUNTFILE)
NOW=$(date)
declare -i BALANCE_OLD
RECIEVED=$(echo $BALANCE_NEW - $BALANCE_OLD | bc)

echo "========================="
echo "$NOW"
#echo "$BALANCE_OLD"
#echo "$BALANCE_NEW"
#echo "$RECIEVED"


RECIE=${RECIEVED%.*}
if [ $RECIE -gt 0 ]
then
        echo "Yeey, je hebt $RECIEVED RDD ontvangen!"
        echo $BALANCE_NEW > $AMOUNTFILE
        echo ""
        SENDMAIL=1
else
        echo "Niks ontvangen!"
        echo ""

fi

echo "=========================="
if [ $SENDMAIL -eq 1 ]
then
        echo "Send email"
        echo "Subject : $SUBJECT"
        echo "Body:"

        if [ $STAKED -eq $RECIE ]
        then
        BODY="
                $NOW
                =====================================

                Yeey, je hebt weer nieuwe munten:

                Staked: $STAKE RDD
                Totale balance: $BALANCE_NEW RDD"

        echo "Staked:  $STAKE RDD"

        else
        echo "Staked:  $STAKE RDD"
        echo "Recieved:  $RECIEVED RDD"
        echo "Total balance:  $BALANCE_NEW RDD"

        BODY="
                $NOW
                =====================================

                Yeey, je hebt weer nieuwe munten:

                Staked: $STAKE RDD
                Recieved:  $RECIEVED RDD
                Totale balance: $BALANCE_NEW RDD"

        fi
echo "$BODY" | mail "$EMAIL" -s "$SUBJECT"
fi

I don’t have tested your script but give you an up-vote because sharing is always the right thing :slight_smile:
thanks mate!

ReddcoinRocks Thank you…
I’m only wondering why the code is not shown nice/beautiful/good on the forum… :frowning:

Elkan The font size of the comment section is strange and the scrolling also but is everything there and is it complete? You could post a pastebin link too

// EDIT: now it looks better

ReddcoinRocks Getting better… :slight_smile:
A tab after a comment fails… :slight_smile:
But it is complete…