1. Home
  2. Delegate
  3. Linux
  4. Maintaining Your Node

Maintaining Your Node


To complete this tutorial, you will need:

  • To have a working Shift instance


1.) shift-snapshot

The first script you need to install is shift-snapshot. shift-checker depends on it because:

  • It can create snapshots of the current node state
  • It can restore snapshots to a previous node state

First of all you’ll need to clone the GitHub repository to your server:

cd ~ 
git clone https://github.com/mrgrshift/shift-snapshot.git
cd shift-snapshot/

For a list of commands do:

bash shift-snapshot.sh help

When your node is fully synced, make sure to create a new snapshot:

bash shift-snapshot.sh create

2.) shift-checker

The second script you need to install is shift-checker. It will:

  • Auto-Start your node when your server rebooted
  • Check the health of your node
  • When forked, restore to a previous state depending on shift-snapshot
  • When healthy, create a daily snapshot
  • Auto-Switch between master and slave node
  • Keep you up-to-date with Telegram

First of all make sure to check of the prerequisites:

Make sure install the package dependencies:

sudo apt install php php-cli php-mbstring php-sqlite3

Be sure that your php.ini allows passthru(). It’s default that it does though, so only check if this script is not working.

Now step into your home directory and clone shift-checker from GitHub:

cd ~ 
git clone https://github.com/MxShift/shift-checker

Rename config.example.php file to config.php and change settings inside it to match your needs.

a.) Add crontab

We need to run shift-checker regulary. We will edit crontab to do so every minute:

crontab -e

And add in this:

# Start shift-checker every minute
* * * * * php ~/shift-checker/checkdelegate.php >> ~/shift-checker/logs/checkdelegate.log 2>&1

To clear unnecessary logs created by shift-checker also add this:

# Clear shift-checker logs
@daily forever cleanlogs

b.) Check logs

To check the logs of shift-checker, move to its directory and run this command:

tail -f ./logs/checkdelegate.log

You can exit it by pressing CTRL+C.

c.) Telegram (Recommended)

As mentioned, shift-checker comes with Telegram functionality which will allow it to send you a message if anything requires your attention. To enable it, you’ll need to edit the config.php in the folder:

cd shift-checker
nano config.php
a.) $telegramId
  1. Open Telegram and start a conversation with: userinfobot
  2. Replace $telegramId with your ID
$telegramId = "12345678";
b.) $telegramApiKey
  1. Start a conversation with: botfather
  2. Say: /newbot
  3. Tell botfather your bot’s name
  4. Tell botfather your bot’s username
  5. Botfather will say “Congratulations!” and give you a token
  6. Replace $telegramApiKey with your ID
$telegramApiKey = "1122334455:AAEhBOweik6ad9r_QXMENQjcrGbqCr4K-bs";
c.) Enable Telegram functionality
  1. Edit the Telegram toggle to true (enable) or false (disabled)
  2. Start a conversation with your bot to enable communication between you two.
$telegramAll = false; // true if you want to receive all messages from shift-checker, but it might be annoying
$SyncingMessage = true;
Was this article helpful to you? Yes 1 No 1

How can we help?