Hi,
I wrote for my stake server (LOL, it’s only a NAS ) 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…
#!/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