Auto-start script for DECENT/PEERPLAYS witnesses

in #witness-category7 years ago (edited)

Hi all witnesses,
I will share a script to help you auto-start your witness node when your system is restarted by the provider.

I will asume that you are running your witness node under a 'screen' session.
In the following guide I use yourlinuxuser please change it in accord your system user.
Before you install this script in your main server I recommend to you to test it in a different server

DECENT

decent.png

For DECENT I will employ the default directories listed in the github: https://github.com/DECENTfoundation/DECENT-Network

Now please create a new file called auto_start.sh, use: nano auto_start.sh
Inside you will need the following code:

#!/bin/bash

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

cd /home/yourlinuxuser/dev/DECENTfoundation/DECENT-Network-build/artifacts/prefix/bin

#If you node do not boot successfully, add a 10 or more waiting seconds for a full reboot of your system (remove '#' from the next line)
#sleep 10
./decentd --rpc-endpoint 127.0.0.1:8090

Now you need to grant access to auto_start.sh script in order to be able to be executed, use this command: chmod a+x auto_start.sh

The last part is to call auto_start.sh script when the system is rebooted. For this you will need cron.
Note if you don't have cron installed run this: sudo apt-get install crontab

To insert a new task for cron do: crontab -e
Inside, insert the following line at the end:

@reboot /usr/bin/screen -dmS witnessReboot bash -c '/home/yourlinuxuser/auto_start.sh; exec bash' >> /home/yourlinuxuser/cron.log 2>&1

For more information about cron use this cheat sheet https://www.codementor.io/akul08/the-ultimate-crontab-cheatsheet-5op0f7o4r

Note that the reboot line have the name witnessReboot for the 'screen' session, you can change that or leave it like that, this is for quickly identify that your system have been rebooted.

To test the result do sudo reboot, wait and login again into your server. Once you are in do screen -ls this command will list all the 'screen' sessions available and you should see witnessReboot. Do screen -r witnessReboot to go inside that 'screen' session, once inside you should see your DECENT node running successfully.


PEERPLAYS

peerplays.png
For PEERPLAYS I will employ the default directories listed in the github: https://github.com/PBSA/peerplays

First go to your peerplays folder with cd peerplays, now please create a new file called auto_start.sh, use: nano auto_start.sh
Inside you will need the following code:

#!/bin/bash

export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8

cd /home/yourlinuxuser/peerplays
cd "$(cd -P -- "$(dirname -- "$0")" && pwd -P)"
root_path=$(pwd)

#If you node do not boot successfully, add a 10 or more waiting seconds for a full reboot of your system (remove '#' from the next line)
#sleep 10
./programs/witness_node/witness_node

Now you need to grant access to auto_start.sh script in order to be able to be executed, use this command: chmod a+x auto_start.sh

The last part is to call auto_start.sh script when the system is rebooted. For this you will need cron.
Note if you don't have cron installed run this: sudo apt-get install crontab

To insert a new task for cron do: crontab -e
Inside, insert the following line at the end:

@reboot /usr/bin/screen -dmS witnessReboot bash -c '/home/yourlinuxuser/peerplays/auto_start.sh; exec bash' >> /home/yourlinuxuser/peerplays/cron.log 2>&1

For more information about cron use this cheat sheet https://www.codementor.io/akul08/the-ultimate-crontab-cheatsheet-5op0f7o4r

Note that the reboot line have the name witnessReboot for the 'screen' session, you can change that or leave it like that, this is for quickly identify that your system have been rebooted.

To test the result do sudo reboot, wait and login again into your server. Once you are in do screen -ls this command will list all the 'screen' sessions available and you should see witnessReboot. Do screen -r witnessReboot to go inside that 'screen' session, once inside you should see your PEERPLAYS node running successfully.


If you enjoyed this post please upvote and also please vote for my witnesses in DECENT and PEERPLAYS.

My DECENT witness is decentspace and you can vote in your cli_wallet as follows:
vote_for_miner <youraccount> decentspace true true

My PEERPLAYS witness is spacecrypt-witness and you can vote in your cli_wallet as follows:
vote_for_witness <youraccount> spacecrypt-witness true true

I wish you a happy and more reliable witnessing!

Sort:  

i will be using this for my witnesses :D

@space4
Great content!
Thanks for sharing!

Congratulations @space4! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote
Award for the number of upvotes received

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Please avoid using #witness-category for networks other than Steem.