Skip to content

Linux Installation

Kozejin edited this page Dec 2, 2024 · 5 revisions

Install Dependencies

  1. Update the package list.
sudo apt update
  1. Install the dependencies.
sudo apt install python3.11 python3.11-venv python3.11-dev git virtualenv nano

Installation (Linux)

  1. Create a new user and switch to it.a
sudo adduser palbot
sudo usermod -aG sudo palbot
su - palbot
  1. Clone the Palworld bot repository with the following commands
git clone https://github.com/dkoz/palworld-bot
cd palworld-bot
  1. Now you need to create a virtual env and install the requirements.
virtualenv venv
source venv/bin/activate
pip install setuptools
pip install -r requirements.txt
  1. Configure the environment variables and server configuration.
cp .env.example .env
nano .env
  1. Now run the bot.
python main.py

Setting up auto-restart using systemd

  1. Create a service file.
sudo nano /etc/systemd/system/palbot.service
  1. Paste the following contents and save the file. Shortcuts: ctrl+o and hit enter, then ctrl+x to exit.
[Unit]
Description=Palworld Bot
After=network.target

[Service]
User=palbot
Group=palbot
WorkingDirectory=/home/palbot/palworld-bot
ExecStart=/home/palbot/palworld-bot/venv/bin/python -u main.py
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target
  1. Reload systemd configuration.
sudo systemctl daemon-reload
  1. Enable the service, then start it.
sudo systemctl enable palbot.service
sudo systemctl start palbot.service
  1. Then check the status of the Palworld bot or journal logs.
sudo systemctl status palbot.service
sudo journalctl -eu palbot.service

Updating the bot

  1. Switch to the bot user and cd into the directory.
su - palbot
cd palbworld-bot
  1. Pull the latest changes and run the requirements again.
git pull
source venv/bin/activate
pip install -r requirements.txt
  1. Restart the bot and verify that it's running.
sudo systemctl restart palbot.service
sudo systemctl status palbot.service
sudo journalctl -eu palbot.service