I’ve seen a few people run into issues when stopping farmerbot, specifically when the on-chain power target of their nodes is set to DOWN. This should address the issue.
This script is to be used in conjunction with the service modification explained below, effectively automating the switch to “UP” state anytime the farmerbot service is stopped using sudo systemctl stop {farmerbot}
In all instances where you see {farmID} or {farmerbot} - replace these with your actual farm ID and farmerbot service name.
First create the wake script in the directory containing your farmerbot config.yaml file (this location is strictly necessary due to the requirement of the .env which is in the same directory):
cd ~/path/to/farmerbot
sudo nano wakeall{farmID}.sh
Add the following, then save (ctrl+o, enter) and exit (ctrl+x):
#!/bin/bash
# Change to the directory where farmerbot and .env are located
cd /path/to/farmerbot/
# Run the farmerbot wake all command
farmerbot start all -e .env --farm {farmID}
Once the script is created and assuming you’re still in the directory where the script is located, make it executable:
sudo chmod +x wakeall{farmID}.sh
Next we need to add a line to the service override.conf
sudo nano /etc/systemd/system/{farmerbot}.service.d/override.conf
Add:
[Service]
ExecStopPost=/bin/bash /path/to/farmerbot/wakeall{farmID}.sh
Then reload the daemon
sudo systemctl daemon-reload
That’s it. Now when we run sudo systemctl stop {farmerbot} the service will be stopped and all nodes under farmerbot control will have their on-chain power target set to “UP”. Remember to switch the {placeholders} for the actual farm ID and farmerbot service name.