New Farmerbot Install Script


Hi Farmers,

I’ve created a script to automate the installation and configuration of the new Farmerbot. It can be used with a full VM on the Grid, a Raspberry Pi (64 bit only), and most other Linux systems.

Here’s what the script can do:

  • Download and install the farmerbot binary (AMD/Intel or arm64)
  • Generate configuration files by asking you questions
  • Create a systemd service to manage the bot and keep it running
  • Set up multiple bots on the same system

Please note that this script is developed on a best effort basis and is not a product of TF Tech. I’m here to help, but support for use of the script may be limited.

This script requires root access and will ask you to enter your mnemonic seed phrase if you choose to use the configuration feature. I recommend running this script inside of a fresh VM or Linux install dedicated to running Farmerbot, not a critical system containing important data (like your laptop). Use the script at your own risk.

Getting started

First, choose a location to store the Farmerbot config files and create a directory. Here’s an example using the current user’s home directory:

mkdir ~/farmerbot
cd ~/farmerbot

Now download the script:

wget https://gist.githubusercontent.com/scottyeager/b4e4504f037841da165e7f759976a86c/raw/farmerbot-setup.sh

Before we proceed to run the script, there are two important notes:

  1. The location of the configuration files is important. If you move or rename this folder, it will interfere with the ability of the bot to start in the future (for how to handle this, see below)
  2. If you want to set up multiple bots on one machine, skip to the next section now

The script must be run as root. You can use sudo either way to be sure:

sudo bash farmerbot-setup.sh

Just follow the prompts on screen and the script will take care of the rest. If you make any mistakes or accidentally skip a step, you can run the script again and overwrite the previous outputs.

If you just need one bot, you can skip the next section and move on to learning how to manage the bot.

Multiple bots

It’s possible to set up multiple bots using the script. Each bot should get a subfolder to hold its config files and you’ll need to choose a unique name for each bot’s service. Assuming you already did the steps above, here’s an example for how to structure the folders and call the script:

mkdir bot1
cd bot1
sudo bash ../farmerbot-setup.sh
cd ..

mkdir bot2
cd bot2
sudo bash ../farmerbot-setup.sh
cd ..

# Repeat as needed...

You can skip the download and install step after the first run of the script. When the script asks you to enter a name for the service, I’d recommend using the same names as your subfolders (“bot1” and “bot2” in the example).

As mentioned before, remember that the location and names of these folders are important and extra steps are required to change them. Instructions are in a section below.

Managing bots

At the end of the script, you have the option to start the bot service. If you did that, the bot will start writing logs to the file farmerbot.log in the same folder as its config files.

A quick check that everything worked properly is to get the status of the systemd service:

sudo systemctl status farmerbot

You can get more detail on the operation of the bot by inspecting the log file:

# See all logs so far
cat farmerbot.log

# See the last ten lines and new logs as they are generated
tail -f farmerbot.log

# See all logs and new lines as they are generated
tail -f -n +1 farmerbot.log

Start and stop bots

If you need to start or stop the bot, such as to implement config changes, you can use these commands:

# Stop the bot (replace "farmerbot" with your service name)
sudo systemctl stop farmerbot

# Start the bot
sudo systemctl start farmerbot

# Restart the bot
sudo systemctl restart farmerbot

The script will also enable each service it generates. This means that the bot will start up again automatically if the host system ever reboots. If you want to stop the bot permanently, you can also disable the service:

sudo systemctl disable farmerbot

Updating the farmerbot binary

The script can also help with downloading new versions of the Farmerbot program when they are released. To do this, just run the script, use only the first step, and confirm to overwrite the existing binary when prompted. You’ll also need to restart any running bots for the change to take effect.

You might also want to backup the existing version in case you need to roll back. Here’s a complete example:

# Make a copy of the current version
cp /usr/local/bin/farmerbot ./farmerbot.bak

# Update using the script
sudo bash farmerbot-setup.sh

# Restart the bot
sudo systemctl restart farmerbot

# Something went wrong, restore the backup
sudo cp ./farmerbot.bak /user/local/bin/farmerbot
sudo systemctl restart farmerbot

Moving the config files

As mentioned before, the location of the configuration files is significant, and the service won’t be able to start again if you move those files. If you need to move or rename the folder containing the config files, run the script again afterwards and regenerate the service file by overwriting the old one.

Here’s an example:

# Stop and disable the service first
sudo systemctl stop farmerbot
sudo systemctl disable farmerbot

# Now move the files to new folder
cd ~
mkdir threefold
mv farmerbot threefold
cd threefold/farmerbot
sudo bash farmerbot-setup.sh
# Skip the download and config steps, just overwrite the service file

# Make sure it came back up successfully
sudo systemctl status farmerbot

For multiple bots, here’s the variation (this assumes you also want to rename the service for the bot):

sudo systemctl stop bot1
sudo systemctl disable bot1
sudo rm /etc/systemd/system/bot1.service

cd ~/farmerbot
mv bot1 super-bot
cd super-bot
sudo bash ../farmerbot-setup.sh

sudo systemctl status super-bot

Uninstall

If you want to completely remove all files generated by the script, just run the following commands. If you used a custom service name or a different config folder, substitute those as needed:

sudo systemctl stop farmerbot
sudo systemctl disable farmerbot

sudo rm /etc/systemd/system/farmerbot.service
sudo rm /usr/local/bin/farmerbot
sudo rm -r ~/farmerbot

That’s all, folks

If the script worked for you (or didn’t), or if you have any questions, please drop me a reply.

3 Likes

This script is really easy to use and it works very well. For now I’m running one farm with 6 Dells and 1 HP, they all did their periodic wake up like they should and fall asleep after 35-45 Minutes. Our second farm is running on the old fb I will get it to the new one today and tell you how it goes with multiple fbs installed with Scotts awesome Script.

Also with two farmerbots running on one VM there are no problems…

2 Likes

Glad to hear it! Thanks so much for reporting back :slightly_smiling_face:

1 Like

It seems to hang on node ids that are not in use associated with your farm id.

I installed the farmerbot using the video but it is giving me this error now. Any idea what i am doing wrong here?

It looks like the secret you entered is not activated with a twin. How did you create your farm?

If you used the Dashboard, you should provide the mnemonic seed phrase as your secret. If you used the TF Connect app, use the TF Chain hex secret for the farm found in the app.

I log in to the dashboard via polkadot password. For this VM I used the 24 word seed phrase from the app where I get my tokens. I have a twin id in my dashboard. Should I use the seed phrase for the polkadot?
Can you also tell me what is the difference between mnemonic seed phrase and TF Chain hex Secret?
Thanks,

Yes, I’d suggest to try again with the seed phrase for your Polkadot account.

In the TF Connect app, there is a “main” seed phrase that’s used to derive all accounts, including Stellar wallets and TF Chain wallets. The hex secrets represent individual accounts derived from that seed phrase.

Most of our tools accept either a seed phrase or hex secret. When a seed phrase is supplied, only one derivation path is used. Due to the respective implementations, the seed phrase and hex secrets from the TF Connect app are not interchangeable for the use case of managing farms created in the app.