Guide for Raspberry to run MFBot on startup

Antworten
brosassin
Beiträge: 4
Registriert: Fr 30. Okt 2020, 16:57
Hat sich bedankt: 2 Mal
Danksagung erhalten: 1 Mal

Guide for Raspberry to run MFBot on startup

Beitrag von brosassin »

Goal: Set a Raspberry Pi with a clean Raspbian OS, to run MFBot on startup.

Assumption 1: You have Raspbian (with or without GUI) installed on a Raspberry Pi and have access with SSH and SFTP if no GUI installed or headless (or you are comfortable managing files using the terminal).
Assumption 2: You have created and have access to your Acc.ini file containing all your account settings. Usually, run the MFBot.exe bot on your Windows machine and setup your accounts, so in the end the Acc.ini file is created or updated.
Assumption 3: If asked, confirm every action during this guide.
Spoiler: I used "sudo" on some commands even if not needed to avoid some people with little experience on terminal commands, asking why the commands do not work. Also, I chose to create a service to run the bot because I found other methods not working well or not on all platforms. I created this guide because I wanted most of the Information needed to run MFBot on Raspbian to exist in one place and couldn't find it anywhere. Finally and obviously, this guide is working in the time of writing it and I am not responsible if something goes wrong or if something breaks.


Guide:

On Terminal (with GUI) / With SSH (Putty on Windows, without GUI)
  • Update the OS with:

    Code: Alles auswählen

    sudo apt-get update 
    and

    Code: Alles auswählen

    sudo apt-get upgrade 
    and accepting by typing "y" when needed
  • Install MFBot to Raspberry with:

    Code: Alles auswählen

    wget http://www.mfbot.de/Download/latest/MFBot_Konsole_ARMRasp 
  • Install Mono environment with:

    Code: Alles auswählen

    sudo apt-get install mono-runtime 
Raspbian file manager (with GUI) / With SFTP (Filezilla on Windows, without GUI)
  • Navigate to: /home/pi/
  • Make sure the file exists: "MFBot_Konsole_ARMRasp"
  • Create a safe folder (ex.): "MFBot"
  • Move the file: "MFBot_Konsole_ARMRasp" to the created folder
  • Take the file "Acc.ini" containing your account settings and place it inside the created folder
  • Make sure that the created folder: "/home/pi/MFBot/" contains the files "MFBot_Konsole_ARMRasp" and "Acc.ini"
On Terminal (with GUI) / With SSH (Putty on Windows, without GUI) Raspbian file manager (with GUI) / With SFTP (Filezilla on Windows, without GUI)
To add the run command on startup with a service, create a file "mfb.service" on "/home/pi/MFBot/" with the following contents:

Code: Alles auswählen

[Unit]
Description=MFBot Daemon
After=network.target
Requires=network.target

[Service]
User=pi
Group=pi
Type=simple
WorkingDirectory=/home/pi/MFBot
ExecStart=/home/pi/MFBot/MFBot_Konsole_ARMRasp
Restart=always

[Install]
WantedBy = multi-user.target 

On Terminal (with GUI) / With SSH (Putty on Windows, without GUI)
  • If not already there, navigate to "/home/pi/MFBot/" using:

    Code: Alles auswählen

    cd /home/pi/MFBot/ 
  • Copy the file to /etc/systemd/system/ using:

    Code: Alles auswählen

    sudo cp mfb.service /etc/systemd/system/mfb.service 
  • To check the service, start it with: [/code]sudo systemctl start mfb.service [/code]
  • Check if the bot is running, doing stuff in your account/accounts etc.
  • And stop the service with:

    Code: Alles auswählen

    sudo systemctl stop mfb.service
  • When you confirmed everything works, enable the service to run on startup with:

    Code: Alles auswählen

    sudo systemctl enable mfb.service
  • And reboot to test it with:

    Code: Alles auswählen

    sudo reboot
PS: I probably covered most aspects of installing and running MFBot on Raspbian. I would be happy to help and I am open to any optimizations you might suggest!
Folgende Benutzer bedankten sich beim Autor brosassin für den Beitrag:
Oshino (Di 3. Nov 2020, 21:40)
Benutzeravatar
TakeViagraDieHard
Spender
Beiträge: 140
Registriert: Fr 29. Jun 2018, 21:53
Wohnort: NRW
Hat sich bedankt: 14 Mal
Danksagung erhalten: 46 Mal

Re: Guide for Raspberry to run MFBot on startup

Beitrag von TakeViagraDieHard »

Hello Brosassin,

I just like to let you know that the installation of Mono needs to be done a bit different. Due to the outdated Raspbian repository it might not work correctly.
According to the manual on the Mono homepage it should be done like this:
https://www.mono-project.com/download/s ... n-raspbian

Code: Alles auswählen

sudo apt install apt-transport-https dirmngr gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/debian stable-raspbianbuster main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update
sudo apt install mono-complete
sudo apt install referenceassemblies-pcl
sudo apt install ca-certificates-mono
sudo cert-sync
After the installation "apt-get update " and "apt-get upgrade" will keep you up to date.

I also created a installation tutorial a while ago, but I missed to translate it for our international community.
http://www.mfbot.de/forum/viewtopic.php?p=15154#p15154
Folgende Benutzer bedankten sich beim Autor TakeViagraDieHard für den Beitrag:
brosassin (Mi 4. Nov 2020, 01:58)
brosassin
Beiträge: 4
Registriert: Fr 30. Okt 2020, 16:57
Hat sich bedankt: 2 Mal
Danksagung erhalten: 1 Mal

Re: Guide for Raspberry to run MFBot on startup

Beitrag von brosassin »

TakeViagraDieHard hat geschrieben: Di 3. Nov 2020, 18:28 I just like to let you know that the installation of Mono needs to be done a bit different. Due to the outdated Raspbian repository it might not work correctly.
According to the manual on the Mono homepage it should be done like this:
https://www.mono-project.com/download/s ... n-raspbian
I sure will keep that in mind and thank you for your tip! However, I have not faced any trouble even if I installed Mono in a Raspberry Zero W clean-install Raspbian headless-no GUI and a Raspberry 2 Raspbian with GUI with a 1-year-old image, updated-upgraded with no problems. My guesses are that they updated the Raspbian repository... maybe? :roll: :D
TakeViagraDieHard hat geschrieben: Di 3. Nov 2020, 18:28 I also created a installation tutorial a while ago, but I missed to translate it for our international community.
http://www.mfbot.de/forum/viewtopic.php?p=15154#p15154
Oh, ok! I see what you did by reading the commands (I know enough German to understand several things but havent spoken since years ago). Very thoughtful to create another user for running the bot, well done! On the other hand, I am not a fan of cronjobs. Anyway, I did not find the guide when searching for one. You might want to create a new post or something so new members could be benefited because I believe yours is very helpful and in depth!

Again, thank you for your reply. Always happy to see knowledgeable and helpful members!
Mfighter
Beiträge: 3
Registriert: Mi 2. Jun 2021, 17:31
Hat sich bedankt: 0
Danksagung erhalten: 1 Mal

Re: Guide for Raspberry to run MFBot on startup

Beitrag von Mfighter »

Because your method creates 100% cpu usage on one core, I use the following ExecStart to fix it:

ExecStart=/usr/bin/screen -DmS mfbot /home/ubuntu/mfbot/MFBot_Konsole_ARM64


This way you can also control the bot in screen.
Antworten

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste