Pangolin Discord bot to Manage the stack

How to Deploy a Discord Bot to Monitor Your Pangolin Stack

Version 1.0.2 Avaliable now with AbuseIPDB blacklist import option in CrowdsecDecision command, new hub command and few other improvement

Running a self-hosted Pangolin stack is a powerful way to manage your online services with enhanced privacy and control. But keeping an eye on your server’s health, managing backups, and handling CrowdSec security can be time-consuming, especially when you’re away from your desk.

In this guide, I’ll show you how to deploy a specialized Discord bot that allows you to monitor and control your Pangolin stack directly from Discord. You’ll be able to check container status, manage backups, view logs, and even unban IPs all from your Discord server.

What is the Pangolin Discord Bot?

The Pangolin Discord Bot is a specialized monitoring and management tool that gives you remote control over your Pangolin stack through Discord’s slash commands. It provides a user-friendly interface to:

  • Monitor container health and status
  • Create and restore backups
  • View system metrics (CPU, memory, network)
  • Check CrowdSec security decisions
  • Handle IP whitelisting and unbanning
  • View and filter container logs
  • Restart, stop, or start containers as needed

Prerequisites

Before deploying the bot, ensure you have:

  1. A server running your Pangolin stack (with Docker)
  2. A Discord account and the ability to create a bot
  3. Basic familiarity with Docker and terminal commands
  4. SSH access to your server

Step 1: Create a Discord Bot Application

First, you’ll need to create a bot in the Discord Developer Portal:

  1. Go to Discord Developer Portal
  2. Click “New Application” and give it a name (e.g., “Pangolin Monitor”)
  3. Navigate to the “Bot” tab and click “Add Bot”
  4. Under the “Privileged Gateway Intents” section, enable “Server Members Intent”
  5. Save your changes
  6. Copy your bot token (you’ll need this later)

First

Second

Third

once collected. put it in the compose file.
bring the bot down

Redo

docker compose up -d

then

docker compose log -f

get the invite

paste it and approve it to the respective server.

Step 2: Prepare Your Server

SSH into your server and prepare to deploy the bot:

# Create a directory for the bot
mkdir -p ~/pangolin-bot
cd ~/pangolin-bot

# Create a backups directory
mkdir -p backups

Step 3: Deploy Using Docker Run

You can quickly deploy the bot using a single docker run command:

docker run -d \
  --name pangolin-discord-bot \
  --restart unless-stopped \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $(pwd)/backups:/app/backups \
  -v /proc:/host/proc:ro \
  -v /sys:/host/sys:ro \
  -v /root:/root:ro \
  -e DISCORD_TOKEN=your_token_here \
  -e DISCORD_CLIENT_ID=your_client_id_here \
  -e DISCORD_GUILD_ID=your_guild_id_here \
  -e BACKUP_DIR=/app/backups \
  -e HOST_PROC=/host/proc \
  -e HOST_SYS=/host/sys \
  hhftechnology/pangolin-discord-bot:latest

Make sure to replace:

  • your_token_here with your Discord bot token
  • your_client_id_here with your bot’s application ID
  • your_guild_id_here with your Discord server (guild) ID

Understanding the Docker Run Parameters:

  • -v /var/run/docker.sock:/var/run/docker.sock: Gives the bot access to your Docker daemon
  • -v $(pwd)/backups:/app/backups: Mounts a local folder for storing backups
  • -v /proc:/host/proc:ro: Provides read-only access to system metrics (CPU, memory)
  • -v /sys:/host/sys:ro: Provides read-only access to more system information
  • -v /root:/root:ro: Gives read-only access to your Pangolin configuration (for backups) Its can only detect if pangolin is deployed in root for backup.
  • Environment variables (-e): Configure the bot credentials and paths

Step 4: Deploy Using Docker Compose (Recommended)

For better maintainability, I recommend using Docker Compose. First, create a docker-compose.yml file:

nano docker-compose.yml

Paste the following content:

services:
  server-bot:
    container_name: pangolin-discord-bot
    image: hhftechnology/pangolin-discord-bot:latest
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - ./backups:/app/backups
      - /proc:/host/proc:ro
      - /sys:/host/sys:ro
      - /root:/root:ro
    environment:
      - DISCORD_TOKEN=your_token_here
      - DISCORD_CLIENT_ID=your_client_id_here
      - DISCORD_GUILD_ID=your_guild_id_here
      - BACKUP_DIR=/app/backups
      - HOST_PROC=/host/proc
      - HOST_SYS=/host/sys
    restart: unless-stopped

Again, replace the token, client ID, and guild ID with your actual values.

Then deploy with:

docker compose up -d

To check if the bot is running:

