Guide to running SFBot as Systemd service on Linux
Verfasst: So 11. Okt 2020, 11:16
Hello,
This topic is for Linux begginers who owns some Linux server and wants to run this bot on it using systemd service.
Notes:
If you copy-paste the code remove the "[root@localhost ~]# "<-- and the space.
Change the: "<your_user>" to user name you are using to connect to your machine.. If you are using root user then change the path /home/<your_user> to /root
If you have questions feel free to ask
This topic is for Linux begginers who owns some Linux server and wants to run this bot on it using systemd service.
Notes:
If you copy-paste the code remove the "[root@localhost ~]# "<-- and the space.
Change the: "<your_user>" to user name you are using to connect to your machine.. If you are using root user then change the path /home/<your_user> to /root
- Create Linux service user with:
Code: Alles auswählen
[root@localhost ~]# useradd -c "SFBot acc" -d /opt/sfbot -s /sbin/nologin sfbot
- Now we can download the MFBot binary from here: http://www.mfbot.de/en/downloads/ and select the binary which fits your system. In my case I am using x86 architecture cpu so I pick "x86_64/amd64 processors (linux servers with intel processors or similar)"... You might use different one.
Code: Alles auswählen
[root@localhost sfbot]# cd /opt/sfbot/ [root@localhost sfbot]# wget http://www.mfbot.de/Download/latest/MFBot_Konsole_x86_64
- Create systemd service file.
Copy-paste these lines and save
Code: Alles auswählen
[root@localhost sfbot]# nano /etc/systemd/system/sfbot.service
Now reload the service filesCode: Alles auswählen
[Unit] Description=Magical Fidget Bot After=syslog.target After=network.target [Service] Type=simple User=sfbot Group=sfbot StandardOutput=syslog StandardError=syslog SyslogIdentifier=sfbot EnvironmentFile=/etc/sfbot/.env WorkingDirectory=/opt/sfbot/ # Change the name of the file "MFBot_Konsole_x86_64" to the different one if you downloaded different executable ExecStart="/opt/sfbot/MFBot_Konsole_x86_64" [Install] WantedBy=multi-user.target
Now you could execute and see if service is loadedCode: Alles auswählen
[root@localhost sfbot]# systemctl daemon-reload
If you now see some lines that looks like this you did this process rightCode: Alles auswählen
[root@localhost sfbot]# systemctl status sfbot.service
Code: Alles auswählen
sfbot.service - Magical Fidget Bot Loaded: loaded (/etc/systemd/system/sfbot.service; disabled; vendor preset: enabled) Active: inactive (dead)
- Create environment file for the future exeperiments and so on..
Create directory for .env fileCreate the empty .env fileCode: Alles auswählen
[root@localhost sfbot]# mkdir /etc/sfbot
Set the owner of the directory and .env fileCode: Alles auswählen
[root@localhost sfbot]# touch /etc/sfbot/.env
Code: Alles auswählen
[root@localhost sfbot]# chown -R sfbot:sfbot /etc/sfbot/
- Prepare the Acc.ini file which you can create on the Windows version of this app.
- Upload it to the machine to your /home/<your_user>. For example you can use WinSCP or FileZilla for uploading the file
- Copy the file and set the permissions for sfbot to see the file
Now change the owner to permit sfbot to see the file and "control" it
Code: Alles auswählen
[root@localhost ~]# mv /home/<your_user>/Acc.ini /opt/sfbot/
Code: Alles auswählen
[root@localhost ~]# chown sfbot:sfbot /opt/sfbot/Acc.ini
- If you did everything right you can now execute to start the service:
and to see if service is running:
Code: Alles auswählen
[root@localhost ~]# systemctl start sfbot.service
The output should be something like thisCode: Alles auswählen
[root@localhost ~]# systemctl status sfbot.service
Code: Alles auswählen
sfbot.service - Magical Fidget Bot Loaded: loaded (/etc/systemd/system/sfbot.service; disabled; vendor preset: enabled) Active: active (running) since Sun 2020-10-11 11:09:09 CEST; 1s ago Main PID: 104785 (MFBot_Konsole_A) Tasks: 4 (limit: 9252) CGroup: /system.slice/sfbot.service └─104785 /opt/sfbot/MFBot_Konsole_XXXXX
Code: Alles auswählen
[root@localhost ~]# journalctl -u sfbot