6. Scheduled tasks

In this final chapter, we will setup some scheduled tasks and scripts that will enable your Raspberry Pi to run stratisd automatically after a restart. This procedure is not recommended for Stratis-qt, as it does not run in the same way, take head to this cautionary advisement.

Start Stratis and enable staking automatically

Type crontab -e to open the document containing your users scheduled tasks. If you are starting crontab for the first time, select nano as your editor of choice.

Add these line to the bottom of the file:

@reboot sleep 60; stratisd -daemon -rescan -detachdb
*/30 * * * * /home/pi/checkstratis >/dev/null 2>&1

Now save the file by pressing Ctrl+X then Y, then finally press Enter.

This will run the script /home/pi/checkstratis every 30 minutes. It will check if stratisd is running, if not it will initiate it and unlock the wallet for staking.

Create the script that checks Stratis every half an hour

Type nano /home/pi/checkstratis and type this into the empty file (don't forget to replace YOUR_PASSWORD_HERE with your password):

#! /bin/bash

history -c

case "$(pidof stratisd | wc -w)" in

0)  echo "Stratis Wallet Restarted @ $(date)" >> /home/pi/CheckStratis.log 
    stratisd -daemon -rescan -detachdb
    sleep 120; stratisd walletpassphrase YOUR_PASSWORD_HERE 9999999 true
    ;;

1)  echo "Stratis daemon already running @ $(date)"  >> /home/pi/CheckStratis.log
    echo "=============================" >> /home/pi/Stratis.log
    ;;
esac

exit 0

Now save the file by pressing Ctrl+X then Y, then finally press Enter.

Make the file executable by typing chmod +x /home/pi/checkstratis

Restart your Raspberry Pi.

After 30 minutes, make sure Stratis has started by typing stratisd getinfo. You should now get data about your Stratis wallet. To check that staking is enabled, type stratisd getstakinginfo. It might take some more time before staking is fully enabled. Be patient.

A note on saving the password in this file

When this guide was written STRAT was still worth pennies, so it made sense to have the password in this file for convenience. I would recommend anyone following this guide to remove the line with:

sleep 120; stratisd walletpassphrase YOUR_PASSWORD_HERE 9999999 true

This way the wallet will not be unlocked automatically on for example a power failure, and it will be your own responsibility to check on your wallet now and then to make sure it is staking. The command for unlocking the wallet manually is:

stratisd walletpassphrase YOUR_PASSWORD_HERE 9999999 true

Update @ 2/05/2017
Added the
history -c line. This will make sure all commands you have entered in the command prompt will be cleaned up from the system every 30 minutes. This way passwords can't be saved on the system by mistake.

Add script for updating the system daily

This is optional, creating this script will automatically have your Rpi check for OS updates and install them automatically for you. It will also create a log file with the results of the update process in /home/pi/systemupdates.log

Create the script"

sudo nano /etc/cron.daily/systemupdate

Then copy/paste the following script into the file:

#! /bin/bash

#Updates system / removes any unused packages

echo "" >> /home/pi/systemupdates.log; echo "Checking system for updates @ $(date)" >> /home/pi/systemupdates.log; echo "" >> /home/pi/systemupdates.log

apt update >> /home/pi/systemupdates.log; apt dist-upgrade -y >> /home/pi/systemupdates.log; apt-get autoremove -y >> /home/pi/systemupdates.log

echo "" >> /home/pi/systemupdates.log; echo "System up-to-date !" >> /home/pi/systemupdates.log

exit 0

Now save the file by pressing Ctrl+X then Y, and press Enter.


End of Tutorial

Well done you have completed the Raspberry Pi Stratis Staking Tutorial! We hope you have enjoyed this guide and encourage you to provide any feedback If you like what we've produced here please come join us on slack ! @olcko, @demon, tips are appreciated too. Thank you!

results matching ""

    No results matching ""