# New Farmerbot Install Script

**URL:** <https://forum.threefold.io/t/new-farmerbot-install-script/4207>\
**Category:** ThreeFold Farming\
**Created:** [January 29, 2024, 10:58pm UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207 "2024-01-29T22:58:58Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott](https://forum.threefold.io/user_avatar/forum.threefold.io/scott/32/604_2.png) [@scott](https://forum.threefold.io/u/scott)\
**Post date:** [January 29, 2024, 10:58pm UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/1 "2024-01-29T22:58:58Z")

</div>

* * *

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:

```nohighlight
mkdir ~/farmerbot
cd ~/farmerbot

```

Now download the script:

```bash
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:

```auto
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:

```python
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:

```bash
sudo systemctl status farmerbot

```

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

```bash
# 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:

```bash
# 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:

```nohighlight
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:

```python
# 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:

```python
# 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):

```nohighlight
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:

```nohighlight
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.

---

<div class="post-metadata">

**Author:** ![tabularaza](https://forum.threefold.io/letter_avatar_proxy/v4/letter/t/b19c9b/32.png) [@tabularaza](https://forum.threefold.io/u/tabularaza)\
**Post date:** [February 1, 2024, 10:08am UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/2 "2024-02-01T10:08:21Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![scott](https://forum.threefold.io/user_avatar/forum.threefold.io/scott/32/604_2.png) [@scott](https://forum.threefold.io/u/scott)\
**Post date:** [February 5, 2024, 10:52pm UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/3 "2024-02-05T22:52:47Z")

</div>

Glad to hear it! Thanks so much for reporting back 🙂

---

<div class="post-metadata">

**Author:** ![FLnelson](https://forum.threefold.io/user_avatar/forum.threefold.io/flnelson/32/2602_2.png) [@FLnelson](https://forum.threefold.io/u/FLnelson)\
**Post date:** [March 7, 2024, 1:47am UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/5 "2024-03-07T01:47:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![stanikzai](https://forum.threefold.io/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@stanikzai](https://forum.threefold.io/u/stanikzai)\
**Post date:** [March 8, 2024, 5:03pm UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/6 "2024-03-08T17:03:02Z")

</div>

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

 ![image](https://forum.threefold.io/uploads/default/original/2X/4/445367e2ccc0d20a381133bb36dadc8cf3a6df27.png)

---

<div class="post-metadata">

**Author:** ![scott](https://forum.threefold.io/user_avatar/forum.threefold.io/scott/32/604_2.png) [@scott](https://forum.threefold.io/u/scott)\
**Post date:** [March 9, 2024, 1:38am UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/7 "2024-03-09T01:38:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![stanikzai](https://forum.threefold.io/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@stanikzai](https://forum.threefold.io/u/stanikzai)\
**Post date:** [March 9, 2024, 4:50am UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/8 "2024-03-09T04:50:48Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![scott](https://forum.threefold.io/user_avatar/forum.threefold.io/scott/32/604_2.png) [@scott](https://forum.threefold.io/u/scott)\
**Post date:** [March 10, 2024, 9:46pm UTC](https://forum.threefold.io/t/new-farmerbot-install-script/4207/9 "2024-03-10T21:46:44Z")

</div>

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.