docker compose ps

You should see your bot container running. Next, copy the invitation link for your bot:
Once the bot is running:

docker compose logs -f


Copy the invite url and paste it in the browser.
Select the server where you need the bot and then your bot is register.

After Registering.

If you dont have a channel the create one

Using the Bot Commands

Once the bot is up and running, you can use the following slash commands in your Discord server:

System Health and Information

Container Management

Backup Management

CrowdSec Security Management

  • /crowdsecstatus - Check the status of your CrowdSec security
  • /crowdsecdecisions - List currently blocked IPs

Troubleshooting

If you encounter issues with the bot:

  1. Check the logs:

    docker logs pangolin-discord-bot
    
  2. Verify permissions:
    Ensure the bot has access to Docker by checking the socket mount:

    docker inspect pangolin-discord-bot | grep -A 10 Mounts
    
  3. Restart the bot:

    docker restart pangolin-discord-bot
    
  4. Update the bot:

    docker compose pull
    docker compose up -d
    

Security Considerations

The bot needs access to your Docker socket and certain system directories to function properly. This gives it significant permissions on your system. To enhance security:

  1. Use a dedicated Discord server for your bot and limit who has access to it
  2. Mount directories as read-only whenever possible (as shown in the examples)
  3. Regularly review the audit logs in Discord to monitor command usage
  4. Consider network isolation by using Docker’s network features
  5. Keep the bot updated to get the latest security patches

Advanced Features

Automatic Notifications

The bot can be configured to send notifications to a specific channel when issues are detected. Edit your docker-compose file to add:

services:
  server-bot:
    # ... existing configuration
    environment:
      # ... existing environment variables
      - ALERT_CHANNEL_ID=your_channel_id_here

Custom Health Monitoring

The bot includes an auto-healing feature that can automatically restart unhealthy containers. Use the /autorestart command to configure:

/autorestart enable pangolin 3

This will enable automatic restarts for the Pangolin container, with a maximum of 3 restart attempts per day.

Conclusion

With the Pangolin Discord Bot deployed, you now have a powerful remote monitoring and management solution for your self-hosted Pangolin stack. You can keep an eye on your server’s health, manage backups, and handle security issues all from the comfort of your Discord server.

The bot provides a convenient way to maintain your Pangolin stack without needing to SSH into your server for routine tasks. It’s especially useful for quick checks when you’re on the go or for sharing limited management capabilities with trusted team members.

By following this guide, you’ve expanded your Pangolin stack with a valuable management tool that enhances your ability to maintain your self-hosted services with minimal effort.

Remember to keep an eye on Docker and bot updates to ensure you’re running the latest version with all security patches and new features.

Happy monitoring!

If someone needs to see the repo

6 Likes

Hi @hhf.technoloy I am trying to figure this out. I have pulled the container it’s up and running (used docker-compose) I have liked the bot to the server, which was successful and logs show no errors.
If I got to a test channel in that server and type the commands, nothing happens…

1 Like


does it show like this?

No it does not even show up in the channels. Sorry

1 Like

First

Second

Third

once collected. put it in the compose file.
bring the bot down

Redo

docker compose up -d

then

docker compose log -f

get the invite

paste it and approve it to the respective server.

2 Likes


1 Like

Thanks, @hhf.technoloy made it work it’s a brilliant lightweight container

1 Like

have fun guys. In future it will be fully loaded with no need to login to ssh.

2 Likes


Bot is added to my server, container up and running on VPS, role is added but commands are not working. Any idea what I might be missing?


did you register using this link?
If yes.
then

docker compose down
docker system prune -af
docker compose up -d

then wait for a bit and share your results

docker compose logs -f
1 Like

Cool that fixed it! Not sure what it was, but all the commands show up now and work. Thanks!

2 Likes

have fun with the bot. do share your experience

This is amazing. Worked great first try. Thanks for this amazing tool.

1 Like

thanks bro. if you just want to use crowdsec then use :crowdsec tag.

Getting this error trying to use the docker pull

1 Like

Yes I am aware of this error. Will fix it next release coming week. There are few other too which I came to know

Hey there,
i followed all the instructions without any problems, but i cannot give any commands using “/” on my discord server. in our PM conversation you mentioned to check the bots logs - can you give me a hint where to find them?

1 Like

go to your bot folder and docker compose logs -f.

check your permissions and deployment steps.

ok i restarted everything and now most of it works! cool!
when i try to do a backup i get the following error in discord:

Failed to create backup: Command failed: cd “/root” && tar -czf “/app/backups/pangolin_backup_2025-03-26T08-56-40.tar.gz” docker-compose.yml config 2>/dev/null

probably a permissions issue…

1 Like