You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Impulse BBS移植Linux后.BRD文件缺失及自动创建脚本故障排查

Hey there, let's work through this .BRD file issue with your Impulse BBS port to Linux—super frustrating when random file deletions take down your system, right? Let's break down why your inotifywait script might not be working, and fix it step by step.

First: Diagnose the inotifywait Script Issues

Most of the time, these scripts fail for small, easy-to-miss reasons. Let's check the basics:

1. Are you monitoring the right path & events?

Double-check that your script is watching the exact directory where Impulse BBS stores its .BRD files. You can confirm this by running lsof | grep .BRD while the BBS is running—it'll show you the full path of active .BRD files.

Also, the DELETE event might not catch every scenario (like if the file is unlinked and the BBS immediately tries to access it). Instead, monitor the ACCESS event—this triggers when the BBS tries to open a missing file, which is exactly when you need to create it.

2. Fix the script with better event handling

Here's a revised script that addresses common gaps:

#!/bin/bash
# Replace with your actual .BRD directory path
BRD_STORAGE="/opt/impulse-bbs/boards"
# Replace with the user/group your BBS runs as (e.g., bbs:bbs)
BBS_USER="bbs"
BBS_GROUP="bbs"

# Monitor directory for file access events, loop indefinitely
inotifywait -m -e access --format "%f" "$BRD_STORAGE" | while read FILENAME; do
    # Only act on .BRD files that don't exist
    if [[ "$FILENAME" == *.BRD && ! -f "$BRD_STORAGE/$FILENAME" ]]; then
        echo "Recreating missing .BRD file: $FILENAME"
        touch "$BRD_STORAGE/$FILENAME"
        # Set correct permissions so the BBS can read/write
        chown "$BBS_USER:$BBS_GROUP" "$BRD_STORAGE/$FILENAME"
        chmod 644 "$BRD_STORAGE/$FILENAME"
    fi
done

Make the script executable with chmod +x brd-watcher.sh, and run it as the same user your BBS uses (or root, but better to match the BBS user for security).

3. Check inotify resource limits

Linux has a default limit on how many files/directories you can monitor with inotify. If you're watching a large directory, you might hit this cap. Check the current limit:

cat /proc/sys/fs/inotify/max_user_watches

If it's low (like 8192), bump it temporarily:

echo 1048576 > /proc/sys/fs/inotify/max_user_watches

To make this permanent, add fs.inotify.max_user_watches=1048576 to /etc/sysctl.conf and run sudo sysctl -p.

Dig Deeper: Why Are .BRD Files Being Deleted?

Fixing the symptom (auto-creating files) is great, but you should find the root cause to avoid future headaches. Use auditd to track who/what is deleting the files:

  1. Install auditd (e.g., sudo apt install auditd on Debian/Ubuntu)
  2. Add a rule to monitor .BRD file deletions:
    sudo auditctl -w "$BRD_STORAGE" -p wa -k brd-file-deletions
    
  3. When a file goes missing, check the audit logs:
    sudo ausearch -k brd-file-deletions
    

This will show you the exact process ID and command that deleted the file—could be a bug in the ported BBS code, a cleanup script, or even a permission issue causing accidental deletions.

Keep the Watcher Running Automatically

Don't forget to set up the script as a daemon so it runs when the BBS starts. Create a systemd service file (e.g., /etc/systemd/system/impulse-brd-watcher.service):

[Unit]
Description=Impulse BBS .BRD File Auto-Creation Watcher
After=impulse-bbs.service

[Service]
Type=simple
User=bbs
ExecStart=/opt/impulse-bbs/brd-watcher.sh
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target

Enable and start it with:

sudo systemctl daemon-reload
sudo systemctl enable impulse-brd-watcher.service
sudo systemctl start impulse-brd-watcher.service

内容的提问来源于stack exchange,提问作者ignatius

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 08:33:14